184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray/* 289daad6bae798779e57f252e9da4fe4e62337124Tim Murray * Copyright (C) 2013 The Android Open Source Project 384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * 484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * Licensed under the Apache License, Version 2.0 (the "License"); 584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * you may not use this file except in compliance with the License. 684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * You may obtain a copy of the License at 784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * 884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * http://www.apache.org/licenses/LICENSE-2.0 984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * 1084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * Unless required by applicable law or agreed to in writing, software 1184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * distributed under the License is distributed on an "AS IS" BASIS, 1284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * See the License for the specific language governing permissions and 1484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray * limitations under the License. 1584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray */ 1684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 1784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray#ifndef ANDROID_RSCPPSTRUCTS_H 1884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray#define ANDROID_RSCPPSTRUCTS_H 1984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 2089daad6bae798779e57f252e9da4fe4e62337124Tim Murray#include "rsDefines.h" 2189daad6bae798779e57f252e9da4fe4e62337124Tim Murray#include "util/RefBase.h" 22a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray#include "rsDispatch.h" 23a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray 2489daad6bae798779e57f252e9da4fe4e62337124Tim Murray#include <vector> 25ab71636b50db242cead6a3787620d6340156684cTim Murray#include <string> 268c24cd62187fb963cb1b76d2e91ae8c247c7f6fbTim Murray#include <pthread.h> 2789daad6bae798779e57f252e9da4fe4e62337124Tim Murray 2875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 2975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Every row in an RS allocation is guaranteed to be aligned by this amount, and 3075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * every row in a user-backed allocation must be aligned by this amount. 3175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 3296267c2ff0133c20cc5643419a3ed3b1e75fe568Tim Murray#define RS_CPU_ALLOCATION_ALIGNMENT 16 3396267c2ff0133c20cc5643419a3ed3b1e75fe568Tim Murray 3484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraynamespace android { 359eb7f4b90120ebe4be74343856e86b46495f72dfTim Murraynamespace RSC { 3684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 3784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraytypedef void (*ErrorHandlerFunc_t)(uint32_t errorNum, const char *errorText); 3884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraytypedef void (*MessageHandlerFunc_t)(uint32_t msgNum, const void *msgData, size_t msgLen); 3984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 4084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass RS; 4184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass BaseObj; 4284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Element; 4384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Type; 4484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Allocation; 4584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Script; 4684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass ScriptC; 47729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murrayclass Sampler; 4884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 4975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 5075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Possible error codes used by RenderScript. Once a status other than RS_SUCCESS 5175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * is returned, the RenderScript context is considered dead and cannot perform any 5275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * additional work. 5375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 5421fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray enum RSError { 5575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_SUCCESS = 0, ///< No error 5675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_ERROR_INVALID_PARAMETER = 1, ///< An invalid parameter was passed to a function 5775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_ERROR_RUNTIME_ERROR = 2, ///< The RenderScript driver returned an error; this is 5875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray ///< often indicative of a kernel that crashed 5975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_ERROR_INVALID_ELEMENT = 3, ///< An invalid Element was passed to a function 6021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray RS_ERROR_MAX = 9999 6121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray 6221fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray }; 6321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray 6475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 6575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * YUV formats supported by the RenderScript API. 6675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 67eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray enum RSYuvFormat { 6875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_YUV_NONE = 0, ///< No YUV data 6975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_YUV_YV12 = 1, ///< YUV data in YV12 format 7075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_YUV_NV21 = 2, ///< YUV data in NV21 format 71eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray RS_YUV_MAX = 3 72eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray }; 73eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray 7475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 7575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Flags that can control RenderScript behavior on a per-context level. 7675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 7784e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray enum RSInitFlags { 7875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_INIT_SYNCHRONOUS = 1, ///< All RenderScript calls will be synchronous. May reduce latency. 7975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RS_INIT_LOW_LATENCY = 2, ///< Prefer low latency devices over potentially higher throughput devices. 8084e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray RS_INIT_MAX = 4 8184e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray }; 8284e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray 8375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 8475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The RenderScript context. This class controls initialization, resource management, and teardown. 8575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 8689daad6bae798779e57f252e9da4fe4e62337124Tim Murray class RS : public android::RSC::LightRefBase<RS> { 8784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 8884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray public: 8984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RS(); 9084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray virtual ~RS(); 9184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 9275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 9375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Initializes a RenderScript context. A context must be initialized before it can be used. 94caf4126512b2152ea5f6573ce5d9ca29767b9678Tim Murray * @param[in] name Directory name to be used by this context. This should be equivalent to 95caf4126512b2152ea5f6573ce5d9ca29767b9678Tim Murray * Context.getCacheDir(). 9675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] flags Optional flags for this context. 9775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return true on success 9875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 99caf4126512b2152ea5f6573ce5d9ca29767b9678Tim Murray bool init(std::string name, uint32_t flags = 0); 10084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 10175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 10275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets the error handler function for this context. This error handler is 10375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * called whenever an error is set. 10475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 10575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] func Error handler function 10675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 10784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setErrorHandler(ErrorHandlerFunc_t func); 10875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 10975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 11075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the current error handler function for this context. 11175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 11275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return pointer to current error handler function or NULL if not set 11375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 11484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; } 11584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 11675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 11775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets the message handler function for this context. This message handler 11875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * is called whenever a message is sent from a RenderScript kernel. 11975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 12075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] func Message handler function 12175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 12284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setMessageHandler(MessageHandlerFunc_t func); 12375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 12475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 12575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the current message handler function for this context. 12675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 12775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return pointer to current message handler function or NULL if not set 12875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 12984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray MessageHandlerFunc_t getMessageHandler() { return mMessageFunc; } 13084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 13175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 13275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns current status for the context. 13375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 13475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return current error 13575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 13610913a5c37ba119bef335320d3e8be25212c05adTim Murray RSError getError(); 13784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 13875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 13975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Waits for any currently running asynchronous operations to finish. This 14075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * should only be used for performance testing and timing. 14175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 142baca6c3c3d79a324c7976ba873afdded0b6bcfb5Tim Murray void finish(); 143baca6c3c3d79a324c7976ba873afdded0b6bcfb5Tim Murray 14475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray RsContext getContext() { return mContext; } 14575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void throwError(RSError error, const char *errMsg); 14675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 147a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray static dispatchTable* dispatch; 148a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray 14984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray private: 1504a92d1268983edaf329f73c8a5b8860cdbb11596Tim Murray static bool usingNative; 151a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray static bool initDispatch(int targetApi); 152a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray 153caf4126512b2152ea5f6573ce5d9ca29767b9678Tim Murray bool init(std::string &name, int targetApi, uint32_t flags); 15484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static void * threadProc(void *); 15584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 15684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static bool gInitialized; 15784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static pthread_mutex_t gInitMutex; 15884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 15984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray pthread_t mMessageThreadId; 16084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray pid_t mNativeMessageThreadId; 16184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mMessageRun; 16284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 16384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RsDevice mDev; 16484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RsContext mContext; 16521fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray RSError mCurrentError; 16684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 16784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray ErrorHandlerFunc_t mErrorFunc; 16884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray MessageHandlerFunc_t mMessageFunc; 169a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray bool mInit; 17084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 171caf4126512b2152ea5f6573ce5d9ca29767b9678Tim Murray std::string mCacheDir; 172caf4126512b2152ea5f6573ce5d9ca29767b9678Tim Murray 17384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray struct { 17489daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> U8; 175eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U8_2; 176eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U8_3; 177eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U8_4; 17889daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> I8; 179eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I8_2; 180eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I8_3; 181eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I8_4; 18289daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> U16; 183eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U16_2; 184eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U16_3; 185eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U16_4; 18689daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> I16; 187eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I16_2; 188eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I16_3; 189eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I16_4; 19089daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> U32; 191eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U32_2; 192eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U32_3; 193eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U32_4; 19489daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> I32; 195eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I32_2; 196eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I32_3; 197eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I32_4; 19889daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> U64; 199eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U64_2; 200eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U64_3; 201eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> U64_4; 20289daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> I64; 203eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I64_2; 204eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I64_3; 205eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> I64_4; 20689daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> F32; 207eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> F32_2; 208eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> F32_3; 209eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> F32_4; 21089daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> F64; 211eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> F64_2; 212eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> F64_3; 213eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> F64_4; 21489daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> BOOLEAN; 21589daad6bae798779e57f252e9da4fe4e62337124Tim Murray 21689daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> ELEMENT; 21789daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> TYPE; 21889daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> ALLOCATION; 21989daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> SAMPLER; 22089daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> SCRIPT; 22189daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> MESH; 22289daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> PROGRAM_FRAGMENT; 22389daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> PROGRAM_VERTEX; 22489daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> PROGRAM_RASTER; 22589daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> PROGRAM_STORE; 22689daad6bae798779e57f252e9da4fe4e62337124Tim Murray 22789daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> A_8; 22889daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> RGB_565; 22989daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> RGB_888; 23089daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> RGBA_5551; 23189daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> RGBA_4444; 23289daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> RGBA_8888; 23389daad6bae798779e57f252e9da4fe4e62337124Tim Murray 234eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray sp<const Element> YUV; 23589daad6bae798779e57f252e9da4fe4e62337124Tim Murray 23689daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> MATRIX_4X4; 23789daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> MATRIX_3X3; 23889daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Element> MATRIX_2X2; 23984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } mElements; 24084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 241729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray struct { 24289daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> CLAMP_NEAREST; 24389daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> CLAMP_LINEAR; 24489daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR; 24589daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> WRAP_NEAREST; 24689daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> WRAP_LINEAR; 24789daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> WRAP_LINEAR_MIP_LINEAR; 24889daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> MIRRORED_REPEAT_NEAREST; 24989daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> MIRRORED_REPEAT_LINEAR; 25089daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR; 251729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray } mSamplers; 252729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray friend class Sampler; 253729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray friend class Element; 254caf4126512b2152ea5f6573ce5d9ca29767b9678Tim Murray friend class ScriptC; 25584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}; 25684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 25775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 25875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Base class for all RenderScript objects. Not for direct use by developers. 25975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 26089daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass BaseObj : public android::RSC::LightRefBase<BaseObj> { 26189daad6bae798779e57f252e9da4fe4e62337124Tim Murraypublic: 26289daad6bae798779e57f252e9da4fe4e62337124Tim Murray void * getID() const; 26389daad6bae798779e57f252e9da4fe4e62337124Tim Murray virtual ~BaseObj(); 26489daad6bae798779e57f252e9da4fe4e62337124Tim Murray virtual void updateFromNative(); 26589daad6bae798779e57f252e9da4fe4e62337124Tim Murray virtual bool equals(sp<const BaseObj> obj); 26689daad6bae798779e57f252e9da4fe4e62337124Tim Murray 26784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected: 26884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void *mID; 2693560907fa9b1624eefbd6db5e9c3ccc25ab23b92Tim Murray RS* mRS; 270ab71636b50db242cead6a3787620d6340156684cTim Murray std::string mName; 27184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 27284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray BaseObj(void *id, sp<RS> rs); 27384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void checkValid(); 27484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 27584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static void * getObjID(sp<const BaseObj> o); 27684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 27784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}; 27884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 27975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 28075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * This class provides the primary method through which data is passed to and 28175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * from RenderScript kernels. An Allocation provides the backing store for a 28275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * given Type. 28375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 28475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * An Allocation also contains a set of usage flags that denote how the 28575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Allocation could be used. For example, an Allocation may have usage flags 28675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * specifying that it can be used from a script as well as input to a 28775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sampler. A developer must synchronize across these different usages using 28875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * syncAll(int) in order to ensure that different users of the Allocation have 28975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * a consistent view of memory. For example, in the case where an Allocation is 29075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * used as the output of one kernel and as Sampler input in a later kernel, a 29175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * developer must call syncAll(RS_ALLOCATION_USAGE_SCRIPT) prior to launching the 29275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * second kernel to ensure correctness. 29375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 29484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Allocation : public BaseObj { 29584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected: 29689daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<const Type> mType; 29784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mUsage; 29889daad6bae798779e57f252e9da4fe4e62337124Tim Murray sp<Allocation> mAdaptedAllocation; 29984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 30084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mConstrainedLOD; 30184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mConstrainedFace; 30284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mConstrainedY; 30384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mConstrainedZ; 30484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mReadAllowed; 30584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mWriteAllowed; 30684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mSelectedY; 30784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mSelectedZ; 30884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mSelectedLOD; 30984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RsAllocationCubemapFace mSelectedFace; 31084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 31184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mCurrentDimX; 31284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mCurrentDimY; 31384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mCurrentDimZ; 31484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mCurrentCount; 31584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 31684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void * getIDSafe() const; 31784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void updateCacheInfo(sp<const Type> t); 31884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 31984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray Allocation(void *id, sp<RS> rs, sp<const Type> t, uint32_t usage); 32084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 32184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void validateIsInt32(); 32284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void validateIsInt16(); 32384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void validateIsInt8(); 32484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void validateIsFloat32(); 32584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void validateIsObject(); 32684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 32784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray virtual void updateFromNative(); 32884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 32984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h); 3309d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray void validate3DRange(uint32_t xoff, uint32_t yoff, uint32_t zoff, 3319d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray uint32_t w, uint32_t h, uint32_t d); 33284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 33384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic: 33475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 33575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 33675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Return Type for the allocation. 33775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return pointer to underlying Type 33875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 339a180b7d58ac6da9d6da866e43aa8c1fa83923dc5Stephen Hines sp<const Type> getType() const { 34084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mType; 34184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 34284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 34375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 34475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Propagate changes from one usage of the Allocation to other usages of the Allocation. 34575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] srcLocation source location with changes to propagate elsewhere 34675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 34784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void syncAll(RsAllocationUsageType srcLocation); 34884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void ioSendOutput(); 34984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void ioGetInput(); 35084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 35175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 35275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Generate a mipmap chain. This is only valid if the Type of the Allocation 35375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * includes mipmaps. This function will generate a complete set of mipmaps 35475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * from the top level LOD and place them into the script memory space. If 35575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * the Allocation is also using other memory spaces, a call to 35675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * syncAll(Allocation.USAGE_SCRIPT) is required. 35775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 35884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void generateMipmaps(); 359509ea5c832a865bc9083d53f1f058377a689bab3Tim Murray 36075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 36175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy an array into part of this Allocation. 36275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] off offset of first Element to be overwritten 36375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] count number of Elements to copy 36475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data array from which to copy 36575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 3660b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray void copy1DRangeFrom(uint32_t off, size_t count, const void *data); 36775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 36875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 36975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy part of an Allocation into part of this Allocation. 37075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] off offset of first Element to be overwritten 37175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] count number of Elements to copy 37275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data Allocation from which to copy 37375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dataOff offset of first Element in data to copy 37475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 375a4cbc2b0cf0f6fbdb21e84a3e17585eda1885e3eTim Murray void copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, uint32_t dataOff); 37684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 37775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 37875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy an array into part of this Allocation. 37975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] off offset of first Element to be overwritten 38075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] count number of Elements to copy 38175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data array from which to copy 38275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 3830b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray void copy1DRangeTo(uint32_t off, size_t count, void *data); 384a4cbc2b0cf0f6fbdb21e84a3e17585eda1885e3eTim Murray 38575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 38675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy entire array to an Allocation. 38775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data array from which to copy 38875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 3890b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray void copy1DFrom(const void* data); 39075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 39175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 39275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy entire Allocation to an array. 39375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data destination array 39475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 3950b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray void copy1DTo(void* data); 3960b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray 39775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 39875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from an array into a rectangular region in this Allocation. The 39975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * array is assumed to be tightly packed. 40075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] xoff X offset of region to update in this Allocation 40175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] yoff Y offset of region to update in this Allocation 40275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] w Width of region to update 40375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] h Height of region to update 40475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data Array from which to copy 40575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 4060b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, 4070b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray const void *data); 4087b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray 40975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 41075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from this Allocation into a rectangular region in an array. The 41175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * array is assumed to be tightly packed. 41275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] xoff X offset of region to copy from this Allocation 41375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] yoff Y offset of region to copy from this Allocation 41475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] w Width of region to update 41575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] h Height of region to update 41675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data destination array 41775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 4187b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray void copy2DRangeTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, 4197b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray void *data); 4207b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray 42175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 42275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from an Allocation into a rectangular region in this Allocation. 42375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] xoff X offset of region to update in this Allocation 42475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] yoff Y offset of region to update in this Allocation 42575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] w Width of region to update 42675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] h Height of region to update 42775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data Allocation from which to copy 42875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dataXoff X offset of region to copy from in data 42975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dataYoff Y offset of region to copy from in data 43075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 43184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, 4320b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff); 43384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 43475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 43575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from a strided array into a rectangular region in this Allocation. 43675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] xoff X offset of region to update in this Allocation 43775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] yoff Y offset of region to update in this Allocation 43875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] w Width of region to update 43975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] h Height of region to update 44075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data array from which to copy 44175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] stride stride of data in bytes 44275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 443358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray void copy2DStridedFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, 444358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray const void *data, size_t stride); 44575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 44675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 44775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from a strided array into this Allocation. 44875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data array from which to copy 44975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] stride stride of data in bytes 45075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 451358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray void copy2DStridedFrom(const void *data, size_t stride); 452358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray 45375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 45475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from a rectangular region in this Allocation into a strided array. 45575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] xoff X offset of region to update in this Allocation 45675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] yoff Y offset of region to update in this Allocation 45775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] w Width of region to update 45875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] h Height of region to update 45975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data destination array 46075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] stride stride of data in bytes 46175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 462358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray void copy2DStridedTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, 463358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray void *data, size_t stride); 46475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 46575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 46675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy this Allocation into a strided array. 46775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data destination array 46875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] stride stride of data in bytes 46975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 470358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray void copy2DStridedTo(void *data, size_t stride); 471358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray 47275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 47375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 47475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from an array into a 3D region in this Allocation. The 47575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * array is assumed to be tightly packed. 47675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] xoff X offset of region to update in this Allocation 47775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] yoff Y offset of region to update in this Allocation 47875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] zoff Z offset of region to update in this Allocation 47975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] w Width of region to update 48075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] h Height of region to update 48175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] d Depth of region to update 48275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data Array from which to copy 48375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 4849d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w, 4859d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray uint32_t h, uint32_t d, const void* data); 4869d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray 48775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 48875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Copy from an Allocation into a 3D region in this Allocation. 48975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] xoff X offset of region to update in this Allocation 49075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] yoff Y offset of region to update in this Allocation 49175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] zoff Z offset of region to update in this Allocation 49275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] w Width of region to update 49375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] h Height of region to update 49475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] d Depth of region to update 49575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] data Allocation from which to copy 49675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dataXoff X offset of region in data to copy from 49775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dataYoff Y offset of region in data to copy from 49875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dataZoff Z offset of region in data to copy from 49975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 5009d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff, 5019d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray uint32_t w, uint32_t h, uint32_t d, 5029d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray sp<const Allocation> data, 5039d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray uint32_t dataXoff, uint32_t dataYoff, uint32_t dataZoff); 50484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 50575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 50675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates an Allocation for use by scripts with a given Type. 50775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs Context to which the Allocation will belong 50875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] type Type of the Allocation 5098f615d682f9e7e2cd4de2e4478e0e76fc359922cStephen Hines * @param[in] mipmaps desired mipmap behavior for the Allocation 51075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] usage usage for the Allocation 51175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new Allocation 51275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 51384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type, 5148f615d682f9e7e2cd4de2e4478e0e76fc359922cStephen Hines RsAllocationMipmapControl mipmaps, uint32_t usage); 51575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 51675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 51775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates an Allocation for use by scripts with a given Type and a backing pointer. For use 51875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * with RS_ALLOCATION_USAGE_SHARED. 51975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs Context to which the Allocation will belong 52075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] type Type of the Allocation 5218f615d682f9e7e2cd4de2e4478e0e76fc359922cStephen Hines * @param[in] mipmaps desired mipmap behavior for the Allocation 52275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] usage usage for the Allocation 52375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] pointer existing backing store to use for this Allocation if possible 52475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new Allocation 52575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 52684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type, 5278f615d682f9e7e2cd4de2e4478e0e76fc359922cStephen Hines RsAllocationMipmapControl mipmaps, uint32_t usage, void * pointer); 52884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 52975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 53075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates an Allocation for use by scripts with a given Type with no mipmaps. 53175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs Context to which the Allocation will belong 53275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] type Type of the Allocation 53375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] usage usage for the Allocation 53475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new Allocation 53575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 53684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type, 53784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT); 53875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 53975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates an Allocation with a specified number of given elements. 54075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs Context to which the Allocation will belong 54175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element used in the Allocation 54275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] count Number of elements of the Allocation 54375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] usage usage for the Allocation 54475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new Allocation 54575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 54684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<Allocation> createSized(sp<RS> rs, sp<const Element> e, size_t count, 54784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT); 54875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 54975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 55075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates a 2D Allocation with a specified number of given elements. 55175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs Context to which the Allocation will belong 55275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element used in the Allocation 55375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] x Width in Elements of the Allocation 55475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] y Height of the Allocation 55575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] usage usage for the Allocation 55675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new Allocation 55775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 558684726cbbd177ee4ee9000e9422058547acd237fTim Murray static sp<Allocation> createSized2D(sp<RS> rs, sp<const Element> e, 559684726cbbd177ee4ee9000e9422058547acd237fTim Murray size_t x, size_t y, 560684726cbbd177ee4ee9000e9422058547acd237fTim Murray uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT); 561684726cbbd177ee4ee9000e9422058547acd237fTim Murray 56284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 563b8a94e26c0a5e8f58d5b6ed04e46b411e95b77a4Jason Sams /** 564b8a94e26c0a5e8f58d5b6ed04e46b411e95b77a4Jason Sams * Get the backing pointer for a USAGE_SHARED allocation. 565b8a94e26c0a5e8f58d5b6ed04e46b411e95b77a4Jason Sams * @param[in] stride optional parameter. when non-NULL, will contain 566b8a94e26c0a5e8f58d5b6ed04e46b411e95b77a4Jason Sams * stride in bytes of a 2D Allocation 567b8a94e26c0a5e8f58d5b6ed04e46b411e95b77a4Jason Sams * @return pointer to data 568b8a94e26c0a5e8f58d5b6ed04e46b411e95b77a4Jason Sams */ 569b8a94e26c0a5e8f58d5b6ed04e46b411e95b77a4Jason Sams void * getPointer(size_t *stride = NULL); 57084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}; 57184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 57275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 57375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * An Element represents one item within an Allocation. An Element is roughly 57475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * equivalent to a C type in a RenderScript kernel. Elements may be basic 57575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * or complex. Some basic elements are: 57675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 57775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * - A single float value (equivalent to a float in a kernel) 57875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * - A four-element float vector (equivalent to a float4 in a kernel) 57975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * - An unsigned 32-bit integer (equivalent to an unsigned int in a kernel) 58075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * - A single signed 8-bit integer (equivalent to a char in a kernel) 58175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 58275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Basic Elements are comprised of a Element.DataType and a 58375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Element.DataKind. The DataType encodes C type information of an Element, 58475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * while the DataKind encodes how that Element should be interpreted by a 58575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sampler. Note that Allocation objects with DataKind USER cannot be used as 58675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * input for a Sampler. In general, Allocation objects that are intended for 58775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * use with a Sampler should use bitmap-derived Elements such as 58875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Element::RGBA_8888. 58975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 59075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 59175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 59284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Element : public BaseObj { 59384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic: 59484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool isComplex(); 59575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 59675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 59775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Elements could be simple, such as an int or a float, or a structure with 59875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * multiple sub-elements, such as a collection of floats, float2, 59975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * float4. This function returns zero for simple elements or the number of 60075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * sub-elements otherwise. 60175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return number of sub-elements 60275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 60384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t getSubElementCount() { 60484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mVisibleElementMap.size(); 60584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 60684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 60775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 60875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * For complex Elements, this returns the sub-element at a given index. 60975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] index index of sub-element 61075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return sub-element 61175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 61284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Element> getSubElement(uint32_t index); 61375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 61475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 61575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * For complex Elements, this returns the name of the sub-element at a given 61675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * index. 61775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] index index of sub-element 61875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return name of sub-element 61975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 62084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray const char * getSubElementName(uint32_t index); 62175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 62275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 62375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * For complex Elements, this returns the size of the sub-element at a given 62475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * index. 62575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] index index of sub-element 62675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return size of sub-element 62775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 62884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t getSubElementArraySize(uint32_t index); 62975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 63075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 63175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the location of a sub-element within a complex Element. 63275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] index index of sub-element 63375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return offset in bytes 63475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 63584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t getSubElementOffsetBytes(uint32_t index); 63675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 63775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 63875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the data type used for the Element. 63975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return data type 64075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 64184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RsDataType getDataType() const { 64284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mType; 64384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 64484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 64575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 64675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the data kind used for the Element. 64775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return data kind 64875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 64984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RsDataKind getDataKind() const { 65084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mKind; 65184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 65284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 65375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 65475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the size in bytes of the Element. 65575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return size in bytes 65675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 65784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t getSizeBytes() const { 65884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mSizeBytes; 65984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 66084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 66175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 66275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the number of vector components for this Element. 66375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return number of vector components 66475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 66510913a5c37ba119bef335320d3e8be25212c05adTim Murray uint32_t getVectorSize() const { 66610913a5c37ba119bef335320d3e8be25212c05adTim Murray return mVectorSize; 66710913a5c37ba119bef335320d3e8be25212c05adTim Murray } 66810913a5c37ba119bef335320d3e8be25212c05adTim Murray 66975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 67075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single bool. 67175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 67275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 67375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 67484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> BOOLEAN(sp<RS> rs); 67575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 67675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single unsigned char. 67775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 67875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 67975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 68084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U8(sp<RS> rs); 68175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 68275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single signed char. 68375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 68475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 68575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 68684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I8(sp<RS> rs); 68775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 68875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single unsigned short. 68975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 69075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 69175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 69284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U16(sp<RS> rs); 69375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 69475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single signed short. 69575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 69675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 69775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 69884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I16(sp<RS> rs); 69975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 70075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single unsigned int. 70175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 70275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 70375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 70484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U32(sp<RS> rs); 70575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 70675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single signed int. 70775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 70875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 70975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 71084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I32(sp<RS> rs); 71175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 71275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single unsigned long long. 71375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 71475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 71575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 71684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U64(sp<RS> rs); 71775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 71875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single signed long long. 71975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 72075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 72175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 72284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I64(sp<RS> rs); 72375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 72475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single float. 72575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 72675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 72775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 72884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F32(sp<RS> rs); 72975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 73075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single double. 73175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 73275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 73375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 73484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F64(sp<RS> rs); 73575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 73675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single Element. 73775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 73875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 73975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 74084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> ELEMENT(sp<RS> rs); 74175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 74275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single Type. 74375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 74475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 74575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 74684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> TYPE(sp<RS> rs); 74775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 74875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single Allocation. 74975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 75075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 75175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 75284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> ALLOCATION(sp<RS> rs); 75375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 75475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single Sampler. 75575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 75675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 75775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 75884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> SAMPLER(sp<RS> rs); 75975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 76075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a single Script. 76175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 76275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 76375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 76484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> SCRIPT(sp<RS> rs); 76575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 76675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an ALPHA_8 pixel. 76775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 76875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 76975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 77084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> A_8(sp<RS> rs); 77175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 77275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an RGB_565 pixel. 77375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 77475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 77575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 77684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> RGB_565(sp<RS> rs); 77775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 77875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an RGB_888 pixel. 77975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 78075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 78175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 78284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> RGB_888(sp<RS> rs); 78375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 78475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an RGBA_5551 pixel. 78575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 78675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 78775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 78884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> RGBA_5551(sp<RS> rs); 78975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 79075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an RGBA_4444 pixel. 79175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 79275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 79375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 79484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> RGBA_4444(sp<RS> rs); 79575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 79675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an RGBA_8888 pixel. 79775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 79875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 79975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 80084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> RGBA_8888(sp<RS> rs); 80184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 80275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 80375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a float2. 80475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 80575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 80675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 80784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F32_2(sp<RS> rs); 80875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 80975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a float3. 81075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 81175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 81275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 81384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F32_3(sp<RS> rs); 81475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 81575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a float4. 81675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 81775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 81875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 81984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F32_4(sp<RS> rs); 82075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 82175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a double2. 82275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 82375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 82475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 82584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F64_2(sp<RS> rs); 82675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 82775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a double3. 82875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 82975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 83075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 83184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F64_3(sp<RS> rs); 83275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 83375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a double4. 83475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 83575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 83675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 83784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> F64_4(sp<RS> rs); 83875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 83975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a uchar2. 84075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 84175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 84275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 84384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U8_2(sp<RS> rs); 84475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 84575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a uchar3. 84675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 84775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 84875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 84984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U8_3(sp<RS> rs); 85075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 85175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a uchar4. 85275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 85375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 85475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 85584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U8_4(sp<RS> rs); 85675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 85775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a char2. 85875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 85975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 86075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 86184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I8_2(sp<RS> rs); 86275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 86375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a char3. 86475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 86575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 86675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 86784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I8_3(sp<RS> rs); 86875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 86975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a char4. 87075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 87175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 87275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 87384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I8_4(sp<RS> rs); 87475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 87575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a ushort2. 87675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 87775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 87875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 87984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U16_2(sp<RS> rs); 88075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 88175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a ushort3. 88275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 88375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 88475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 88584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U16_3(sp<RS> rs); 88675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 88775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a ushort4. 88875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 88975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 89075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 89184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U16_4(sp<RS> rs); 89275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 89375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a short2. 89475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 89575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 89675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 89784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I16_2(sp<RS> rs); 89875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 89975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a short3. 90075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 90175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 90275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 90384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I16_3(sp<RS> rs); 90475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 90575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a short4. 90675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 90775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 90875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 90984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I16_4(sp<RS> rs); 91075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 91175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a uint2. 91275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 91375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 91475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 91584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U32_2(sp<RS> rs); 91675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 91775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a uint3. 91875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 91975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 92075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 92184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U32_3(sp<RS> rs); 92275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 92375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a uint4. 92475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 92575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 92675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 92784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U32_4(sp<RS> rs); 92875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 92975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an int2. 93075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 93175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 93275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 93384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I32_2(sp<RS> rs); 93475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 93575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an int3. 93675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 93775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 93875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 93984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I32_3(sp<RS> rs); 94075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 94175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an int4. 94275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 94375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 94475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 94584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I32_4(sp<RS> rs); 94675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 94775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a ulong2. 94875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 94975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 95075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 95184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U64_2(sp<RS> rs); 95275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 95375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a ulong3. 95475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 95575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 95675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 95784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U64_3(sp<RS> rs); 95875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 95975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a ulong4. 96075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 96175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 96275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 96384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> U64_4(sp<RS> rs); 96475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 96575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a long2. 96675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 96775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 96875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 96984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I64_2(sp<RS> rs); 97075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 97175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a long3. 97275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 97375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 97475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 97584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I64_3(sp<RS> rs); 97675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 97775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a long4. 97875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 97975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 98075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 98184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> I64_4(sp<RS> rs); 98275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 98375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing a YUV pixel. 98475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 98575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 98675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 987eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray static sp<const Element> YUV(sp<RS> rs); 98875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 98975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an rs_matrix_4x4. 99075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 99175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 99275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 99384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> MATRIX_4X4(sp<RS> rs); 99475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 99575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an rs_matrix_3x3. 99675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 99775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 99875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 99984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> MATRIX_3X3(sp<RS> rs); 100075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 100175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Utility function for returning an Element containing an rs_matrix_2x2. 100275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 100375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 100475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 100584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> MATRIX_2X2(sp<RS> rs); 100684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 100784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void updateFromNative(); 100875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 100975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 101075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Create an Element with a given DataType. 101175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 101275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dt data type 101375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 101475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 101584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> createUser(sp<RS> rs, RsDataType dt); 101675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 101775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Create a vector Element with the given DataType 101875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript 101975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dt DataType 102075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] size vector size 102175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 102275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 102384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> createVector(sp<RS> rs, RsDataType dt, uint32_t size); 102475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 102575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Create an Element with a given DataType and DataKind. 102675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 102775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dt DataType 102875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dk DataKind 102975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Element 103075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 103184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray static sp<const Element> createPixel(sp<RS> rs, RsDataType dt, RsDataKind dk); 103275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 103375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 103475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns true if the Element can interoperate with this Element. 103575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element to compare 103675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return true if Elements can interoperate 103775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 103810913a5c37ba119bef335320d3e8be25212c05adTim Murray bool isCompatible(sp<const Element>e) const; 103984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 104075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 104175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Builder class for producing complex elements with matching field and name 104275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * pairs. The builder starts empty. The order in which elements are added is 104375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * retained for the layout in memory. 104475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 104584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray class Builder { 104684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray private: 10473560907fa9b1624eefbd6db5e9c3ccc25ab23b92Tim Murray RS* mRS; 104889daad6bae798779e57f252e9da4fe4e62337124Tim Murray std::vector<sp<Element> > mElements; 1049ab71636b50db242cead6a3787620d6340156684cTim Murray std::vector<std::string> mElementNames; 105089daad6bae798779e57f252e9da4fe4e62337124Tim Murray std::vector<uint32_t> mArraySizes; 105184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mSkipPadding; 105284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 105384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray public: 105484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray Builder(sp<RS> rs); 105584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray ~Builder(); 1056ab71636b50db242cead6a3787620d6340156684cTim Murray void add(sp<Element> e, std::string &name, uint32_t arraySize = 1); 105784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Element> create(); 105884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray }; 105984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 10607d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hinesprotected: 10617d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines Element(void *id, sp<RS> rs, 10627d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines std::vector<sp<Element> > &elements, 10637d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines std::vector<std::string> &elementNames, 10647d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines std::vector<uint32_t> &arraySizes); 10657d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size); 10667d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines Element(sp<RS> rs); 10677d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines virtual ~Element(); 10687d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines 106984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprivate: 107084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void updateVisibleSubElements(); 107184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 107289daad6bae798779e57f252e9da4fe4e62337124Tim Murray std::vector<sp<Element> > mElements; 1073ab71636b50db242cead6a3787620d6340156684cTim Murray std::vector<std::string> mElementNames; 107489daad6bae798779e57f252e9da4fe4e62337124Tim Murray std::vector<uint32_t> mArraySizes; 107589daad6bae798779e57f252e9da4fe4e62337124Tim Murray std::vector<uint32_t> mVisibleElementMap; 107689daad6bae798779e57f252e9da4fe4e62337124Tim Murray std::vector<uint32_t> mOffsetInBytes; 107784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 107884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RsDataType mType; 107984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray RsDataKind mKind; 108084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mNormalized; 108184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t mSizeBytes; 108284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t mVectorSize; 108384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}; 108484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 10852c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hinesclass FieldPacker { 10862c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hinesprotected: 10872c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines unsigned char* mData; 10882c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines size_t mPos; 10892c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines size_t mLen; 10902c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 10912c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hinespublic: 10922c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines FieldPacker(size_t len) 109389daad6bae798779e57f252e9da4fe4e62337124Tim Murray : mPos(0), mLen(len) { 109489daad6bae798779e57f252e9da4fe4e62337124Tim Murray mData = new unsigned char[len]; 109589daad6bae798779e57f252e9da4fe4e62337124Tim Murray } 10962c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 10972c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines virtual ~FieldPacker() { 10982c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines delete [] mData; 10992c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11002c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11012c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines void align(size_t v) { 11022c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines if ((v & (v - 1)) != 0) { 1103ab71636b50db242cead6a3787620d6340156684cTim Murray // ALOGE("Non-power-of-two alignment: %zu", v); 11042c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines return; 11052c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11062c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11072c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines while ((mPos & (v - 1)) != 0) { 11082c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines mData[mPos++] = 0; 11092c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11102c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11112c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11122c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines void reset() { 11132c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines mPos = 0; 11142c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11152c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11162c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines void reset(size_t i) { 11172c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines if (i >= mLen) { 1118ab71636b50db242cead6a3787620d6340156684cTim Murray // ALOGE("Out of bounds: i (%zu) >= len (%zu)", i, mLen); 11192c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines return; 11202c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11212c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines mPos = i; 11222c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11232c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11242c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines void skip(size_t i) { 11252c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines size_t res = mPos + i; 11262c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines if (res > mLen) { 1127ab71636b50db242cead6a3787620d6340156684cTim Murray // ALOGE("Exceeded buffer length: i (%zu) > len (%zu)", i, mLen); 11282c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines return; 11292c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11302c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines mPos = res; 11312c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11322c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11332c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines void* getData() const { 11342c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines return mData; 11352c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11362c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11372c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines size_t getLength() const { 11382c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines return mLen; 11392c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11402c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 11412c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines template <typename T> 114289daad6bae798779e57f252e9da4fe4e62337124Tim Murray void add(T t) { 11432c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines align(sizeof(t)); 11442c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines if (mPos + sizeof(t) <= mLen) { 11452c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines memcpy(&mData[mPos], &t, sizeof(t)); 11462c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines mPos += sizeof(t); 11472c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 11482c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines } 114943514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines 115043514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines /* 115189daad6bae798779e57f252e9da4fe4e62337124Tim Murray void add(rs_matrix4x4 m) { 115289daad6bae798779e57f252e9da4fe4e62337124Tim Murray for (size_t i = 0; i < 16; i++) { 115389daad6bae798779e57f252e9da4fe4e62337124Tim Murray add(m.m[i]); 115489daad6bae798779e57f252e9da4fe4e62337124Tim Murray } 115589daad6bae798779e57f252e9da4fe4e62337124Tim Murray } 115689daad6bae798779e57f252e9da4fe4e62337124Tim Murray 115789daad6bae798779e57f252e9da4fe4e62337124Tim Murray void add(rs_matrix3x3 m) { 115889daad6bae798779e57f252e9da4fe4e62337124Tim Murray for (size_t i = 0; i < 9; i++) { 115989daad6bae798779e57f252e9da4fe4e62337124Tim Murray add(m.m[i]); 116089daad6bae798779e57f252e9da4fe4e62337124Tim Murray } 116189daad6bae798779e57f252e9da4fe4e62337124Tim Murray } 116289daad6bae798779e57f252e9da4fe4e62337124Tim Murray 116389daad6bae798779e57f252e9da4fe4e62337124Tim Murray void add(rs_matrix2x2 m) { 116489daad6bae798779e57f252e9da4fe4e62337124Tim Murray for (size_t i = 0; i < 4; i++) { 116589daad6bae798779e57f252e9da4fe4e62337124Tim Murray add(m.m[i]); 116689daad6bae798779e57f252e9da4fe4e62337124Tim Murray } 116789daad6bae798779e57f252e9da4fe4e62337124Tim Murray } 116843514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines */ 116943514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines 117089daad6bae798779e57f252e9da4fe4e62337124Tim Murray void add(sp<BaseObj> obj) { 117143514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines if (obj != NULL) { 117243514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines add((uint32_t) (uintptr_t) obj->getID()); 117343514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines } else { 117443514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines add((uint32_t) 0); 117543514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines } 117643514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines } 11772c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines}; 11782c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines 117975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 118075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type describes the Element and dimensions used for an Allocation or a 118175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * parallel operation. 118275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 118375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type always includes an Element and an X dimension. A Type may be 118475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * multidimensional, up to three dimensions. A nonzero value in the Y or Z 118575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * dimensions indicates that the dimension is present. Note that a Type with 118675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * only a given X dimension and a Type with the same X dimension but Y = 1 are 118775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * not equivalent. 118875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 118975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type also supports inclusion of level of detail (LOD) or cube map 119075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * faces. LOD and cube map faces are booleans to indicate present or not 119175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * present. 119275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 119375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type also supports YUV format information to support an Allocation in a YUV 119475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * format. The YUV formats supported are YV12 and NV21. 119575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 119684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Type : public BaseObj { 119784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected: 119884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray friend class Allocation; 119984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 120084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mDimX; 120184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mDimY; 120284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mDimZ; 1203eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray RSYuvFormat mYuvFormat; 120484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mDimMipmaps; 120584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mDimFaces; 120684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t mElementCount; 120784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Element> mElement; 120884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 12097d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines Type(void *id, sp<RS> rs); 12107d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines 121184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void calcElementCount(); 121284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray virtual void updateFromNative(); 121384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 121484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic: 121584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 121675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 121775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the YUV format. 121875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return YUV format of the Allocation 121975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1220eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray RSYuvFormat getYuvFormat() const { 1221eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray return mYuvFormat; 1222eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray } 1223eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray 122475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 122575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the Element of the Allocation. 122675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return YUV format of the Allocation 122775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 122884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Element> getElement() const { 122984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mElement; 123084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 123184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 123275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 123375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the X dimension of the Allocation. 123475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return X dimension of the allocation 123575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 123684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t getX() const { 123784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mDimX; 123884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 123984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 124075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 124175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the Y dimension of the Allocation. 124275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Y dimension of the allocation 124375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 124484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t getY() const { 124584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mDimY; 124684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 124784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 124875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 124975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns the Z dimension of the Allocation. 125075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Z dimension of the allocation 125175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 125284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t getZ() const { 125384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mDimZ; 125484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 125584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 125675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 125775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns true if the Allocation has mipmaps. 125875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return true if the Allocation has mipmaps 125975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 126084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool hasMipmaps() const { 126184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mDimMipmaps; 126284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 126384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 126475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 126575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns true if the Allocation is a cube map 126675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return true if the Allocation is a cube map 126775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 126884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool hasFaces() const { 126984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mDimFaces; 127084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 127184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 127275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 127375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns number of accessible Elements in the Allocation 127475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return number of accessible Elements in the Allocation 127575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 127684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t getCount() const { 127784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mElementCount; 127884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 127984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 128075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 128175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Returns size in bytes of all Elements in the Allocation 128275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return size in bytes of all Elements in the Allocation 128375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 128484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray size_t getSizeBytes() const { 128584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mElementCount * mElement->getSizeBytes(); 128684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 128784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 128875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 128975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates a new Type with the given Element and dimensions. 129075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 129175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element 129275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dimX X dimension 129375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dimY Y dimension 129475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] dimZ Z dimension 129575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new Type 129675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 129796267c2ff0133c20cc5643419a3ed3b1e75fe568Tim Murray static sp<const Type> create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint32_t dimY, uint32_t dimZ); 129884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 129984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray class Builder { 130084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray protected: 13013560907fa9b1624eefbd6db5e9c3ccc25ab23b92Tim Murray RS* mRS; 130284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mDimX; 130384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mDimY; 130484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray uint32_t mDimZ; 1305eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray RSYuvFormat mYuvFormat; 130684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mDimMipmaps; 130784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray bool mDimFaces; 130884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Element> mElement; 130984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 131084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray public: 131184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray Builder(sp<RS> rs, sp<const Element> e); 131284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 131384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setX(uint32_t value); 13147d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines void setY(uint32_t value); 1315eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray void setZ(uint32_t value); 1316eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray void setYuvFormat(RSYuvFormat format); 131784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setMipmaps(bool value); 131884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setFaces(bool value); 131984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Type> create(); 132084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray }; 132184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 132284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}; 132384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 132475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 132575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The parent class for all executable Scripts. This should not be used by applications. 132675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 132784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Script : public BaseObj { 132884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprivate: 132984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 133084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected: 133184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray Script(void *id, sp<RS> rs); 133284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void forEach(uint32_t slot, sp<const Allocation> in, sp<const Allocation> out, 133384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray const void *v, size_t) const; 133484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void bindAllocation(sp<Allocation> va, uint32_t slot) const; 133584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setVar(uint32_t index, const void *, size_t len) const; 133684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setVar(uint32_t index, sp<const BaseObj> o) const; 133784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void invoke(uint32_t slot, const void *v, size_t len) const; 133884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 133984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 134084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void invoke(uint32_t slot) const { 134184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray invoke(slot, NULL, 0); 134284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 134384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setVar(uint32_t index, float v) const { 134484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray setVar(index, &v, sizeof(v)); 134584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 134684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setVar(uint32_t index, double v) const { 134784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray setVar(index, &v, sizeof(v)); 134884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 134984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setVar(uint32_t index, int32_t v) const { 135084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray setVar(index, &v, sizeof(v)); 135184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 135284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setVar(uint32_t index, int64_t v) const { 135384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray setVar(index, &v, sizeof(v)); 135484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 135584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void setVar(uint32_t index, bool v) const { 135684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray setVar(index, &v, sizeof(v)); 135784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 135884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 135984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic: 136084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray class FieldBase { 136184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray protected: 136284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Element> mElement; 136384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<Allocation> mAllocation; 136484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 136584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray void init(sp<RS> rs, uint32_t dimx, uint32_t usages = 0); 136684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 136784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray public: 136884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Element> getElement() { 136984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mElement; 137084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 137184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 137284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Type> getType() { 137384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mAllocation->getType(); 137484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 137584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 137684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray sp<const Allocation> getAllocation() { 137784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray return mAllocation; 137884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray } 137984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 138084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray //void updateAllocation(); 138184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray }; 138284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}; 138384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 138475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 138575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The parent class for all user-defined scripts. This is intended to be used by auto-generated code only. 138675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 138784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass ScriptC : public Script { 138884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected: 138984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray ScriptC(sp<RS> rs, 139084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray const void *codeTxt, size_t codeLength, 139184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray const char *cachedName, size_t cachedNameLength, 139284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray const char *cacheDir, size_t cacheDirLength); 139384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 139484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}; 139584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 139675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 139775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The parent class for all script intrinsics. Intrinsics provide highly optimized implementations of 139875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * basic functions. This is not intended to be used directly. 139975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 14007f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murrayclass ScriptIntrinsic : public Script { 14017f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray protected: 140210913a5c37ba119bef335320d3e8be25212c05adTim Murray sp<const Element> mElement; 14033cd44af22622898d3000b2b3c4c408cede294152Tim Murray ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e); 1404b27b18130d0772203799ba0f2d27783b640dc891Tim Murray virtual ~ScriptIntrinsic(); 14057f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray}; 14067f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray 140775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 140875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for converting RGB to RGBA by using a 3D lookup table. The incoming 140975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * r,g,b values are use as normalized x,y,z coordinates into a 3D 141075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * allocation. The 8 nearest values are sampled and linearly interpolated. The 141175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * result is placed in the output. 141275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 141389daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsic3DLUT : public ScriptIntrinsic { 141421fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 141589daad6bae798779e57f252e9da4fe4e62337124Tim Murray ScriptIntrinsic3DLUT(sp<RS> rs, sp<const Element> e); 141621fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 141775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 141875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported Element types are U8_4. Default lookup table is identity. 141975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 142075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element 142175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new ScriptIntrinsic 142275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 142321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray static sp<ScriptIntrinsic3DLUT> create(sp<RS> rs, sp<const Element> e); 142475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 142575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 142675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Launch the intrinsic. 142775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] ain input Allocation 142875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] aout output Allocation 142975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 143089daad6bae798779e57f252e9da4fe4e62337124Tim Murray void forEach(sp<Allocation> ain, sp<Allocation> aout); 143175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 143275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 143375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets the lookup table. The lookup table must use the same Element as the 143475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * intrinsic. 143575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] lut new lookup table 143675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 143789daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setLUT(sp<Allocation> lut); 143889daad6bae798779e57f252e9da4fe4e62337124Tim Murray}; 143989daad6bae798779e57f252e9da4fe4e62337124Tim Murray 144075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 144175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic kernel for blending two Allocations. 144275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 14437f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murrayclass ScriptIntrinsicBlend : public ScriptIntrinsic { 144421fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 144589daad6bae798779e57f252e9da4fe4e62337124Tim Murray ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e); 144621fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 144775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 144875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported Element types are U8_4. 144975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 145075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element 145175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new ScriptIntrinsicBlend 145275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 145321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray static sp<ScriptIntrinsicBlend> create(sp<RS> rs, sp<const Element> e); 145475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 145575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * sets dst = {0, 0, 0, 0} 145675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 145775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 145875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 145975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachClear(sp<Allocation> in, sp<Allocation> out); 146075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 146175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = src 146275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 146375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 146475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 146575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachSrc(sp<Allocation> in, sp<Allocation> out); 146675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 146775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = dst (NOP) 146875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 146975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 147075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 147175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachDst(sp<Allocation> in, sp<Allocation> out); 147275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 147375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = src + dst * (1.0 - src.a) 147475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 147575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 147675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 147775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachSrcOver(sp<Allocation> in, sp<Allocation> out); 147875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 147975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = dst + src * (1.0 - dst.a) 148075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 148175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 148275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 148375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachDstOver(sp<Allocation> in, sp<Allocation> out); 148475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 148575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = src * dst.a 148675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 148775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 148875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 148975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachSrcIn(sp<Allocation> in, sp<Allocation> out); 149075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 149175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = dst * src.a 149275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 149375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 149475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 149575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachDstIn(sp<Allocation> in, sp<Allocation> out); 149675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 149775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = src * (1.0 - dst.a) 149875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 149975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 150075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 150175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachSrcOut(sp<Allocation> in, sp<Allocation> out); 150275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 150375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = dst * (1.0 - src.a) 150475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 150575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 150675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 150775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachDstOut(sp<Allocation> in, sp<Allocation> out); 150875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 150975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb 151075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 151175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 151275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 151375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachSrcAtop(sp<Allocation> in, sp<Allocation> out); 151475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 151575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst.rgb = dst.rgb * src.a + (1.0 - dst.a) * src.rgb 151675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 151775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 151875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 151975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachDstAtop(sp<Allocation> in, sp<Allocation> out); 152075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 152175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a} 152275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 152375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 152475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 152575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachXor(sp<Allocation> in, sp<Allocation> out); 152675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 152775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = src * dst 152875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 152975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 153075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 153175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachMultiply(sp<Allocation> in, sp<Allocation> out); 153275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 153375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = min(src + dst, 1.0) 153475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 153575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 153675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 153775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachAdd(sp<Allocation> in, sp<Allocation> out); 153875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 153975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets dst = max(dst - src, 0.0) 154075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 154175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 154275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 154375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray void forEachSubtract(sp<Allocation> in, sp<Allocation> out); 15447f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray}; 154584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 154675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 154775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic Gausian blur filter. Applies a Gaussian blur of the specified 154875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * radius to all elements of an Allocation. 154975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 15508f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murrayclass ScriptIntrinsicBlur : public ScriptIntrinsic { 155121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 155289daad6bae798779e57f252e9da4fe4e62337124Tim Murray ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e); 155321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 155475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 155575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported Element types are U8 and U8_4. 155675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 155775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element 155875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new ScriptIntrinsicBlur 155975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 156021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray static sp<ScriptIntrinsicBlur> create(sp<RS> rs, sp<const Element> e); 156175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 156275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets the input of the blur. 156375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 156475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 156521fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray void setInput(sp<Allocation> in); 156675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 156775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Runs the intrinsic. 156875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] output Allocation 156975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 157021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray void forEach(sp<Allocation> out); 157175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 157275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets the radius of the blur. The supported range is 0 < radius <= 25. 157375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] radius radius of the blur 157475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 15758f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murray void setRadius(float radius); 15768f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murray}; 15778f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murray 157875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 157975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a color matrix to allocations. This has the 158075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * same effect as loading each element and converting it to a 158175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * F32_N, multiplying the result by the 4x4 color matrix 158275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * as performed by rsMatrixMultiply() and writing it to the output 158375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * after conversion back to U8_N or F32_N. 158475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 158589daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicColorMatrix : public ScriptIntrinsic { 158621fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 158789daad6bae798779e57f252e9da4fe4e62337124Tim Murray ScriptIntrinsicColorMatrix(sp<RS> rs, sp<const Element> e); 158821fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 158975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 159075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates a new intrinsic. 159175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 159275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new ScriptIntrinsicColorMatrix 159375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1594aae73c96081c15eb63ac24f29e243b7c85ff4480Tim Murray static sp<ScriptIntrinsicColorMatrix> create(sp<RS> rs); 159575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 159675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Applies the color matrix. Supported types are U8 and F32 with 159775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * vector lengths between 1 and 4. 159875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 159975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[out] out output Allocation 160075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 160189daad6bae798779e57f252e9da4fe4e62337124Tim Murray void forEach(sp<Allocation> in, sp<Allocation> out); 160275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 160375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the value to be added after the color matrix has been 160475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * applied. The default value is {0, 0, 0, 0}. 160575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] add float[4] of values 160675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 160710913a5c37ba119bef335320d3e8be25212c05adTim Murray void setAdd(float* add); 160875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 160975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 161075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the color matrix which will be applied to each cell of the 161175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * image. The alpha channel will be copied. 161275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 161375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] m float[9] of values 161475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 161589daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setColorMatrix3(float* m); 161675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 161775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the color matrix which will be applied to each cell of the 161875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * image. 161975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 162075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] m float[16] of values 162175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 162289daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setColorMatrix4(float* m); 162375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 162475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set a color matrix to convert from RGB to luminance. The alpha 162575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * channel will be a copy. 162675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 162789daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setGreyscale(); 162875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 162975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the matrix to convert from RGB to YUV with a direct copy of 163075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * the 4th channel. 163175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 163289daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setRGBtoYUV(); 163375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 163475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the matrix to convert from YUV to RGB with a direct copy of 163575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * the 4th channel. 163675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 163789daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setYUVtoRGB(); 163889daad6bae798779e57f252e9da4fe4e62337124Tim Murray}; 163989daad6bae798779e57f252e9da4fe4e62337124Tim Murray 164075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 164175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a 3x3 convolve to an allocation. 164275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 164389daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicConvolve3x3 : public ScriptIntrinsic { 164421fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 164589daad6bae798779e57f252e9da4fe4e62337124Tim Murray ScriptIntrinsicConvolve3x3(sp<RS> rs, sp<const Element> e); 164621fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 164775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 164875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported types U8 and F32 with vector lengths between 1 and 164975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 4. The default convolution kernel is the identity. 165075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 165175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element 165275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new ScriptIntrinsicConvolve3x3 165375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 165421fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray static sp<ScriptIntrinsicConvolve3x3> create(sp<RS> rs, sp<const Element> e); 165575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 165675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets input for intrinsic. 165775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 165875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 165989daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setInput(sp<Allocation> in); 166075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 166175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Launches the intrinsic. 166275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 166375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 166489daad6bae798779e57f252e9da4fe4e62337124Tim Murray void forEach(sp<Allocation> out); 166575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 166675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets convolution kernel. 166775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] v float[9] of values 166875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 166989daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setCoefficients(float* v); 167089daad6bae798779e57f252e9da4fe4e62337124Tim Murray}; 167189daad6bae798779e57f252e9da4fe4e62337124Tim Murray 167275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 167375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a 5x5 convolve to an allocation. 167475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 167589daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicConvolve5x5 : public ScriptIntrinsic { 167621fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 167789daad6bae798779e57f252e9da4fe4e62337124Tim Murray ScriptIntrinsicConvolve5x5(sp<RS> rs, sp<const Element> e); 167821fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 167975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 168075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported types U8 and F32 with vector lengths between 1 and 168175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 4. The default convolution kernel is the identity. 168275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 168375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element 168475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return new ScriptIntrinsicConvolve5x5 168575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 168621fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray static sp<ScriptIntrinsicConvolve5x5> create(sp<RS> rs, sp<const Element> e); 168775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 168875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets input for intrinsic. 168975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] in input Allocation 169075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 169189daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setInput(sp<Allocation> in); 169275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 169375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Launches the intrinsic. 169475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] out output Allocation 169575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 169689daad6bae798779e57f252e9da4fe4e62337124Tim Murray void forEach(sp<Allocation> out); 169775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 169875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets convolution kernel. 169975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] v float[25] of values 170075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 170189daad6bae798779e57f252e9da4fe4e62337124Tim Murray void setCoefficients(float* v); 170289daad6bae798779e57f252e9da4fe4e62337124Tim Murray}; 170389daad6bae798779e57f252e9da4fe4e62337124Tim Murray 170475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 170575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for computing a histogram. 170675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1707b27b18130d0772203799ba0f2d27783b640dc891Tim Murrayclass ScriptIntrinsicHistogram : public ScriptIntrinsic { 170821fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 1709b27b18130d0772203799ba0f2d27783b640dc891Tim Murray ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e); 171010913a5c37ba119bef335320d3e8be25212c05adTim Murray sp<Allocation> mOut; 171121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 171275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 171375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Create an intrinsic for calculating the histogram of an uchar 171475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * or uchar4 image. 171575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 171675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported elements types are U8_4, U8_3, U8_2, and U8. 171775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 171875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs The RenderScript context 171975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element type for inputs 172075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 172175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return ScriptIntrinsicHistogram 172275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 172310913a5c37ba119bef335320d3e8be25212c05adTim Murray static sp<ScriptIntrinsicHistogram> create(sp<RS> rs); 172475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 172575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the output of the histogram. 32 bit integer types are 172675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * supported. 172775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 172875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] aout The output allocation 172975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1730b27b18130d0772203799ba0f2d27783b640dc891Tim Murray void setOutput(sp<Allocation> aout); 173175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 173275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the coefficients used for the dot product calculation. The 173375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * default is {0.299f, 0.587f, 0.114f, 0.f}. 173475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 173575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Coefficients must be >= 0 and sum to 1.0 or less. 173675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 173775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] r Red coefficient 173875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] g Green coefficient 173975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] b Blue coefficient 174075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] a Alpha coefficient 174175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1742b27b18130d0772203799ba0f2d27783b640dc891Tim Murray void setDotCoefficients(float r, float g, float b, float a); 174375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 174475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Process an input buffer and place the histogram into the output 174575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * allocation. The output allocation may be a narrower vector size 174675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * than the input. In this case the vector size of the output is 174775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * used to determine how many of the input channels are used in 174875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * the computation. This is useful if you have an RGBA input 174975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * buffer but only want the histogram for RGB. 175075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 175175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 1D and 2D input allocations are supported. 175275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 175375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] ain The input image 175475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1755b27b18130d0772203799ba0f2d27783b640dc891Tim Murray void forEach(sp<Allocation> ain); 175675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 175775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Process an input buffer and place the histogram into the output 175875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * allocation. The dot product of the input channel and the 175975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * coefficients from 'setDotCoefficients' are used to calculate 176075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * the output values. 176175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 176275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 1D and 2D input allocations are supported. 176375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 176475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param ain The input image 176575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1766b27b18130d0772203799ba0f2d27783b640dc891Tim Murray void forEach_dot(sp<Allocation> ain); 1767b27b18130d0772203799ba0f2d27783b640dc891Tim Murray}; 1768b27b18130d0772203799ba0f2d27783b640dc891Tim Murray 176975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 177075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a per-channel lookup table. Each channel of 177175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * the input has an independant lookup table. The tables are 256 177275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * entries in size and can cover the full value range of U8_4. 177375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray **/ 1774b27b18130d0772203799ba0f2d27783b640dc891Tim Murrayclass ScriptIntrinsicLUT : public ScriptIntrinsic { 1775b27b18130d0772203799ba0f2d27783b640dc891Tim Murray private: 1776b27b18130d0772203799ba0f2d27783b640dc891Tim Murray sp<Allocation> LUT; 1777b27b18130d0772203799ba0f2d27783b640dc891Tim Murray bool mDirty; 1778b27b18130d0772203799ba0f2d27783b640dc891Tim Murray unsigned char mCache[1024]; 17792acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray void setTable(unsigned int offset, unsigned char base, unsigned int length, unsigned char* lutValues); 178021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray ScriptIntrinsicLUT(sp<RS> rs, sp<const Element> e); 1781b27b18130d0772203799ba0f2d27783b640dc891Tim Murray 178289daad6bae798779e57f252e9da4fe4e62337124Tim Murray public: 178375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 178475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported elements types are U8_4. 178575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 178675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The defaults tables are identity. 178775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 178875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs The RenderScript context 178975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element type for intputs and outputs 179075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 179175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return ScriptIntrinsicLUT 179275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 179321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray static sp<ScriptIntrinsicLUT> create(sp<RS> rs, sp<const Element> e); 179475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 179575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Invoke the kernel and apply the lookup to each cell of ain and 179675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * copy to aout. 179775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 179875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] ain Input allocation 179975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] aout Output allocation 180075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 180189daad6bae798779e57f252e9da4fe4e62337124Tim Murray void forEach(sp<Allocation> ain, sp<Allocation> aout); 180275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 180375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets entries in LUT for the red channel. 180475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] base base of region to update 180575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] length length of region to update 180675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] lutValues LUT values to use 180775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 18082acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray void setRed(unsigned char base, unsigned int length, unsigned char* lutValues); 180975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 181075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets entries in LUT for the green channel. 181175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] base base of region to update 181275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] length length of region to update 181375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] lutValues LUT values to use 181475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 18152acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray void setGreen(unsigned char base, unsigned int length, unsigned char* lutValues); 181675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 181775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets entries in LUT for the blue channel. 181875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] base base of region to update 181975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] length length of region to update 182075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] lutValues LUT values to use 182175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 18222acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray void setBlue(unsigned char base, unsigned int length, unsigned char* lutValues); 182375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 182475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sets entries in LUT for the alpha channel. 182575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] base base of region to update 182675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] length length of region to update 182775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] lutValues LUT values to use 182875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 18292acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray void setAlpha(unsigned char base, unsigned int length, unsigned char* lutValues); 1830b27b18130d0772203799ba0f2d27783b640dc891Tim Murray virtual ~ScriptIntrinsicLUT(); 1831b27b18130d0772203799ba0f2d27783b640dc891Tim Murray}; 1832b27b18130d0772203799ba0f2d27783b640dc891Tim Murray 183375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 183475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for converting an Android YUV buffer to RGB. 183575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 183675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The input allocation should be supplied in a supported YUV format 183775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * as a YUV element Allocation. The output is RGBA; the alpha channel 183875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * will be set to 255. 183975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 184089daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicYuvToRGB : public ScriptIntrinsic { 184121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private: 1842b27b18130d0772203799ba0f2d27783b640dc891Tim Murray ScriptIntrinsicYuvToRGB(sp<RS> rs, sp<const Element> e); 184321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public: 184475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 184575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Create an intrinsic for converting YUV to RGB. 184675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 184775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Supported elements types are U8_4. 184875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 184975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs The RenderScript context 185075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] e Element type for output 185175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 185275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return ScriptIntrinsicYuvToRGB 185375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 185421fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray static sp<ScriptIntrinsicYuvToRGB> create(sp<RS> rs, sp<const Element> e); 185575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 185675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Set the input YUV allocation. 185775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 185875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] ain The input allocation. 185975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1860b27b18130d0772203799ba0f2d27783b640dc891Tim Murray void setInput(sp<Allocation> in); 186175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray 186275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 186375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Convert the image to RGB. 186475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 186575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] aout Output allocation. Must match creation element 186675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * type. 186775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1868b27b18130d0772203799ba0f2d27783b640dc891Tim Murray void forEach(sp<Allocation> out); 186989daad6bae798779e57f252e9da4fe4e62337124Tim Murray 187089daad6bae798779e57f252e9da4fe4e62337124Tim Murray}; 1871b27b18130d0772203799ba0f2d27783b640dc891Tim Murray 187275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/** 187375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sampler object that defines how Allocations can be read as textures 187475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * within a kernel. Samplers are used in conjunction with the rsSample 187575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * runtime function to return values from normalized coordinates. 187675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 187775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Any Allocation used with a Sampler must have been created with 187875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; using a Sampler on an 187975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Allocation that was not created with 188075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE is undefined. 188175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray **/ 1882729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray class Sampler : public BaseObj { 1883729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray private: 1884729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray Sampler(sp<RS> rs, void* id); 1885729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue mMin; 1886729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue mMag; 1887729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue mWrapS; 1888729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue mWrapT; 1889729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue mWrapR; 1890729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray float mAniso; 1891729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray 1892729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray public: 189375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 189475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Creates a non-standard Sampler. 189575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] rs RenderScript context 189675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] min minification 189775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] mag magnification 189875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] wrapS S wrapping mode 189975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] wrapT T wrapping mode 190075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param[in] anisotropy anisotropy setting 190175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1902729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray static sp<Sampler> create(sp<RS> rs, RsSamplerValue min, RsSamplerValue mag, RsSamplerValue wrapS, RsSamplerValue wrapT, float anisotropy); 1903729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray 190475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 190575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return minification setting for the sampler 190675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1907729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue getMinification(); 190875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 190975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return magnification setting for the sampler 191075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1911729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue getMagnification(); 191275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 191375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return S wrapping mode for the sampler 191475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1915729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue getWrapS(); 191675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 191775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return T wrapping mode for the sampler 191875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1919729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray RsSamplerValue getWrapT(); 192075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 192175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return anisotropy setting for the sampler 192275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 1923729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray float getAnisotropy(); 1924729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray 192575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 192675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with min and mag set to nearest and wrap modes set to 192775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * clamp. 192875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 192975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 193075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 193175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 193275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19338a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> CLAMP_NEAREST(sp<RS> rs); 193475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 193575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with min and mag set to linear and wrap modes set to 193675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * clamp. 193775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 193875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 193975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 194075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 194175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19428a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> CLAMP_LINEAR(sp<RS> rs); 194375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 194475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with mag set to linear, min linear mipmap linear, and 194575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * wrap modes set to clamp. 194675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 194775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 194875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 194975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 195075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19518a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR(sp<RS> rs); 195275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 195375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with min and mag set to nearest and wrap modes set to 195475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * wrap. 195575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 195675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 195775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 195875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 195975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19608a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> WRAP_NEAREST(sp<RS> rs); 196175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 196275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with min and mag set to linear and wrap modes set to 196375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * wrap. 196475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 196575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 196675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 196775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 196875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19698a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> WRAP_LINEAR(sp<RS> rs); 197075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 197175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with mag set to linear, min linear mipmap linear, and 197275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * wrap modes set to wrap. 197375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 197475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 197575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 197675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 197775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19788a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> WRAP_LINEAR_MIP_LINEAR(sp<RS> rs); 197975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 198075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with min and mag set to nearest and wrap modes set to 198175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * mirrored repeat. 198275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 198375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 198475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 198575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 198675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19878a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> MIRRORED_REPEAT_NEAREST(sp<RS> rs); 198875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 198975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with min and mag set to linear and wrap modes set to 199075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * mirrored repeat. 199175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 199275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 199375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 199475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 199575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 19968a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> MIRRORED_REPEAT_LINEAR(sp<RS> rs); 199775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /** 199875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Retrieve a sampler with min and mag set to linear and wrap modes set to 199975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * mirrored repeat. 200075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 200175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @param rs Context to which the sampler will belong. 200275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * 200375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * @return Sampler 200475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */ 20058a588bd9d34088ed89ef2c192c32ea2301e601bcStephen Hines static sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR(sp<RS> rs); 2006729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray 2007729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray}; 2008729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray 2009d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Byte2 { 2010d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2011d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int8_t x, y; 2012d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2013d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Byte2(int8_t initX, int8_t initY) 2014d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2015d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Byte2() : x(0), y(0) {} 2016d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2017d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2018d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Byte3 { 2019d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2020d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int8_t x, y, z; 2021d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2022d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Byte3(int8_t initX, int8_t initY, int8_t initZ) 2023d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2024d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Byte3() : x(0), y(0), z(0) {} 2025d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2026d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2027d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Byte4 { 2028d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2029d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int8_t x, y, z, w; 2030d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2031d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Byte4(int8_t initX, int8_t initY, int8_t initZ, int8_t initW) 2032d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2033d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Byte4() : x(0), y(0), z(0), w(0) {} 2034d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2035d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2036d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UByte2 { 2037d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2038d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint8_t x, y; 2039d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2040d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UByte2(uint8_t initX, uint8_t initY) 2041d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2042d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UByte2() : x(0), y(0) {} 2043d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2044d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2045d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UByte3 { 2046d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2047d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint8_t x, y, z; 2048d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2049d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UByte3(uint8_t initX, uint8_t initY, uint8_t initZ) 2050d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2051d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UByte3() : x(0), y(0), z(0) {} 2052d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2053d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2054d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UByte4 { 2055d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2056d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint8_t x, y, z, w; 2057d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2058d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UByte4(uint8_t initX, uint8_t initY, uint8_t initZ, uint8_t initW) 2059d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2060d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UByte4() : x(0), y(0), z(0), w(0) {} 2061d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2062d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2063d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Short2 { 2064d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2065d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines short x, y; 2066d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2067d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Short2(short initX, short initY) 2068d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2069d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Short2() : x(0), y(0) {} 2070d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2071d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2072d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Short3 { 2073d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2074d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines short x, y, z; 2075d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2076d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Short3(short initX, short initY, short initZ) 2077d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2078d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Short3() : x(0), y(0), z(0) {} 2079d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2080d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2081d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Short4 { 2082d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2083d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines short x, y, z, w; 2084d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2085d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Short4(short initX, short initY, short initZ, short initW) 2086d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2087d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Short4() : x(0), y(0), z(0), w(0) {} 2088d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2089d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2090d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UShort2 { 2091d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2092d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint16_t x, y; 2093d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2094d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UShort2(uint16_t initX, uint16_t initY) 2095d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2096d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UShort2() : x(0), y(0) {} 2097d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2098d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2099d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UShort3 { 2100d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2101d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint16_t x, y, z; 2102d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2103d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UShort3(uint16_t initX, uint16_t initY, uint16_t initZ) 2104d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2105d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UShort3() : x(0), y(0), z(0) {} 2106d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2107d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2108d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UShort4 { 2109d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2110d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint16_t x, y, z, w; 2111d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2112d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UShort4(uint16_t initX, uint16_t initY, uint16_t initZ, uint16_t initW) 2113d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2114d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UShort4() : x(0), y(0), z(0), w(0) {} 2115d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2116d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2117d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Int2 { 2118d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2119d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int x, y; 2120d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2121d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Int2(int initX, int initY) 2122d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2123d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Int2() : x(0), y(0) {} 2124d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2125d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2126d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Int3 { 2127d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2128d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int x, y, z; 2129d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2130d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Int3(int initX, int initY, int initZ) 2131d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2132d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Int3() : x(0), y(0), z(0) {} 2133d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2134d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2135d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Int4 { 2136d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2137d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int x, y, z, w; 2138d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2139d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Int4(int initX, int initY, int initZ, int initW) 2140d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2141d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Int4() : x(0), y(0), z(0), w(0) {} 2142d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2143d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2144d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UInt2 { 2145d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2146d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint32_t x, y; 2147d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2148d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UInt2(uint32_t initX, uint32_t initY) 2149d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2150d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UInt2() : x(0), y(0) {} 2151d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2152d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2153d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UInt3 { 2154d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2155d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint32_t x, y, z; 2156d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2157d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UInt3(uint32_t initX, uint32_t initY, uint32_t initZ) 2158d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2159d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UInt3() : x(0), y(0), z(0) {} 2160d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2161d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2162d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UInt4 { 2163d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2164d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint32_t x, y, z, w; 2165d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2166d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UInt4(uint32_t initX, uint32_t initY, uint32_t initZ, uint32_t initW) 2167d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2168d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines UInt4() : x(0), y(0), z(0), w(0) {} 2169d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2170d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2171d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Long2 { 2172d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2173d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int64_t x, y; 2174d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2175d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Long2(int64_t initX, int64_t initY) 2176d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2177d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Long2() : x(0), y(0) {} 2178d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2179d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2180d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Long3 { 2181d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2182d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int64_t x, y, z; 2183d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2184d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Long3(int64_t initX, int64_t initY, int64_t initZ) 2185d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2186d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Long3() : x(0), y(0), z(0) {} 2187d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2188d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2189d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Long4 { 2190d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2191d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines int64_t x, y, z, w; 2192d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2193d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Long4(int64_t initX, int64_t initY, int64_t initZ, int64_t initW) 2194d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2195d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Long4() : x(0), y(0), z(0), w(0) {} 2196d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2197d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2198d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass ULong2 { 2199d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2200d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint64_t x, y; 2201d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2202d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines ULong2(uint64_t initX, uint64_t initY) 2203d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2204d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines ULong2() : x(0), y(0) {} 2205d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2206d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2207d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass ULong3 { 2208d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2209d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint64_t x, y, z; 2210d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2211d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines ULong3(uint64_t initX, uint64_t initY, uint64_t initZ) 2212d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2213d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines ULong3() : x(0), y(0), z(0) {} 2214d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2215d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2216d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass ULong4 { 2217d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2218d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines uint64_t x, y, z, w; 2219d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2220d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines ULong4(uint64_t initX, uint64_t initY, uint64_t initZ, uint64_t initW) 2221d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2222d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines ULong4() : x(0), y(0), z(0), w(0) {} 2223d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2224d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2225d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Float2 { 2226d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2227d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines float x, y; 2228d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2229d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Float2(float initX, float initY) 2230d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2231d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Float2() : x(0), y(0) {} 2232d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2233d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2234d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Float3 { 2235d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2236d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines float x, y, z; 2237d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2238d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Float3(float initX, float initY, float initZ) 2239d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2240d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Float3() : x(0.f), y(0.f), z(0.f) {} 2241d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2242d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2243d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Float4 { 2244d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2245d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines float x, y, z, w; 2246d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2247d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Float4(float initX, float initY, float initZ, float initW) 2248d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2249d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Float4() : x(0.f), y(0.f), z(0.f), w(0.f) {} 2250d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2251d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2252d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Double2 { 2253d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2254d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines double x, y; 2255d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2256d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Double2(double initX, double initY) 2257d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY) {} 2258d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Double2() : x(0), y(0) {} 2259d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2260d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2261d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Double3 { 2262d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2263d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines double x, y, z; 2264d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2265d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Double3(double initX, double initY, double initZ) 2266d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ) {} 2267d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Double3() : x(0), y(0), z(0) {} 2268d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2269d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2270d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Double4 { 2271d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public: 2272d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines double x, y, z, w; 2273d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 2274d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Double4(double initX, double initY, double initZ, double initW) 2275d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines : x(initX), y(initY), z(initZ), w(initW) {} 2276d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines Double4() : x(0), y(0), z(0), w(0) {} 2277d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines}; 2278d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines 227984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray} 22807f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray 228184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray} 228284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray 228384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray#endif 2284