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>
2689daad6bae798779e57f252e9da4fe4e62337124Tim Murray
2775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
2875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Every row in an RS allocation is guaranteed to be aligned by this amount, and
2975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * every row in a user-backed allocation must be aligned by this amount.
3075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
3196267c2ff0133c20cc5643419a3ed3b1e75fe568Tim Murray#define RS_CPU_ALLOCATION_ALIGNMENT 16
3296267c2ff0133c20cc5643419a3ed3b1e75fe568Tim Murray
3384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraynamespace android {
349eb7f4b90120ebe4be74343856e86b46495f72dfTim Murraynamespace RSC {
3584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
3684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraytypedef void (*ErrorHandlerFunc_t)(uint32_t errorNum, const char *errorText);
3784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraytypedef void (*MessageHandlerFunc_t)(uint32_t msgNum, const void *msgData, size_t msgLen);
3884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
3984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass RS;
4084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass BaseObj;
4184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Element;
4284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Type;
4384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Allocation;
4484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Script;
4584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass ScriptC;
46729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murrayclass Sampler;
4784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
4875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
4975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Possible error codes used by RenderScript. Once a status other than RS_SUCCESS
5075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * is returned, the RenderScript context is considered dead and cannot perform any
5175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * additional work.
5275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
5321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray enum RSError {
5475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_SUCCESS = 0,                 ///< No error
5575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_ERROR_INVALID_PARAMETER = 1, ///< An invalid parameter was passed to a function
5675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_ERROR_RUNTIME_ERROR = 2,     ///< The RenderScript driver returned an error; this is
5775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray                                     ///< often indicative of a kernel that crashed
5875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_ERROR_INVALID_ELEMENT = 3,   ///< An invalid Element was passed to a function
5921fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray     RS_ERROR_MAX = 9999
6021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray
6121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray };
6221fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray
6375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /**
6475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * YUV formats supported by the RenderScript API.
6575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  */
66eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray enum RSYuvFormat {
6775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_YUV_NONE = 0, ///< No YUV data
6875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_YUV_YV12 = 1, ///< YUV data in YV12 format
6975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_YUV_NV21 = 2, ///< YUV data in NV21 format
70eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray     RS_YUV_MAX = 3
71eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray };
72eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray
7375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /**
7475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Flags that can control RenderScript behavior on a per-context level.
7575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  */
7684e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray enum RSInitFlags {
7775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_INIT_SYNCHRONOUS = 1, ///< All RenderScript calls will be synchronous. May reduce latency.
7875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     RS_INIT_LOW_LATENCY = 2, ///< Prefer low latency devices over potentially higher throughput devices.
7984e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray     RS_INIT_MAX = 4
8084e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray };
8184e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray
8275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /**
8375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * The RenderScript context. This class controls initialization, resource management, and teardown.
8475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  */
8589daad6bae798779e57f252e9da4fe4e62337124Tim Murray class RS : public android::RSC::LightRefBase<RS> {
8684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
8784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray public:
8884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RS();
8984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    virtual ~RS();
9084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
9175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
9275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Initializes a RenderScript context. A context must be initialized before it can be used.
9375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] flags Optional flags for this context.
9475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return true on success
9575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
964c4bec1fa216cc2b90625cab01ef678c242c38d1Tim Murray    bool init(uint32_t flags = 0);
9784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
9875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
9975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets the error handler function for this context. This error handler is
10075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * called whenever an error is set.
10175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
10275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] func Error handler function
10375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
10484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setErrorHandler(ErrorHandlerFunc_t func);
10575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
10675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
10775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the current error handler function for this context.
10875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
10975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return pointer to current error handler function or NULL if not set
11075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
11184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; }
11284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
11375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
11475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets the message handler function for this context. This message handler
11575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * is called whenever a message is sent from a RenderScript kernel.
11675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
11775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *  @param[in] func Message handler function
11875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
11984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setMessageHandler(MessageHandlerFunc_t func);
12075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
12175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
12275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the current message handler function for this context.
12375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
12475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return pointer to current message handler function or NULL if not set
12575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
12684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    MessageHandlerFunc_t getMessageHandler() { return mMessageFunc; }
12784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
12875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
12975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns current status for the context.
13075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
13175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return current error
13275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
13310913a5c37ba119bef335320d3e8be25212c05adTim Murray    RSError getError();
13484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
13575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
13675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Waits for any currently running asynchronous operations to finish. This
13775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * should only be used for performance testing and timing.
13875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
139baca6c3c3d79a324c7976ba873afdded0b6bcfb5Tim Murray    void finish();
140baca6c3c3d79a324c7976ba873afdded0b6bcfb5Tim Murray
14175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    RsContext getContext() { return mContext; }
14275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void throwError(RSError error, const char *errMsg);
14375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
144a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray    static dispatchTable* dispatch;
145a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray
14684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray private:
1474a92d1268983edaf329f73c8a5b8860cdbb11596Tim Murray    static bool usingNative;
148a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray    static bool initDispatch(int targetApi);
149a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray
15084e3dea053bea25c1cec44ffb298f8b5b9b9141aTim Murray    bool init(int targetApi, uint32_t flags);
15184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static void * threadProc(void *);
15284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
15384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static bool gInitialized;
15484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static pthread_mutex_t gInitMutex;
15584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
15684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    pthread_t mMessageThreadId;
15784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    pid_t mNativeMessageThreadId;
15884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mMessageRun;
15984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
16084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RsDevice mDev;
16184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RsContext mContext;
16221fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    RSError mCurrentError;
16384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
16484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    ErrorHandlerFunc_t mErrorFunc;
16584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    MessageHandlerFunc_t mMessageFunc;
166a423096c0d49e5cfe13a400b4323a76f89c6885cTim Murray    bool mInit;
16784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
16884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    struct {
16989daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> U8;
170eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U8_2;
171eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U8_3;
172eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U8_4;
17389daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> I8;
174eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I8_2;
175eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I8_3;
176eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I8_4;
17789daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> U16;
178eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U16_2;
179eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U16_3;
180eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U16_4;
18189daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> I16;
182eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I16_2;
183eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I16_3;
184eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I16_4;
18589daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> U32;
186eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U32_2;
187eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U32_3;
188eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U32_4;
18989daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> I32;
190eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I32_2;
191eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I32_3;
192eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I32_4;
19389daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> U64;
194eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U64_2;
195eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U64_3;
196eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> U64_4;
19789daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> I64;
198eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I64_2;
199eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I64_3;
200eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> I64_4;
20189daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> F32;
202eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> F32_2;
203eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> F32_3;
204eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> F32_4;
20589daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> F64;
206eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> F64_2;
207eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> F64_3;
208eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> F64_4;
20989daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> BOOLEAN;
21089daad6bae798779e57f252e9da4fe4e62337124Tim Murray
21189daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> ELEMENT;
21289daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> TYPE;
21389daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> ALLOCATION;
21489daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> SAMPLER;
21589daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> SCRIPT;
21689daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> MESH;
21789daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> PROGRAM_FRAGMENT;
21889daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> PROGRAM_VERTEX;
21989daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> PROGRAM_RASTER;
22089daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> PROGRAM_STORE;
22189daad6bae798779e57f252e9da4fe4e62337124Tim Murray
22289daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> A_8;
22389daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> RGB_565;
22489daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> RGB_888;
22589daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> RGBA_5551;
22689daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> RGBA_4444;
22789daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> RGBA_8888;
22889daad6bae798779e57f252e9da4fe4e62337124Tim Murray
229eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        sp<const Element> YUV;
23089daad6bae798779e57f252e9da4fe4e62337124Tim Murray
23189daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> MATRIX_4X4;
23289daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> MATRIX_3X3;
23389daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Element> MATRIX_2X2;
23484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    } mElements;
23584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
236729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    struct {
23789daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> CLAMP_NEAREST;
23889daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> CLAMP_LINEAR;
23989daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR;
24089daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> WRAP_NEAREST;
24189daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> WRAP_LINEAR;
24289daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> WRAP_LINEAR_MIP_LINEAR;
24389daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> MIRRORED_REPEAT_NEAREST;
24489daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> MIRRORED_REPEAT_LINEAR;
24589daad6bae798779e57f252e9da4fe4e62337124Tim Murray        sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
246729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    } mSamplers;
247729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    friend class Sampler;
248729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    friend class Element;
24984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray};
25084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
25175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /**
25275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Base class for all RenderScript objects. Not for direct use by developers.
25375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  */
25489daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass BaseObj : public android::RSC::LightRefBase<BaseObj> {
25589daad6bae798779e57f252e9da4fe4e62337124Tim Murraypublic:
25689daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void * getID() const;
25789daad6bae798779e57f252e9da4fe4e62337124Tim Murray    virtual ~BaseObj();
25889daad6bae798779e57f252e9da4fe4e62337124Tim Murray    virtual void updateFromNative();
25989daad6bae798779e57f252e9da4fe4e62337124Tim Murray    virtual bool equals(sp<const BaseObj> obj);
26089daad6bae798779e57f252e9da4fe4e62337124Tim Murray
26184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected:
26284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void *mID;
26384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    sp<RS> mRS;
264ab71636b50db242cead6a3787620d6340156684cTim Murray    std::string mName;
26584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
26684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    BaseObj(void *id, sp<RS> rs);
26784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void checkValid();
26884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
26984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static void * getObjID(sp<const BaseObj> o);
27084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
27184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray};
27284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
27375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /**
27475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * This class provides the primary method through which data is passed to and
27575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * from RenderScript kernels. An Allocation provides the backing store for a
27675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * given Type.
27775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  *
27875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * An Allocation also contains a set of usage flags that denote how the
27975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Allocation could be used. For example, an Allocation may have usage flags
28075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * specifying that it can be used from a script as well as input to a
28175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Sampler. A developer must synchronize across these different usages using
28275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * syncAll(int) in order to ensure that different users of the Allocation have
28375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * a consistent view of memory. For example, in the case where an Allocation is
28475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * used as the output of one kernel and as Sampler input in a later kernel, a
28575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * developer must call syncAll(RS_ALLOCATION_USAGE_SCRIPT) prior to launching the
28675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * second kernel to ensure correctness.
28775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  */
28884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Allocation : public BaseObj {
28984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected:
29089daad6bae798779e57f252e9da4fe4e62337124Tim Murray    sp<const Type> mType;
29184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mUsage;
29289daad6bae798779e57f252e9da4fe4e62337124Tim Murray    sp<Allocation> mAdaptedAllocation;
29384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
29484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mConstrainedLOD;
29584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mConstrainedFace;
29684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mConstrainedY;
29784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mConstrainedZ;
29884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mReadAllowed;
29984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mWriteAllowed;
30084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mSelectedY;
30184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mSelectedZ;
30284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mSelectedLOD;
30384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RsAllocationCubemapFace mSelectedFace;
30484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
30584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mCurrentDimX;
30684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mCurrentDimY;
30784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mCurrentDimZ;
30884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mCurrentCount;
30984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
31084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void * getIDSafe() const;
31184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void updateCacheInfo(sp<const Type> t);
31284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
31384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    Allocation(void *id, sp<RS> rs, sp<const Type> t, uint32_t usage);
31484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
31584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void validateIsInt32();
31684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void validateIsInt16();
31784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void validateIsInt8();
31884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void validateIsFloat32();
31984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void validateIsObject();
32084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
32184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    virtual void updateFromNative();
32284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
32384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h);
3249d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray    void validate3DRange(uint32_t xoff, uint32_t yoff, uint32_t zoff,
3259d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray                         uint32_t w, uint32_t h, uint32_t d);
32684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
32784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic:
32875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
32975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
33075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Return Type for the allocation.
33175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return pointer to underlying Type
33275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
333a180b7d58ac6da9d6da866e43aa8c1fa83923dc5Stephen Hines    sp<const Type> getType() const {
33484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mType;
33584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
33684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
33775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
33875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Propagate changes from one usage of the Allocation to other usages of the Allocation.
33975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] srcLocation source location with changes to propagate elsewhere
34075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
34184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void syncAll(RsAllocationUsageType srcLocation);
34284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void ioSendOutput();
34384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void ioGetInput();
34484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
34575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
34675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Generate a mipmap chain. This is only valid if the Type of the Allocation
34775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * includes mipmaps. This function will generate a complete set of mipmaps
34875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * from the top level LOD and place them into the script memory space. If
34975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * the Allocation is also using other memory spaces, a call to
35075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * syncAll(Allocation.USAGE_SCRIPT) is required.
35175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
35284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void generateMipmaps();
353509ea5c832a865bc9083d53f1f058377a689bab3Tim Murray
35475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
35575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy an array into part of this Allocation.
35675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] off offset of first Element to be overwritten
35775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] count number of Elements to copy
35875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data array from which to copy
35975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
3600b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray    void copy1DRangeFrom(uint32_t off, size_t count, const void *data);
36175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
36275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
36375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy part of an Allocation into part of this Allocation.
36475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] off offset of first Element to be overwritten
36575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] count number of Elements to copy
36675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data Allocation from which to copy
36775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dataOff offset of first Element in data to copy
36875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
369a4cbc2b0cf0f6fbdb21e84a3e17585eda1885e3eTim Murray    void copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, uint32_t dataOff);
37084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
37175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
37275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy an array into part of this Allocation.
37375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] off offset of first Element to be overwritten
37475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] count number of Elements to copy
37575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data array from which to copy
37675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
3770b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray    void copy1DRangeTo(uint32_t off, size_t count, void *data);
378a4cbc2b0cf0f6fbdb21e84a3e17585eda1885e3eTim Murray
37975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
38075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy entire array to an Allocation.
38175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data array from which to copy
38275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
3830b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray    void copy1DFrom(const void* data);
38475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
38575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
38675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy entire Allocation to an array.
38775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data destination array
38875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
3890b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray    void copy1DTo(void* data);
3900b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray
39175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
39275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from an array into a rectangular region in this Allocation. The
39375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * array is assumed to be tightly packed.
39475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] xoff X offset of region to update in this Allocation
39575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] yoff Y offset of region to update in this Allocation
39675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] w Width of region to update
39775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] h Height of region to update
39875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data Array from which to copy
39975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
4000b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray    void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
4010b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray                         const void *data);
4027b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray
40375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
40475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from this Allocation into a rectangular region in an array. The
40575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * array is assumed to be tightly packed.
40675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] xoff X offset of region to copy from this Allocation
40775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] yoff Y offset of region to copy from this Allocation
40875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] w Width of region to update
40975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] h Height of region to update
41075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data destination array
41175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
4127b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray    void copy2DRangeTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
4137b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray                       void *data);
4147b3e3093f745134345dadf89498ad16e1f9c0e71Tim Murray
41575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
41675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from an Allocation into a rectangular region in this Allocation.
41775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] xoff X offset of region to update in this Allocation
41875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] yoff Y offset of region to update in this Allocation
41975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] w Width of region to update
42075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] h Height of region to update
42175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data Allocation from which to copy
42275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dataXoff X offset of region to copy from in data
42375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dataYoff Y offset of region to copy from in data
42475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
42584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
4260b93e30c8c64fb2f985218adfaceff777f62a42fTim Murray                         sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff);
42784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
42875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
42975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from a strided array into a rectangular region in this Allocation.
43075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] xoff X offset of region to update in this Allocation
43175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] yoff Y offset of region to update in this Allocation
43275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] w Width of region to update
43375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] h Height of region to update
43475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data array from which to copy
43575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] stride stride of data in bytes
43675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
437358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray    void copy2DStridedFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
438358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray                           const void *data, size_t stride);
43975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
44075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
44175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from a strided array into this Allocation.
44275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data array from which to copy
44375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] stride stride of data in bytes
44475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
445358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray    void copy2DStridedFrom(const void *data, size_t stride);
446358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray
44775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
44875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from a rectangular region in this Allocation into a strided array.
44975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] xoff X offset of region to update in this Allocation
45075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] yoff Y offset of region to update in this Allocation
45175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] w Width of region to update
45275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] h Height of region to update
45375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data destination array
45475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] stride stride of data in bytes
45575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
456358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray    void copy2DStridedTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
457358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray                         void *data, size_t stride);
45875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
45975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
46075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy this Allocation into a strided array.
46175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data destination array
46275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] stride stride of data in bytes
46375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
464358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray    void copy2DStridedTo(void *data, size_t stride);
465358747a3118301c5faeee73c98dd5f839bbfb54aTim Murray
46675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
46775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
46875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from an array into a 3D region in this Allocation. The
46975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * array is assumed to be tightly packed.
47075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] xoff X offset of region to update in this Allocation
47175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] yoff Y offset of region to update in this Allocation
47275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] zoff Z offset of region to update in this Allocation
47375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] w Width of region to update
47475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] h Height of region to update
47575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] d Depth of region to update
47675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data Array from which to copy
47775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
4789d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray    void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w,
4799d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray                         uint32_t h, uint32_t d, const void* data);
4809d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray
48175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
48275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Copy from an Allocation into a 3D region in this Allocation.
48375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] xoff X offset of region to update in this Allocation
48475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] yoff Y offset of region to update in this Allocation
48575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] zoff Z offset of region to update in this Allocation
48675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] w Width of region to update
48775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] h Height of region to update
48875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] d Depth of region to update
48975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] data Allocation from which to copy
49075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dataXoff X offset of region in data to copy from
49175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dataYoff Y offset of region in data to copy from
49275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dataZoff Z offset of region in data to copy from
49375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
4949d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray    void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff,
4959d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray                         uint32_t w, uint32_t h, uint32_t d,
4969d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray                         sp<const Allocation> data,
4979d24ae621bdfdaf09406b099a2ae055e33d1089aTim Murray                         uint32_t dataXoff, uint32_t dataYoff, uint32_t dataZoff);
49884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
49975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
50075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates an Allocation for use by scripts with a given Type.
50175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs Context to which the Allocation will belong
50275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] type Type of the Allocation
50375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] mips desired mipmap behavior for the Allocation
50475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] usage usage for the Allocation
50575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new Allocation
50675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
50784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
50884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray                                   RsAllocationMipmapControl mips, uint32_t usage);
50975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
51075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
51175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates an Allocation for use by scripts with a given Type and a backing pointer. For use
51275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * with RS_ALLOCATION_USAGE_SHARED.
51375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs Context to which the Allocation will belong
51475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] type Type of the Allocation
51575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] mips desired mipmap behavior for the Allocation
51675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] usage usage for the Allocation
51775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] pointer existing backing store to use for this Allocation if possible
51875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new Allocation
51975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
52084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
52184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray                                   RsAllocationMipmapControl mips, uint32_t usage, void * pointer);
52284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
52375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
52475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates an Allocation for use by scripts with a given Type with no mipmaps.
52575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs Context to which the Allocation will belong
52675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] type Type of the Allocation
52775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] usage usage for the Allocation
52875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new Allocation
52975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
53084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
53184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray                                   uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
53275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
53375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates an Allocation with a specified number of given elements.
53475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs Context to which the Allocation will belong
53575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element used in the Allocation
53675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] count Number of elements of the Allocation
53775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] usage usage for the Allocation
53875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new Allocation
53975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
54084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<Allocation> createSized(sp<RS> rs, sp<const Element> e, size_t count,
54184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray                                   uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
54275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
54375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
54475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates a 2D Allocation with a specified number of given elements.
54575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs Context to which the Allocation will belong
54675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element used in the Allocation
54775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] x Width in Elements of the Allocation
54875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] y Height of the Allocation
54975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] usage usage for the Allocation
55075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new Allocation
55175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
552684726cbbd177ee4ee9000e9422058547acd237fTim Murray    static sp<Allocation> createSized2D(sp<RS> rs, sp<const Element> e,
553684726cbbd177ee4ee9000e9422058547acd237fTim Murray                                        size_t x, size_t y,
554684726cbbd177ee4ee9000e9422058547acd237fTim Murray                                        uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
555684726cbbd177ee4ee9000e9422058547acd237fTim Murray
55684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
55784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray};
55884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
55975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray /**
56075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * An Element represents one item within an Allocation. An Element is roughly
56175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * equivalent to a C type in a RenderScript kernel. Elements may be basic
56275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * or complex. Some basic elements are:
56375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
56475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * - A single float value (equivalent to a float in a kernel)
56575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * - A four-element float vector (equivalent to a float4 in a kernel)
56675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * - An unsigned 32-bit integer (equivalent to an unsigned int in a kernel)
56775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * - A single signed 8-bit integer (equivalent to a char in a kernel)
56875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
56975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Basic Elements are comprised of a Element.DataType and a
57075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Element.DataKind. The DataType encodes C type information of an Element,
57175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * while the DataKind encodes how that Element should be interpreted by a
57275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Sampler. Note that Allocation objects with DataKind USER cannot be used as
57375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * input for a Sampler. In general, Allocation objects that are intended for
57475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * use with a Sampler should use bitmap-derived Elements such as
57575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray  * Element::RGBA_8888.
57675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
57775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
57875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
57984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Element : public BaseObj {
58084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic:
58184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool isComplex();
58275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
58375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
58475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Elements could be simple, such as an int or a float, or a structure with
58575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * multiple sub-elements, such as a collection of floats, float2,
58675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * float4. This function returns zero for simple elements or the number of
58775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * sub-elements otherwise.
58875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return number of sub-elements
58975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
59084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t getSubElementCount() {
59184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mVisibleElementMap.size();
59284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
59384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
59475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
59575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * For complex Elements, this returns the sub-element at a given index.
59675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] index index of sub-element
59775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return sub-element
59875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
59984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    sp<const Element> getSubElement(uint32_t index);
60075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
60175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
60275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * For complex Elements, this returns the name of the sub-element at a given
60375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * index.
60475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] index index of sub-element
60575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return name of sub-element
60675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
60784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    const char * getSubElementName(uint32_t index);
60875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
60975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
61075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * For complex Elements, this returns the size of the sub-element at a given
61175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * index.
61275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] index index of sub-element
61375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return size of sub-element
61475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
61584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t getSubElementArraySize(uint32_t index);
61675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
61775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
61875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the location of a sub-element within a complex Element.
61975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] index index of sub-element
62075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return offset in bytes
62175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
62284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t getSubElementOffsetBytes(uint32_t index);
62375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
62475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
62575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the data type used for the Element.
62675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return data type
62775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
62884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RsDataType getDataType() const {
62984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mType;
63084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
63184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
63275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
63375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the data kind used for the Element.
63475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return data kind
63575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
63684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RsDataKind getDataKind() const {
63784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mKind;
63884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
63984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
64075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
64175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the size in bytes of the Element.
64275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return size in bytes
64375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
64484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t getSizeBytes() const {
64584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mSizeBytes;
64684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
64784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
64875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
64975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the number of vector components for this Element.
65075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return number of vector components
65175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
65210913a5c37ba119bef335320d3e8be25212c05adTim Murray    uint32_t getVectorSize() const {
65310913a5c37ba119bef335320d3e8be25212c05adTim Murray        return mVectorSize;
65410913a5c37ba119bef335320d3e8be25212c05adTim Murray    }
65510913a5c37ba119bef335320d3e8be25212c05adTim Murray
65675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
65775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single bool.
65875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
65975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
66075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
66184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> BOOLEAN(sp<RS> rs);
66275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
66375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single unsigned char.
66475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
66575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
66675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
66784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U8(sp<RS> rs);
66875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
66975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single signed char.
67075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
67175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
67275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
67384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I8(sp<RS> rs);
67475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
67575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single unsigned short.
67675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
67775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
67875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
67984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U16(sp<RS> rs);
68075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
68175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single signed short.
68275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
68375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
68475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
68584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I16(sp<RS> rs);
68675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
68775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single unsigned int.
68875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
68975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
69075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
69184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U32(sp<RS> rs);
69275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
69375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single signed int.
69475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
69575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
69675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
69784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I32(sp<RS> rs);
69875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
69975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single unsigned long long.
70075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
70175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
70275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
70384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U64(sp<RS> rs);
70475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
70575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single signed long long.
70675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
70775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
70875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
70984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I64(sp<RS> rs);
71075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
71175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single float.
71275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
71375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
71475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
71584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F32(sp<RS> rs);
71675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
71775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single double.
71875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
71975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
72075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
72184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F64(sp<RS> rs);
72275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
72375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single Element.
72475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
72575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
72675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
72784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> ELEMENT(sp<RS> rs);
72875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
72975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single Type.
73075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
73175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
73275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
73384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> TYPE(sp<RS> rs);
73475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
73575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single Allocation.
73675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
73775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
73875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
73984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> ALLOCATION(sp<RS> rs);
74075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
74175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single Sampler.
74275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
74375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
74475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
74584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> SAMPLER(sp<RS> rs);
74675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
74775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a single Script.
74875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
74975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
75075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
75184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> SCRIPT(sp<RS> rs);
75275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
75375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an ALPHA_8 pixel.
75475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
75575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
75675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
75784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> A_8(sp<RS> rs);
75875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
75975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an RGB_565 pixel.
76075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
76175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
76275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
76384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> RGB_565(sp<RS> rs);
76475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
76575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an RGB_888 pixel.
76675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
76775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
76875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
76984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> RGB_888(sp<RS> rs);
77075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
77175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an RGBA_5551 pixel.
77275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
77375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
77475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
77584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> RGBA_5551(sp<RS> rs);
77675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
77775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an RGBA_4444 pixel.
77875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
77975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
78075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
78184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> RGBA_4444(sp<RS> rs);
78275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
78375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an RGBA_8888 pixel.
78475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
78575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
78675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
78784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> RGBA_8888(sp<RS> rs);
78884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
78975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
79075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a float2.
79175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
79275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
79375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
79484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F32_2(sp<RS> rs);
79575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
79675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a float3.
79775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
79875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
79975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
80084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F32_3(sp<RS> rs);
80175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
80275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a float4.
80375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
80475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
80575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
80684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F32_4(sp<RS> rs);
80775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
80875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a double2.
80975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
81075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
81175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
81284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F64_2(sp<RS> rs);
81375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
81475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a double3.
81575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
81675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
81775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
81884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F64_3(sp<RS> rs);
81975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
82075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a double4.
82175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
82275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
82375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
82484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> F64_4(sp<RS> rs);
82575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
82675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a uchar2.
82775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
82875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
82975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
83084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U8_2(sp<RS> rs);
83175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
83275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a uchar3.
83375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
83475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
83575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
83684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U8_3(sp<RS> rs);
83775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
83875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a uchar4.
83975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
84075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
84175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
84284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U8_4(sp<RS> rs);
84375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
84475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a char2.
84575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
84675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
84775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
84884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I8_2(sp<RS> rs);
84975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
85075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a char3.
85175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
85275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
85375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
85484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I8_3(sp<RS> rs);
85575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
85675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a char4.
85775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
85875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
85975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
86084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I8_4(sp<RS> rs);
86175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
86275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a ushort2.
86375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
86475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
86575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
86684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U16_2(sp<RS> rs);
86775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
86875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a ushort3.
86975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
87075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
87175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
87284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U16_3(sp<RS> rs);
87375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
87475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a ushort4.
87575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
87675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
87775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
87884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U16_4(sp<RS> rs);
87975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
88075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a short2.
88175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
88275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
88375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
88484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I16_2(sp<RS> rs);
88575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
88675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a short3.
88775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
88875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
88975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
89084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I16_3(sp<RS> rs);
89175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
89275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a short4.
89375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
89475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
89575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
89684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I16_4(sp<RS> rs);
89775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
89875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a uint2.
89975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
90075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
90175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
90284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U32_2(sp<RS> rs);
90375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
90475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a uint3.
90575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
90675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
90775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
90884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U32_3(sp<RS> rs);
90975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
91075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a uint4.
91175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
91275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
91375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
91484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U32_4(sp<RS> rs);
91575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
91675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an int2.
91775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
91875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
91975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
92084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I32_2(sp<RS> rs);
92175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
92275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an int3.
92375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
92475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
92575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
92684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I32_3(sp<RS> rs);
92775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
92875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an int4.
92975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
93075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
93175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
93284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I32_4(sp<RS> rs);
93375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
93475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a ulong2.
93575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
93675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
93775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
93884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U64_2(sp<RS> rs);
93975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
94075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a ulong3.
94175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
94275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
94375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
94484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U64_3(sp<RS> rs);
94575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
94675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a ulong4.
94775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
94875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
94975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
95084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> U64_4(sp<RS> rs);
95175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
95275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a long2.
95375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
95475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
95575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
95684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I64_2(sp<RS> rs);
95775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
95875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a long3.
95975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
96075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
96175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
96284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I64_3(sp<RS> rs);
96375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
96475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a long4.
96575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
96675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
96775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
96884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> I64_4(sp<RS> rs);
96975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
97075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing a YUV pixel.
97175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
97275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
97375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
974eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray    static sp<const Element> YUV(sp<RS> rs);
97575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
97675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an rs_matrix_4x4.
97775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
97875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
97975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
98084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> MATRIX_4X4(sp<RS> rs);
98175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
98275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an rs_matrix_3x3.
98375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
98475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
98575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
98684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> MATRIX_3X3(sp<RS> rs);
98775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
98875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Utility function for returning an Element containing an rs_matrix_2x2.
98975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
99075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
99175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
99284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> MATRIX_2X2(sp<RS> rs);
99384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
99484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void updateFromNative();
99575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
99675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
99775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Create an Element with a given DataType.
99875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
99975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dt data type
100075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
100175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
100284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> createUser(sp<RS> rs, RsDataType dt);
100375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
100475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Create a vector Element with the given DataType
100575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript
100675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dt DataType
100775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] size vector size
100875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
100975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
101084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> createVector(sp<RS> rs, RsDataType dt, uint32_t size);
101175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
101275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Create an Element with a given DataType and DataKind.
101375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
101475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dt DataType
101575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dk DataKind
101675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Element
101775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
101884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    static sp<const Element> createPixel(sp<RS> rs, RsDataType dt, RsDataKind dk);
101975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
102075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
102175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns true if the Element can interoperate with this Element.
102275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element to compare
102375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return true if Elements can interoperate
102475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
102510913a5c37ba119bef335320d3e8be25212c05adTim Murray    bool isCompatible(sp<const Element>e) const;
102684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
102775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
102875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Builder class for producing complex elements with matching field and name
102975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * pairs. The builder starts empty. The order in which elements are added is
103075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * retained for the layout in memory.
103175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
103284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    class Builder {
103384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    private:
103484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<RS> mRS;
103589daad6bae798779e57f252e9da4fe4e62337124Tim Murray        std::vector<sp<Element> > mElements;
1036ab71636b50db242cead6a3787620d6340156684cTim Murray        std::vector<std::string> mElementNames;
103789daad6bae798779e57f252e9da4fe4e62337124Tim Murray        std::vector<uint32_t> mArraySizes;
103884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        bool mSkipPadding;
103984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
104084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    public:
104184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        Builder(sp<RS> rs);
104284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        ~Builder();
1043ab71636b50db242cead6a3787620d6340156684cTim Murray        void add(sp<Element> e, std::string &name, uint32_t arraySize = 1);
104484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<const Element> create();
104584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    };
104684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
10477d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hinesprotected:
10487d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines    Element(void *id, sp<RS> rs,
10497d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines            std::vector<sp<Element> > &elements,
10507d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines            std::vector<std::string> &elementNames,
10517d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines            std::vector<uint32_t> &arraySizes);
10527d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines    Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
10537d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines    Element(sp<RS> rs);
10547d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines    virtual ~Element();
10557d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines
105684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprivate:
105784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void updateVisibleSubElements();
105884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
105989daad6bae798779e57f252e9da4fe4e62337124Tim Murray    std::vector<sp<Element> > mElements;
1060ab71636b50db242cead6a3787620d6340156684cTim Murray    std::vector<std::string> mElementNames;
106189daad6bae798779e57f252e9da4fe4e62337124Tim Murray    std::vector<uint32_t> mArraySizes;
106289daad6bae798779e57f252e9da4fe4e62337124Tim Murray    std::vector<uint32_t> mVisibleElementMap;
106389daad6bae798779e57f252e9da4fe4e62337124Tim Murray    std::vector<uint32_t> mOffsetInBytes;
106484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
106584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RsDataType mType;
106684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    RsDataKind mKind;
106784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mNormalized;
106884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t mSizeBytes;
106984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t mVectorSize;
107084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray};
107184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
10722c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hinesclass FieldPacker {
10732c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hinesprotected:
10742c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    unsigned char* mData;
10752c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    size_t mPos;
10762c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    size_t mLen;
10772c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
10782c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hinespublic:
10792c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    FieldPacker(size_t len)
108089daad6bae798779e57f252e9da4fe4e62337124Tim Murray        : mPos(0), mLen(len) {
108189daad6bae798779e57f252e9da4fe4e62337124Tim Murray            mData = new unsigned char[len];
108289daad6bae798779e57f252e9da4fe4e62337124Tim Murray        }
10832c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
10842c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    virtual ~FieldPacker() {
10852c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        delete [] mData;
10862c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
10872c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
10882c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    void align(size_t v) {
10892c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        if ((v & (v - 1)) != 0) {
1090ab71636b50db242cead6a3787620d6340156684cTim Murray            //            ALOGE("Non-power-of-two alignment: %zu", v);
10912c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines            return;
10922c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        }
10932c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
10942c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        while ((mPos & (v - 1)) != 0) {
10952c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines            mData[mPos++] = 0;
10962c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        }
10972c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
10982c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
10992c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    void reset() {
11002c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        mPos = 0;
11012c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
11022c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
11032c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    void reset(size_t i) {
11042c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        if (i >= mLen) {
1105ab71636b50db242cead6a3787620d6340156684cTim Murray            //            ALOGE("Out of bounds: i (%zu) >= len (%zu)", i, mLen);
11062c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines            return;
11072c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        }
11082c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        mPos = i;
11092c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
11102c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
11112c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    void skip(size_t i) {
11122c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        size_t res = mPos + i;
11132c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        if (res > mLen) {
1114ab71636b50db242cead6a3787620d6340156684cTim Murray            //            ALOGE("Exceeded buffer length: i (%zu) > len (%zu)", i, mLen);
11152c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines            return;
11162c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        }
11172c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        mPos = res;
11182c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
11192c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
11202c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    void* getData() const {
11212c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        return mData;
11222c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
11232c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
11242c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    size_t getLength() const {
11252c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        return mLen;
11262c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
11272c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
11282c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    template <typename T>
112989daad6bae798779e57f252e9da4fe4e62337124Tim Murray        void add(T t) {
11302c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        align(sizeof(t));
11312c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        if (mPos + sizeof(t) <= mLen) {
11322c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines            memcpy(&mData[mPos], &t, sizeof(t));
11332c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines            mPos += sizeof(t);
11342c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines        }
11352c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines    }
113643514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines
113743514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines    /*
113889daad6bae798779e57f252e9da4fe4e62337124Tim Murray      void add(rs_matrix4x4 m) {
113989daad6bae798779e57f252e9da4fe4e62337124Tim Murray      for (size_t i = 0; i < 16; i++) {
114089daad6bae798779e57f252e9da4fe4e62337124Tim Murray      add(m.m[i]);
114189daad6bae798779e57f252e9da4fe4e62337124Tim Murray      }
114289daad6bae798779e57f252e9da4fe4e62337124Tim Murray      }
114389daad6bae798779e57f252e9da4fe4e62337124Tim Murray
114489daad6bae798779e57f252e9da4fe4e62337124Tim Murray      void add(rs_matrix3x3 m) {
114589daad6bae798779e57f252e9da4fe4e62337124Tim Murray      for (size_t i = 0; i < 9; i++) {
114689daad6bae798779e57f252e9da4fe4e62337124Tim Murray      add(m.m[i]);
114789daad6bae798779e57f252e9da4fe4e62337124Tim Murray      }
114889daad6bae798779e57f252e9da4fe4e62337124Tim Murray      }
114989daad6bae798779e57f252e9da4fe4e62337124Tim Murray
115089daad6bae798779e57f252e9da4fe4e62337124Tim Murray      void add(rs_matrix2x2 m) {
115189daad6bae798779e57f252e9da4fe4e62337124Tim Murray      for (size_t i = 0; i < 4; i++) {
115289daad6bae798779e57f252e9da4fe4e62337124Tim Murray      add(m.m[i]);
115389daad6bae798779e57f252e9da4fe4e62337124Tim Murray      }
115489daad6bae798779e57f252e9da4fe4e62337124Tim Murray      }
115543514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines    */
115643514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines
115789daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void add(sp<BaseObj> obj) {
115843514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines        if (obj != NULL) {
115943514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines            add((uint32_t) (uintptr_t) obj->getID());
116043514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines        } else {
116143514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines            add((uint32_t) 0);
116243514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines        }
116343514cde7e9b4869ffba6ba759d1e31f22d936f7Stephen Hines    }
11642c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines};
11652c7206e7e19c23fdaa2dd5843f0597624a5e7341Stephen Hines
116675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
116775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type describes the Element and dimensions used for an Allocation or a
116875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * parallel operation.
116975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray *
117075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type always includes an Element and an X dimension. A Type may be
117175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * multidimensional, up to three dimensions. A nonzero value in the Y or Z
117275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * dimensions indicates that the dimension is present. Note that a Type with
117375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * only a given X dimension and a Type with the same X dimension but Y = 1 are
117475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * not equivalent.
117575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray *
117675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type also supports inclusion of level of detail (LOD) or cube map
117775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * faces. LOD and cube map faces are booleans to indicate present or not
117875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * present.
117975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray *
118075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * A Type also supports YUV format information to support an Allocation in a YUV
118175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * format. The YUV formats supported are YV12 and NV21.
118275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
118384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Type : public BaseObj {
118484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected:
118584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    friend class Allocation;
118684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
118784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mDimX;
118884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mDimY;
118984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t mDimZ;
1190eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray    RSYuvFormat mYuvFormat;
119184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mDimMipmaps;
119284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool mDimFaces;
119384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t mElementCount;
119484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    sp<const Element> mElement;
119584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
11967d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines    Type(void *id, sp<RS> rs);
11977d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines
119884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void calcElementCount();
119984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    virtual void updateFromNative();
120084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
120184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic:
120284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
120375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
120475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the YUV format.
120575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return YUV format of the Allocation
120675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1207eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray    RSYuvFormat getYuvFormat() const {
1208eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        return mYuvFormat;
1209eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray    }
1210eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray
121175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
121275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the Element of the Allocation.
121375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return YUV format of the Allocation
121475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
121584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    sp<const Element> getElement() const {
121684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mElement;
121784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
121884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
121975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
122075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the X dimension of the Allocation.
122175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return X dimension of the allocation
122275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
122384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t getX() const {
122484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mDimX;
122584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
122684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
122775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
122875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the Y dimension of the Allocation.
122975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Y dimension of the allocation
123075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
123184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t getY() const {
123284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mDimY;
123384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
123484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
123575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
123675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns the Z dimension of the Allocation.
123775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Z dimension of the allocation
123875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
123984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    uint32_t getZ() const {
124084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mDimZ;
124184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
124284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
124375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
124475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns true if the Allocation has mipmaps.
124575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return true if the Allocation has mipmaps
124675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
124784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool hasMipmaps() const {
124884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mDimMipmaps;
124984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
125084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
125175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
125275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns true if the Allocation is a cube map
125375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return true if the Allocation is a cube map
125475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
125584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    bool hasFaces() const {
125684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mDimFaces;
125784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
125884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
125975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
126075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns number of accessible Elements in the Allocation
126175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return number of accessible Elements in the Allocation
126275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
126384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t getCount() const {
126484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mElementCount;
126584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
126684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
126775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
126875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Returns size in bytes of all Elements in the Allocation
126975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return size in bytes of all Elements in the Allocation
127075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
127184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    size_t getSizeBytes() const {
127284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        return mElementCount * mElement->getSizeBytes();
127384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
127484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
127575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
127675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates a new Type with the given Element and dimensions.
127775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
127875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element
127975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dimX X dimension
128075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dimY Y dimension
128175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] dimZ Z dimension
128275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new Type
128375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
128496267c2ff0133c20cc5643419a3ed3b1e75fe568Tim Murray    static sp<const Type> create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint32_t dimY, uint32_t dimZ);
128584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
128684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    class Builder {
128784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    protected:
128884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<RS> mRS;
128984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        uint32_t mDimX;
129084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        uint32_t mDimY;
129184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        uint32_t mDimZ;
1292eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        RSYuvFormat mYuvFormat;
129384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        bool mDimMipmaps;
129484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        bool mDimFaces;
129584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<const Element> mElement;
129684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
129784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    public:
129884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        Builder(sp<RS> rs, sp<const Element> e);
129984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
130084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        void setX(uint32_t value);
13017d1b757c0be2622b72b3d3a10826752adb3e5182Stephen Hines        void setY(uint32_t value);
1302eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        void setZ(uint32_t value);
1303eb4426dfb63983559cf903b2ea984569e990c4fdTim Murray        void setYuvFormat(RSYuvFormat format);
130484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        void setMipmaps(bool value);
130584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        void setFaces(bool value);
130684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<const Type> create();
130784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    };
130884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
130984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray};
131084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
131175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
131275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The parent class for all executable Scripts. This should not be used by applications.
131375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
131484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass Script : public BaseObj {
131584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprivate:
131684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
131784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected:
131884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    Script(void *id, sp<RS> rs);
131984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void forEach(uint32_t slot, sp<const Allocation> in, sp<const Allocation> out,
132084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray            const void *v, size_t) const;
132184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void bindAllocation(sp<Allocation> va, uint32_t slot) const;
132284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setVar(uint32_t index, const void *, size_t len) const;
132384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setVar(uint32_t index, sp<const BaseObj> o) const;
132484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void invoke(uint32_t slot, const void *v, size_t len) const;
132584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
132684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
132784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void invoke(uint32_t slot) const {
132884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        invoke(slot, NULL, 0);
132984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
133084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setVar(uint32_t index, float v) const {
133184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        setVar(index, &v, sizeof(v));
133284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
133384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setVar(uint32_t index, double v) const {
133484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        setVar(index, &v, sizeof(v));
133584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
133684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setVar(uint32_t index, int32_t v) const {
133784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        setVar(index, &v, sizeof(v));
133884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
133984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setVar(uint32_t index, int64_t v) const {
134084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        setVar(index, &v, sizeof(v));
134184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
134284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    void setVar(uint32_t index, bool v) const {
134384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        setVar(index, &v, sizeof(v));
134484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    }
134584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
134684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murraypublic:
134784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    class FieldBase {
134884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    protected:
134984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<const Element> mElement;
135084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<Allocation> mAllocation;
135184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
135284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        void init(sp<RS> rs, uint32_t dimx, uint32_t usages = 0);
135384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
135484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    public:
135584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<const Element> getElement() {
135684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray            return mElement;
135784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        }
135884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
135984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<const Type> getType() {
136084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray            return mAllocation->getType();
136184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        }
136284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
136384bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        sp<const Allocation> getAllocation() {
136484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray            return mAllocation;
136584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        }
136684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
136784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray        //void updateAllocation();
136884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    };
136984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray};
137084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
137175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
137275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The parent class for all user-defined scripts. This is intended to be used by auto-generated code only.
137375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
137484bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayclass ScriptC : public Script {
137584bf2b877024aaa154b66e0f2338d54bdabd855aTim Murrayprotected:
137684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray    ScriptC(sp<RS> rs,
137784bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray            const void *codeTxt, size_t codeLength,
137884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray            const char *cachedName, size_t cachedNameLength,
137984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray            const char *cacheDir, size_t cacheDirLength);
138084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
138184bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray};
138284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
138375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
138475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The parent class for all script intrinsics. Intrinsics provide highly optimized implementations of
138575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * basic functions. This is not intended to be used directly.
138675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
13877f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murrayclass ScriptIntrinsic : public Script {
13887f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray protected:
138910913a5c37ba119bef335320d3e8be25212c05adTim Murray    sp<const Element> mElement;
13903cd44af22622898d3000b2b3c4c408cede294152Tim Murray    ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e);
1391b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    virtual ~ScriptIntrinsic();
13927f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray};
13937f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray
139475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
139575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for converting RGB to RGBA by using a 3D lookup table. The incoming
139675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * r,g,b values are use as normalized x,y,z coordinates into a 3D
139775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * allocation. The 8 nearest values are sampled and linearly interpolated. The
139875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * result is placed in the output.
139975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
140089daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsic3DLUT : public ScriptIntrinsic {
140121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
140289daad6bae798779e57f252e9da4fe4e62337124Tim Murray    ScriptIntrinsic3DLUT(sp<RS> rs, sp<const Element> e);
140321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
140475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
140575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported Element types are U8_4. Default lookup table is identity.
140675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
140775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element
140875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new ScriptIntrinsic
140975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
141021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    static sp<ScriptIntrinsic3DLUT> create(sp<RS> rs, sp<const Element> e);
141175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
141275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
141375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Launch the intrinsic.
141475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] ain input Allocation
141575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] aout output Allocation
141675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
141789daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void forEach(sp<Allocation> ain, sp<Allocation> aout);
141875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
141975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
142075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets the lookup table. The lookup table must use the same Element as the
142175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * intrinsic.
142275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] lut new lookup table
142375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
142489daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setLUT(sp<Allocation> lut);
142589daad6bae798779e57f252e9da4fe4e62337124Tim Murray};
142689daad6bae798779e57f252e9da4fe4e62337124Tim Murray
142775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
142875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic kernel for blending two Allocations.
142975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
14307f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murrayclass ScriptIntrinsicBlend : public ScriptIntrinsic {
143121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
143289daad6bae798779e57f252e9da4fe4e62337124Tim Murray    ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e);
143321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
143475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
143575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported Element types are U8_4.
143675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
143775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element
143875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new ScriptIntrinsicBlend
143975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
144021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    static sp<ScriptIntrinsicBlend> create(sp<RS> rs, sp<const Element> e);
144175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
144275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * sets dst = {0, 0, 0, 0}
144375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
144475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
144575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
144675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachClear(sp<Allocation> in, sp<Allocation> out);
144775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
144875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = src
144975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
145075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
145175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
145275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachSrc(sp<Allocation> in, sp<Allocation> out);
145375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
145475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = dst (NOP)
145575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
145675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
145775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
145875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachDst(sp<Allocation> in, sp<Allocation> out);
145975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
146075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = src + dst * (1.0 - src.a)
146175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
146275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
146375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
146475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachSrcOver(sp<Allocation> in, sp<Allocation> out);
146575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
146675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = dst + src * (1.0 - dst.a)
146775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
146875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
146975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
147075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachDstOver(sp<Allocation> in, sp<Allocation> out);
147175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
147275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = src * dst.a
147375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
147475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
147575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
147675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachSrcIn(sp<Allocation> in, sp<Allocation> out);
147775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
147875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = dst * src.a
147975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
148075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
148175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
148275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachDstIn(sp<Allocation> in, sp<Allocation> out);
148375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
148475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = src * (1.0 - dst.a)
148575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
148675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
148775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
148875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachSrcOut(sp<Allocation> in, sp<Allocation> out);
148975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
149075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = dst * (1.0 - src.a)
149175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
149275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
149375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
149475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachDstOut(sp<Allocation> in, sp<Allocation> out);
149575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
149675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb
149775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
149875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
149975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
150075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachSrcAtop(sp<Allocation> in, sp<Allocation> out);
150175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
150275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst.rgb = dst.rgb * src.a + (1.0 - dst.a) * src.rgb
150375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
150475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
150575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
150675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachDstAtop(sp<Allocation> in, sp<Allocation> out);
150775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
150875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a}
150975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
151075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
151175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
151275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachXor(sp<Allocation> in, sp<Allocation> out);
151375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
151475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = src * dst
151575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
151675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
151775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
151875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachMultiply(sp<Allocation> in, sp<Allocation> out);
151975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
152075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = min(src + dst, 1.0)
152175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
152275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
152375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
152475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachAdd(sp<Allocation> in, sp<Allocation> out);
152575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
152675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets dst = max(dst - src, 0.0)
152775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
152875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
152975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
153075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    void forEachSubtract(sp<Allocation> in, sp<Allocation> out);
15317f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray};
153284bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
153375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
153475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic Gausian blur filter. Applies a Gaussian blur of the specified
153575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * radius to all elements of an Allocation.
153675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
15378f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murrayclass ScriptIntrinsicBlur : public ScriptIntrinsic {
153821fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
153989daad6bae798779e57f252e9da4fe4e62337124Tim Murray    ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e);
154021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
154175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
154275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported Element types are U8 and U8_4.
154375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
154475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element
154575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new ScriptIntrinsicBlur
154675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
154721fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    static sp<ScriptIntrinsicBlur> create(sp<RS> rs, sp<const Element> e);
154875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
154975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets the input of the blur.
155075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
155175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
155221fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    void setInput(sp<Allocation> in);
155375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
155475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Runs the intrinsic.
155575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] output Allocation
155675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
155721fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    void forEach(sp<Allocation> out);
155875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
155975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets the radius of the blur. The supported range is 0 < radius <= 25.
156075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] radius radius of the blur
156175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
15628f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murray    void setRadius(float radius);
15638f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murray};
15648f1e60c42e0a819f389594f5d2f38fb2e024c9c9Tim Murray
156575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
156675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a color matrix to allocations. This has the
156775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * same effect as loading each element and converting it to a
156875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * F32_N, multiplying the result by the 4x4 color matrix
156975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * as performed by rsMatrixMultiply() and writing it to the output
157075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * after conversion back to U8_N or F32_N.
157175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
157289daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicColorMatrix : public ScriptIntrinsic {
157321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
157489daad6bae798779e57f252e9da4fe4e62337124Tim Murray    ScriptIntrinsicColorMatrix(sp<RS> rs, sp<const Element> e);
157521fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
157675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
157775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates a new intrinsic.
157875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
157975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new ScriptIntrinsicColorMatrix
158075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1581aae73c96081c15eb63ac24f29e243b7c85ff4480Tim Murray    static sp<ScriptIntrinsicColorMatrix> create(sp<RS> rs);
158275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
158375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Applies the color matrix. Supported types are U8 and F32 with
158475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * vector lengths between 1 and 4.
158575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
158675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[out] out output Allocation
158775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
158889daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void forEach(sp<Allocation> in, sp<Allocation> out);
158975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
159075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the value to be added after the color matrix has been
159175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * applied. The default value is {0, 0, 0, 0}.
159275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] add float[4] of values
159375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
159410913a5c37ba119bef335320d3e8be25212c05adTim Murray    void setAdd(float* add);
159575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
159675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
159775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the color matrix which will be applied to each cell of the
159875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * image. The alpha channel will be copied.
159975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
160075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] m float[9] of values
160175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
160289daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setColorMatrix3(float* m);
160375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
160475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the color matrix which will be applied to each cell of the
160575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * image.
160675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
160775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] m float[16] of values
160875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
160989daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setColorMatrix4(float* m);
161075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
161175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set a color matrix to convert from RGB to luminance. The alpha
161275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * channel will be a copy.
161375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
161489daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setGreyscale();
161575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
161675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the matrix to convert from RGB to YUV with a direct copy of
161775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * the 4th channel.
161875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
161989daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setRGBtoYUV();
162075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
162175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the matrix to convert from YUV to RGB with a direct copy of
162275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * the 4th channel.
162375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
162489daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setYUVtoRGB();
162589daad6bae798779e57f252e9da4fe4e62337124Tim Murray};
162689daad6bae798779e57f252e9da4fe4e62337124Tim Murray
162775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
162875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a 3x3 convolve to an allocation.
162975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
163089daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicConvolve3x3 : public ScriptIntrinsic {
163121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
163289daad6bae798779e57f252e9da4fe4e62337124Tim Murray    ScriptIntrinsicConvolve3x3(sp<RS> rs, sp<const Element> e);
163321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
163475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
163575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported types U8 and F32 with vector lengths between 1 and
163675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * 4. The default convolution kernel is the identity.
163775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
163875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element
163975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new ScriptIntrinsicConvolve3x3
164075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
164121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    static sp<ScriptIntrinsicConvolve3x3> create(sp<RS> rs, sp<const Element> e);
164275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
164375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets input for intrinsic.
164475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
164575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
164689daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setInput(sp<Allocation> in);
164775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
164875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Launches the intrinsic.
164975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
165075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
165189daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void forEach(sp<Allocation> out);
165275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
165375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets convolution kernel.
165475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] v float[9] of values
165575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
165689daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setCoefficients(float* v);
165789daad6bae798779e57f252e9da4fe4e62337124Tim Murray};
165889daad6bae798779e57f252e9da4fe4e62337124Tim Murray
165975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
166075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a 5x5 convolve to an allocation.
166175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
166289daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicConvolve5x5 : public ScriptIntrinsic {
166321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
166489daad6bae798779e57f252e9da4fe4e62337124Tim Murray    ScriptIntrinsicConvolve5x5(sp<RS> rs, sp<const Element> e);
166521fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
166675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
166775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported types U8 and F32 with vector lengths between 1 and
166875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * 4. The default convolution kernel is the identity.
166975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
167075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element
167175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return new ScriptIntrinsicConvolve5x5
167275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
167321fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    static sp<ScriptIntrinsicConvolve5x5> create(sp<RS> rs, sp<const Element> e);
167475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
167575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets input for intrinsic.
167675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] in input Allocation
167775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
167889daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setInput(sp<Allocation> in);
167975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
168075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Launches the intrinsic.
168175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] out output Allocation
168275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
168389daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void forEach(sp<Allocation> out);
168475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
168575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets convolution kernel.
168675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] v float[25] of values
168775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
168889daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void setCoefficients(float* v);
168989daad6bae798779e57f252e9da4fe4e62337124Tim Murray};
169089daad6bae798779e57f252e9da4fe4e62337124Tim Murray
169175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
169275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for computing a histogram.
169375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
1694b27b18130d0772203799ba0f2d27783b640dc891Tim Murrayclass ScriptIntrinsicHistogram : public ScriptIntrinsic {
169521fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
1696b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e);
169710913a5c37ba119bef335320d3e8be25212c05adTim Murray    sp<Allocation> mOut;
169821fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
169975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
170075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Create an intrinsic for calculating the histogram of an uchar
170175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * or uchar4 image.
170275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
170375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported elements types are U8_4, U8_3, U8_2, and U8.
170475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
170575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs The RenderScript context
170675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element type for inputs
170775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
170875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return ScriptIntrinsicHistogram
170975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
171010913a5c37ba119bef335320d3e8be25212c05adTim Murray    static sp<ScriptIntrinsicHistogram> create(sp<RS> rs);
171175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
171275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the output of the histogram.  32 bit integer types are
171375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * supported.
171475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
171575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] aout The output allocation
171675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1717b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    void setOutput(sp<Allocation> aout);
171875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
171975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the coefficients used for the dot product calculation. The
172075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * default is {0.299f, 0.587f, 0.114f, 0.f}.
172175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
172275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Coefficients must be >= 0 and sum to 1.0 or less.
172375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
172475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] r Red coefficient
172575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] g Green coefficient
172675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] b Blue coefficient
172775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] a Alpha coefficient
172875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1729b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    void setDotCoefficients(float r, float g, float b, float a);
173075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
173175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Process an input buffer and place the histogram into the output
173275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * allocation. The output allocation may be a narrower vector size
173375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * than the input. In this case the vector size of the output is
173475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * used to determine how many of the input channels are used in
173575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * the computation. This is useful if you have an RGBA input
173675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * buffer but only want the histogram for RGB.
173775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
173875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * 1D and 2D input allocations are supported.
173975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
174075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] ain The input image
174175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1742b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    void forEach(sp<Allocation> ain);
174375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
174475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Process an input buffer and place the histogram into the output
174575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * allocation. The dot product of the input channel and the
174675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * coefficients from 'setDotCoefficients' are used to calculate
174775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * the output values.
174875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
174975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * 1D and 2D input allocations are supported.
175075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
175175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param ain The input image
175275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1753b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    void forEach_dot(sp<Allocation> ain);
1754b27b18130d0772203799ba0f2d27783b640dc891Tim Murray};
1755b27b18130d0772203799ba0f2d27783b640dc891Tim Murray
175675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
175775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for applying a per-channel lookup table. Each channel of
175875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * the input has an independant lookup table. The tables are 256
175975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * entries in size and can cover the full value range of U8_4.
176075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray **/
1761b27b18130d0772203799ba0f2d27783b640dc891Tim Murrayclass ScriptIntrinsicLUT : public ScriptIntrinsic {
1762b27b18130d0772203799ba0f2d27783b640dc891Tim Murray private:
1763b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    sp<Allocation> LUT;
1764b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    bool mDirty;
1765b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    unsigned char mCache[1024];
17662acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray    void setTable(unsigned int offset, unsigned char base, unsigned int length, unsigned char* lutValues);
176721fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    ScriptIntrinsicLUT(sp<RS> rs, sp<const Element> e);
1768b27b18130d0772203799ba0f2d27783b640dc891Tim Murray
176989daad6bae798779e57f252e9da4fe4e62337124Tim Murray public:
177075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
177175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported elements types are U8_4.
177275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
177375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * The defaults tables are identity.
177475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
177575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs The RenderScript context
177675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element type for intputs and outputs
177775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
177875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return ScriptIntrinsicLUT
177975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
178021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    static sp<ScriptIntrinsicLUT> create(sp<RS> rs, sp<const Element> e);
178175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
178275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Invoke the kernel and apply the lookup to each cell of ain and
178375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * copy to aout.
178475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
178575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] ain Input allocation
178675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] aout Output allocation
178775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
178889daad6bae798779e57f252e9da4fe4e62337124Tim Murray    void forEach(sp<Allocation> ain, sp<Allocation> aout);
178975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
179075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets entries in LUT for the red channel.
179175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] base base of region to update
179275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] length length of region to update
179375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] lutValues LUT values to use
179475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
17952acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray    void setRed(unsigned char base, unsigned int length, unsigned char* lutValues);
179675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
179775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets entries in LUT for the green channel.
179875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] base base of region to update
179975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] length length of region to update
180075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] lutValues LUT values to use
180175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
18022acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray    void setGreen(unsigned char base, unsigned int length, unsigned char* lutValues);
180375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
180475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets entries in LUT for the blue channel.
180575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] base base of region to update
180675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] length length of region to update
180775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] lutValues LUT values to use
180875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
18092acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray    void setBlue(unsigned char base, unsigned int length, unsigned char* lutValues);
181075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
181175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Sets entries in LUT for the alpha channel.
181275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] base base of region to update
181375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] length length of region to update
181475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] lutValues LUT values to use
181575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
18162acce99bd7d6bb97d8a4d4778107968aa09d6e02Tim Murray    void setAlpha(unsigned char base, unsigned int length, unsigned char* lutValues);
1817b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    virtual ~ScriptIntrinsicLUT();
1818b27b18130d0772203799ba0f2d27783b640dc891Tim Murray};
1819b27b18130d0772203799ba0f2d27783b640dc891Tim Murray
182075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
182175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Intrinsic for converting an Android YUV buffer to RGB.
182275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray *
182375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * The input allocation should be supplied in a supported YUV format
182475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * as a YUV element Allocation. The output is RGBA; the alpha channel
182575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * will be set to 255.
182675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray */
182789daad6bae798779e57f252e9da4fe4e62337124Tim Murrayclass ScriptIntrinsicYuvToRGB : public ScriptIntrinsic {
182821fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray private:
1829b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    ScriptIntrinsicYuvToRGB(sp<RS> rs, sp<const Element> e);
183021fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray public:
183175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
183275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Create an intrinsic for converting YUV to RGB.
183375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
183475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Supported elements types are U8_4.
183575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
183675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs The RenderScript context
183775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] e Element type for output
183875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
183975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return ScriptIntrinsicYuvToRGB
184075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
184121fa7a0a23eddab88ff261017f6d7a2548b4d89aTim Murray    static sp<ScriptIntrinsicYuvToRGB> create(sp<RS> rs, sp<const Element> e);
184275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
184375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Set the input YUV allocation.
184475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
184575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] ain The input allocation.
184675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1847b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    void setInput(sp<Allocation> in);
184875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray
184975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
185075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Convert the image to RGB.
185175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
185275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] aout Output allocation. Must match creation element
185375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *                 type.
185475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1855b27b18130d0772203799ba0f2d27783b640dc891Tim Murray    void forEach(sp<Allocation> out);
185689daad6bae798779e57f252e9da4fe4e62337124Tim Murray
185789daad6bae798779e57f252e9da4fe4e62337124Tim Murray};
1858b27b18130d0772203799ba0f2d27783b640dc891Tim Murray
185975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray/**
186075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Sampler object that defines how Allocations can be read as textures
186175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * within a kernel. Samplers are used in conjunction with the rsSample
186275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * runtime function to return values from normalized coordinates.
186375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray *
186475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Any Allocation used with a Sampler must have been created with
186575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; using a Sampler on an
186675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * Allocation that was not created with
186775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray * RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE is undefined.
186875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray **/
1869729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray class Sampler : public BaseObj {
1870729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray private:
1871729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    Sampler(sp<RS> rs, void* id);
1872729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue mMin;
1873729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue mMag;
1874729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue mWrapS;
1875729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue mWrapT;
1876729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue mWrapR;
1877729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    float mAniso;
1878729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray
1879729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray public:
188075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
188175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Creates a non-standard Sampler.
188275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] rs RenderScript context
188375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] min minification
188475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] mag magnification
188575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] wrapS S wrapping mode
188675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] wrapT T wrapping mode
188775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param[in] anisotropy anisotropy setting
188875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1889729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    static sp<Sampler> create(sp<RS> rs, RsSamplerValue min, RsSamplerValue mag, RsSamplerValue wrapS, RsSamplerValue wrapT, float anisotropy);
1890729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray
189175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
189275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return minification setting for the sampler
189375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1894729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue getMinification();
189575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
189675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return magnification setting for the sampler
189775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1898729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue getMagnification();
189975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
190075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return S wrapping mode for the sampler
190175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1902729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue getWrapS();
190375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
190475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return T wrapping mode for the sampler
190575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1906729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    RsSamplerValue getWrapT();
190775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
190875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return anisotropy setting for the sampler
190975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1910729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    float getAnisotropy();
1911729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray
191275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
191375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with min and mag set to nearest and wrap modes set to
191475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * clamp.
191575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
191675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
191775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
191875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
191975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1920729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> CLAMP_NEAREST(sp<RS> rs);
192175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
192275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with min and mag set to linear and wrap modes set to
192375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * clamp.
192475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
192575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
192675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
192775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
192875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1929729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> CLAMP_LINEAR(sp<RS> rs);
193075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
193175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with mag set to linear, min linear mipmap linear, and
193275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * wrap modes set to clamp.
193375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
193475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
193575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
193675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
193775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1938729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR(sp<RS> rs);
193975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
194075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with min and mag set to nearest and wrap modes set to
194175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * wrap.
194275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
194375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
194475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
194575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
194675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1947729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> WRAP_NEAREST(sp<RS> rs);
194875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
194975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with min and mag set to linear and wrap modes set to
195075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * wrap.
195175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
195275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
195375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
195475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
195575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1956729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> WRAP_LINEAR(sp<RS> rs);
195775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
195875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with mag set to linear, min linear mipmap linear, and
195975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * wrap modes set to wrap.
196075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
196175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
196275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
196375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
196475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1965729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> WRAP_LINEAR_MIP_LINEAR(sp<RS> rs);
196675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
196775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with min and mag set to nearest and wrap modes set to
196875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * mirrored repeat.
196975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
197075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
197175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
197275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
197375e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1974729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> MIRRORED_REPEAT_NEAREST(sp<RS> rs);
197575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
197675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with min and mag set to linear and wrap modes set to
197775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * mirrored repeat.
197875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
197975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
198075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
198175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
198275e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1983729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> MIRRORED_REPEAT_LINEAR(sp<RS> rs);
198475e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray    /**
198575e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * Retrieve a sampler with min and mag set to linear and wrap modes set to
198675e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * mirrored repeat.
198775e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
198875e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @param rs Context to which the sampler will belong.
198975e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     *
199075e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     * @return Sampler
199175e877d157f9429eb6d8fb1b09c75c5472db161aTim Murray     */
1992729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray    sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR(sp<RS> rs);
1993729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray
1994729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray};
1995729b6fe58aff47c4f666b22bbb7a6d6114ddefa9Tim Murray
1996d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Byte2 {
1997d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
1998d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int8_t x, y;
1999d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2000d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Byte2(int8_t initX, int8_t initY)
2001d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2002d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Byte2() : x(0), y(0) {}
2003d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2004d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2005d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Byte3 {
2006d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2007d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int8_t x, y, z;
2008d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2009d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Byte3(int8_t initX, int8_t initY, int8_t initZ)
2010d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2011d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Byte3() : x(0), y(0), z(0) {}
2012d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2013d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2014d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Byte4 {
2015d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2016d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int8_t x, y, z, w;
2017d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2018d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Byte4(int8_t initX, int8_t initY, int8_t initZ, int8_t initW)
2019d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2020d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Byte4() : x(0), y(0), z(0), w(0) {}
2021d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2022d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2023d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UByte2 {
2024d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2025d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint8_t x, y;
2026d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2027d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UByte2(uint8_t initX, uint8_t initY)
2028d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2029d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UByte2() : x(0), y(0) {}
2030d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2031d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2032d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UByte3 {
2033d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2034d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint8_t x, y, z;
2035d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2036d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UByte3(uint8_t initX, uint8_t initY, uint8_t initZ)
2037d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2038d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UByte3() : x(0), y(0), z(0) {}
2039d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2040d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2041d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UByte4 {
2042d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2043d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint8_t x, y, z, w;
2044d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2045d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UByte4(uint8_t initX, uint8_t initY, uint8_t initZ, uint8_t initW)
2046d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2047d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UByte4() : x(0), y(0), z(0), w(0) {}
2048d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2049d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2050d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Short2 {
2051d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2052d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  short x, y;
2053d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2054d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Short2(short initX, short initY)
2055d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2056d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Short2() : x(0), y(0) {}
2057d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2058d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2059d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Short3 {
2060d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2061d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  short x, y, z;
2062d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2063d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Short3(short initX, short initY, short initZ)
2064d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2065d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Short3() : x(0), y(0), z(0) {}
2066d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2067d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2068d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Short4 {
2069d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2070d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  short x, y, z, w;
2071d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2072d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Short4(short initX, short initY, short initZ, short initW)
2073d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2074d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Short4() : x(0), y(0), z(0), w(0) {}
2075d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2076d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2077d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UShort2 {
2078d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2079d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint16_t x, y;
2080d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2081d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UShort2(uint16_t initX, uint16_t initY)
2082d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2083d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UShort2() : x(0), y(0) {}
2084d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2085d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2086d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UShort3 {
2087d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2088d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint16_t x, y, z;
2089d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2090d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UShort3(uint16_t initX, uint16_t initY, uint16_t initZ)
2091d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2092d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UShort3() : x(0), y(0), z(0) {}
2093d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2094d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2095d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UShort4 {
2096d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2097d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint16_t x, y, z, w;
2098d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2099d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UShort4(uint16_t initX, uint16_t initY, uint16_t initZ, uint16_t initW)
2100d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2101d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UShort4() : x(0), y(0), z(0), w(0) {}
2102d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2103d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2104d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Int2 {
2105d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2106d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int x, y;
2107d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2108d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Int2(int initX, int initY)
2109d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2110d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Int2() : x(0), y(0) {}
2111d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2112d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2113d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Int3 {
2114d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2115d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int x, y, z;
2116d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2117d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Int3(int initX, int initY, int initZ)
2118d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2119d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Int3() : x(0), y(0), z(0) {}
2120d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2121d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2122d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Int4 {
2123d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2124d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int x, y, z, w;
2125d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2126d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Int4(int initX, int initY, int initZ, int initW)
2127d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2128d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Int4() : x(0), y(0), z(0), w(0) {}
2129d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2130d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2131d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UInt2 {
2132d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2133d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint32_t x, y;
2134d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2135d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UInt2(uint32_t initX, uint32_t initY)
2136d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2137d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UInt2() : x(0), y(0) {}
2138d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2139d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2140d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UInt3 {
2141d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2142d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint32_t x, y, z;
2143d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2144d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UInt3(uint32_t initX, uint32_t initY, uint32_t initZ)
2145d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2146d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UInt3() : x(0), y(0), z(0) {}
2147d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2148d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2149d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass UInt4 {
2150d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2151d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint32_t x, y, z, w;
2152d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2153d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UInt4(uint32_t initX, uint32_t initY, uint32_t initZ, uint32_t initW)
2154d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2155d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  UInt4() : x(0), y(0), z(0), w(0) {}
2156d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2157d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2158d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Long2 {
2159d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2160d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int64_t x, y;
2161d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2162d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Long2(int64_t initX, int64_t initY)
2163d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2164d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Long2() : x(0), y(0) {}
2165d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2166d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2167d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Long3 {
2168d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2169d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int64_t x, y, z;
2170d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2171d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Long3(int64_t initX, int64_t initY, int64_t initZ)
2172d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2173d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Long3() : x(0), y(0), z(0) {}
2174d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2175d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2176d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Long4 {
2177d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2178d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  int64_t x, y, z, w;
2179d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2180d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Long4(int64_t initX, int64_t initY, int64_t initZ, int64_t initW)
2181d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2182d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Long4() : x(0), y(0), z(0), w(0) {}
2183d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2184d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2185d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass ULong2 {
2186d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2187d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint64_t x, y;
2188d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2189d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  ULong2(uint64_t initX, uint64_t initY)
2190d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2191d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  ULong2() : x(0), y(0) {}
2192d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2193d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2194d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass ULong3 {
2195d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2196d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint64_t x, y, z;
2197d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2198d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  ULong3(uint64_t initX, uint64_t initY, uint64_t initZ)
2199d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2200d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  ULong3() : x(0), y(0), z(0) {}
2201d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2202d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2203d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass ULong4 {
2204d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2205d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  uint64_t x, y, z, w;
2206d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2207d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  ULong4(uint64_t initX, uint64_t initY, uint64_t initZ, uint64_t initW)
2208d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2209d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  ULong4() : x(0), y(0), z(0), w(0) {}
2210d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2211d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2212d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Float2 {
2213d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2214d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  float x, y;
2215d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2216d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Float2(float initX, float initY)
2217d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2218d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Float2() : x(0), y(0) {}
2219d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2220d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2221d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Float3 {
2222d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2223d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  float x, y, z;
2224d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2225d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Float3(float initX, float initY, float initZ)
2226d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2227d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Float3() : x(0.f), y(0.f), z(0.f) {}
2228d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2229d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2230d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Float4 {
2231d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2232d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  float x, y, z, w;
2233d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2234d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Float4(float initX, float initY, float initZ, float initW)
2235d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2236d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Float4() : x(0.f), y(0.f), z(0.f), w(0.f) {}
2237d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2238d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2239d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Double2 {
2240d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2241d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  double x, y;
2242d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2243d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Double2(double initX, double initY)
2244d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY) {}
2245d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Double2() : x(0), y(0) {}
2246d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2247d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2248d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Double3 {
2249d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2250d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  double x, y, z;
2251d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2252d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Double3(double initX, double initY, double initZ)
2253d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ) {}
2254d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Double3() : x(0), y(0), z(0) {}
2255d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2256d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2257d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hinesclass Double4 {
2258d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines public:
2259d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  double x, y, z, w;
2260d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
2261d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Double4(double initX, double initY, double initZ, double initW)
2262d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines    : x(initX), y(initY), z(initZ), w(initW) {}
2263d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines  Double4() : x(0), y(0), z(0), w(0) {}
2264d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines};
2265d10412f903f2aab730fa9bcbead471db4d7c2393Stephen Hines
226684bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}
22677f0d56899840f071c81bbbcbebfbd880ac31c043Tim Murray
226884bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray}
226984bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray
227084bf2b877024aaa154b66e0f2338d54bdabd855aTim Murray#endif
2271