00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ANDROID_RSCPPSTRUCTS_H
00018 #define ANDROID_RSCPPSTRUCTS_H
00019
00020 #include "rsDefines.h"
00021 #include "util/RefBase.h"
00022 #include "rsDispatch.h"
00023
00024 #include <vector>
00025 #include <string>
00026
00031 #define RS_CPU_ALLOCATION_ALIGNMENT 16
00032
00033 namespace android {
00034 namespace RSC {
00035
00036 typedef void (*ErrorHandlerFunc_t)(uint32_t errorNum, const char *errorText);
00037 typedef void (*MessageHandlerFunc_t)(uint32_t msgNum, const void *msgData, size_t msgLen);
00038
00039 class RS;
00040 class BaseObj;
00041 class Element;
00042 class Type;
00043 class Allocation;
00044 class Script;
00045 class ScriptC;
00046 class Sampler;
00047
00053 enum RSError {
00054 RS_SUCCESS = 0,
00055 RS_ERROR_INVALID_PARAMETER = 1,
00056 RS_ERROR_RUNTIME_ERROR = 2,
00057
00058 RS_ERROR_INVALID_ELEMENT = 3,
00059 RS_ERROR_MAX = 9999
00060
00061 };
00062
00066 enum RSYuvFormat {
00067 RS_YUV_NONE = 0,
00068 RS_YUV_YV12 = 1,
00069 RS_YUV_NV21 = 2,
00070 RS_YUV_MAX = 3
00071 };
00072
00076 enum RSInitFlags {
00077 RS_INIT_SYNCHRONOUS = 1,
00078 RS_INIT_LOW_LATENCY = 2,
00079 RS_INIT_MAX = 4
00080 };
00081
00085 class RS : public android::RSC::LightRefBase<RS> {
00086
00087 public:
00088 RS();
00089 virtual ~RS();
00090
00098 bool init(std::string name, uint32_t flags = 0);
00099
00106 void setErrorHandler(ErrorHandlerFunc_t func);
00107
00113 ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; }
00114
00121 void setMessageHandler(MessageHandlerFunc_t func);
00122
00128 MessageHandlerFunc_t getMessageHandler() { return mMessageFunc; }
00129
00135 RSError getError();
00136
00141 void finish();
00142
00143 RsContext getContext() { return mContext; }
00144 void throwError(RSError error, const char *errMsg);
00145
00146 static dispatchTable* dispatch;
00147
00148 private:
00149 static bool usingNative;
00150 static bool initDispatch(int targetApi);
00151
00152 bool init(std::string &name, int targetApi, uint32_t flags);
00153 static void * threadProc(void *);
00154
00155 static bool gInitialized;
00156 static pthread_mutex_t gInitMutex;
00157
00158 pthread_t mMessageThreadId;
00159 pid_t mNativeMessageThreadId;
00160 bool mMessageRun;
00161
00162 RsDevice mDev;
00163 RsContext mContext;
00164 RSError mCurrentError;
00165
00166 ErrorHandlerFunc_t mErrorFunc;
00167 MessageHandlerFunc_t mMessageFunc;
00168 bool mInit;
00169
00170 std::string mCacheDir;
00171
00172 struct {
00173 sp<const Element> U8;
00174 sp<const Element> U8_2;
00175 sp<const Element> U8_3;
00176 sp<const Element> U8_4;
00177 sp<const Element> I8;
00178 sp<const Element> I8_2;
00179 sp<const Element> I8_3;
00180 sp<const Element> I8_4;
00181 sp<const Element> U16;
00182 sp<const Element> U16_2;
00183 sp<const Element> U16_3;
00184 sp<const Element> U16_4;
00185 sp<const Element> I16;
00186 sp<const Element> I16_2;
00187 sp<const Element> I16_3;
00188 sp<const Element> I16_4;
00189 sp<const Element> U32;
00190 sp<const Element> U32_2;
00191 sp<const Element> U32_3;
00192 sp<const Element> U32_4;
00193 sp<const Element> I32;
00194 sp<const Element> I32_2;
00195 sp<const Element> I32_3;
00196 sp<const Element> I32_4;
00197 sp<const Element> U64;
00198 sp<const Element> U64_2;
00199 sp<const Element> U64_3;
00200 sp<const Element> U64_4;
00201 sp<const Element> I64;
00202 sp<const Element> I64_2;
00203 sp<const Element> I64_3;
00204 sp<const Element> I64_4;
00205 sp<const Element> F32;
00206 sp<const Element> F32_2;
00207 sp<const Element> F32_3;
00208 sp<const Element> F32_4;
00209 sp<const Element> F64;
00210 sp<const Element> F64_2;
00211 sp<const Element> F64_3;
00212 sp<const Element> F64_4;
00213 sp<const Element> BOOLEAN;
00214
00215 sp<const Element> ELEMENT;
00216 sp<const Element> TYPE;
00217 sp<const Element> ALLOCATION;
00218 sp<const Element> SAMPLER;
00219 sp<const Element> SCRIPT;
00220 sp<const Element> MESH;
00221 sp<const Element> PROGRAM_FRAGMENT;
00222 sp<const Element> PROGRAM_VERTEX;
00223 sp<const Element> PROGRAM_RASTER;
00224 sp<const Element> PROGRAM_STORE;
00225
00226 sp<const Element> A_8;
00227 sp<const Element> RGB_565;
00228 sp<const Element> RGB_888;
00229 sp<const Element> RGBA_5551;
00230 sp<const Element> RGBA_4444;
00231 sp<const Element> RGBA_8888;
00232
00233 sp<const Element> YUV;
00234
00235 sp<const Element> MATRIX_4X4;
00236 sp<const Element> MATRIX_3X3;
00237 sp<const Element> MATRIX_2X2;
00238 } mElements;
00239
00240 struct {
00241 sp<const Sampler> CLAMP_NEAREST;
00242 sp<const Sampler> CLAMP_LINEAR;
00243 sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR;
00244 sp<const Sampler> WRAP_NEAREST;
00245 sp<const Sampler> WRAP_LINEAR;
00246 sp<const Sampler> WRAP_LINEAR_MIP_LINEAR;
00247 sp<const Sampler> MIRRORED_REPEAT_NEAREST;
00248 sp<const Sampler> MIRRORED_REPEAT_LINEAR;
00249 sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
00250 } mSamplers;
00251 friend class Sampler;
00252 friend class Element;
00253 friend class ScriptC;
00254 };
00255
00259 class BaseObj : public android::RSC::LightRefBase<BaseObj> {
00260 public:
00261 void * getID() const;
00262 virtual ~BaseObj();
00263 virtual void updateFromNative();
00264 virtual bool equals(sp<const BaseObj> obj);
00265
00266 protected:
00267 void *mID;
00268 RS* mRS;
00269 std::string mName;
00270
00271 BaseObj(void *id, sp<RS> rs);
00272 void checkValid();
00273
00274 static void * getObjID(sp<const BaseObj> o);
00275
00276 };
00277
00293 class Allocation : public BaseObj {
00294 protected:
00295 sp<const Type> mType;
00296 uint32_t mUsage;
00297 sp<Allocation> mAdaptedAllocation;
00298
00299 bool mConstrainedLOD;
00300 bool mConstrainedFace;
00301 bool mConstrainedY;
00302 bool mConstrainedZ;
00303 bool mReadAllowed;
00304 bool mWriteAllowed;
00305 uint32_t mSelectedY;
00306 uint32_t mSelectedZ;
00307 uint32_t mSelectedLOD;
00308 RsAllocationCubemapFace mSelectedFace;
00309
00310 uint32_t mCurrentDimX;
00311 uint32_t mCurrentDimY;
00312 uint32_t mCurrentDimZ;
00313 uint32_t mCurrentCount;
00314
00315 void * getIDSafe() const;
00316 void updateCacheInfo(sp<const Type> t);
00317
00318 Allocation(void *id, sp<RS> rs, sp<const Type> t, uint32_t usage);
00319
00320 void validateIsInt32();
00321 void validateIsInt16();
00322 void validateIsInt8();
00323 void validateIsFloat32();
00324 void validateIsObject();
00325
00326 virtual void updateFromNative();
00327
00328 void validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h);
00329 void validate3DRange(uint32_t xoff, uint32_t yoff, uint32_t zoff,
00330 uint32_t w, uint32_t h, uint32_t d);
00331
00332 public:
00333
00338 sp<const Type> getType() const {
00339 return mType;
00340 }
00341
00346 void syncAll(RsAllocationUsageType srcLocation);
00347 void ioSendOutput();
00348 void ioGetInput();
00349
00357 void generateMipmaps();
00358
00365 void copy1DRangeFrom(uint32_t off, size_t count, const void *data);
00366
00374 void copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, uint32_t dataOff);
00375
00382 void copy1DRangeTo(uint32_t off, size_t count, void *data);
00383
00388 void copy1DFrom(const void* data);
00389
00394 void copy1DTo(void* data);
00395
00405 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00406 const void *data);
00407
00417 void copy2DRangeTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00418 void *data);
00419
00430 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00431 sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff);
00432
00442 void copy2DStridedFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00443 const void *data, size_t stride);
00444
00450 void copy2DStridedFrom(const void *data, size_t stride);
00451
00461 void copy2DStridedTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00462 void *data, size_t stride);
00463
00469 void copy2DStridedTo(void *data, size_t stride);
00470
00471
00483 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w,
00484 uint32_t h, uint32_t d, const void* data);
00485
00499 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff,
00500 uint32_t w, uint32_t h, uint32_t d,
00501 sp<const Allocation> data,
00502 uint32_t dataXoff, uint32_t dataYoff, uint32_t dataZoff);
00503
00512 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
00513 RsAllocationMipmapControl mipmaps, uint32_t usage);
00514
00525 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
00526 RsAllocationMipmapControl mipmaps, uint32_t usage, void * pointer);
00527
00535 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
00536 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
00545 static sp<Allocation> createSized(sp<RS> rs, sp<const Element> e, size_t count,
00546 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
00547
00557 static sp<Allocation> createSized2D(sp<RS> rs, sp<const Element> e,
00558 size_t x, size_t y,
00559 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
00560
00561
00562 };
00563
00584 class Element : public BaseObj {
00585 public:
00586 bool isComplex();
00587
00595 size_t getSubElementCount() {
00596 return mVisibleElementMap.size();
00597 }
00598
00604 sp<const Element> getSubElement(uint32_t index);
00605
00612 const char * getSubElementName(uint32_t index);
00613
00620 size_t getSubElementArraySize(uint32_t index);
00621
00627 uint32_t getSubElementOffsetBytes(uint32_t index);
00628
00633 RsDataType getDataType() const {
00634 return mType;
00635 }
00636
00641 RsDataKind getDataKind() const {
00642 return mKind;
00643 }
00644
00649 size_t getSizeBytes() const {
00650 return mSizeBytes;
00651 }
00652
00657 uint32_t getVectorSize() const {
00658 return mVectorSize;
00659 }
00660
00666 static sp<const Element> BOOLEAN(sp<RS> rs);
00672 static sp<const Element> U8(sp<RS> rs);
00678 static sp<const Element> I8(sp<RS> rs);
00684 static sp<const Element> U16(sp<RS> rs);
00690 static sp<const Element> I16(sp<RS> rs);
00696 static sp<const Element> U32(sp<RS> rs);
00702 static sp<const Element> I32(sp<RS> rs);
00708 static sp<const Element> U64(sp<RS> rs);
00714 static sp<const Element> I64(sp<RS> rs);
00720 static sp<const Element> F32(sp<RS> rs);
00726 static sp<const Element> F64(sp<RS> rs);
00732 static sp<const Element> ELEMENT(sp<RS> rs);
00738 static sp<const Element> TYPE(sp<RS> rs);
00744 static sp<const Element> ALLOCATION(sp<RS> rs);
00750 static sp<const Element> SAMPLER(sp<RS> rs);
00756 static sp<const Element> SCRIPT(sp<RS> rs);
00762 static sp<const Element> A_8(sp<RS> rs);
00768 static sp<const Element> RGB_565(sp<RS> rs);
00774 static sp<const Element> RGB_888(sp<RS> rs);
00780 static sp<const Element> RGBA_5551(sp<RS> rs);
00786 static sp<const Element> RGBA_4444(sp<RS> rs);
00792 static sp<const Element> RGBA_8888(sp<RS> rs);
00793
00799 static sp<const Element> F32_2(sp<RS> rs);
00805 static sp<const Element> F32_3(sp<RS> rs);
00811 static sp<const Element> F32_4(sp<RS> rs);
00817 static sp<const Element> F64_2(sp<RS> rs);
00823 static sp<const Element> F64_3(sp<RS> rs);
00829 static sp<const Element> F64_4(sp<RS> rs);
00835 static sp<const Element> U8_2(sp<RS> rs);
00841 static sp<const Element> U8_3(sp<RS> rs);
00847 static sp<const Element> U8_4(sp<RS> rs);
00853 static sp<const Element> I8_2(sp<RS> rs);
00859 static sp<const Element> I8_3(sp<RS> rs);
00865 static sp<const Element> I8_4(sp<RS> rs);
00871 static sp<const Element> U16_2(sp<RS> rs);
00877 static sp<const Element> U16_3(sp<RS> rs);
00883 static sp<const Element> U16_4(sp<RS> rs);
00889 static sp<const Element> I16_2(sp<RS> rs);
00895 static sp<const Element> I16_3(sp<RS> rs);
00901 static sp<const Element> I16_4(sp<RS> rs);
00907 static sp<const Element> U32_2(sp<RS> rs);
00913 static sp<const Element> U32_3(sp<RS> rs);
00919 static sp<const Element> U32_4(sp<RS> rs);
00925 static sp<const Element> I32_2(sp<RS> rs);
00931 static sp<const Element> I32_3(sp<RS> rs);
00937 static sp<const Element> I32_4(sp<RS> rs);
00943 static sp<const Element> U64_2(sp<RS> rs);
00949 static sp<const Element> U64_3(sp<RS> rs);
00955 static sp<const Element> U64_4(sp<RS> rs);
00961 static sp<const Element> I64_2(sp<RS> rs);
00967 static sp<const Element> I64_3(sp<RS> rs);
00973 static sp<const Element> I64_4(sp<RS> rs);
00979 static sp<const Element> YUV(sp<RS> rs);
00985 static sp<const Element> MATRIX_4X4(sp<RS> rs);
00991 static sp<const Element> MATRIX_3X3(sp<RS> rs);
00997 static sp<const Element> MATRIX_2X2(sp<RS> rs);
00998
00999 void updateFromNative();
01000
01007 static sp<const Element> createUser(sp<RS> rs, RsDataType dt);
01015 static sp<const Element> createVector(sp<RS> rs, RsDataType dt, uint32_t size);
01023 static sp<const Element> createPixel(sp<RS> rs, RsDataType dt, RsDataKind dk);
01024
01030 bool isCompatible(sp<const Element>e) const;
01031
01037 class Builder {
01038 private:
01039 RS* mRS;
01040 std::vector<sp<Element> > mElements;
01041 std::vector<std::string> mElementNames;
01042 std::vector<uint32_t> mArraySizes;
01043 bool mSkipPadding;
01044
01045 public:
01046 Builder(sp<RS> rs);
01047 ~Builder();
01048 void add(sp<Element> e, std::string &name, uint32_t arraySize = 1);
01049 sp<const Element> create();
01050 };
01051
01052 protected:
01053 Element(void *id, sp<RS> rs,
01054 std::vector<sp<Element> > &elements,
01055 std::vector<std::string> &elementNames,
01056 std::vector<uint32_t> &arraySizes);
01057 Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
01058 Element(sp<RS> rs);
01059 virtual ~Element();
01060
01061 private:
01062 void updateVisibleSubElements();
01063
01064 std::vector<sp<Element> > mElements;
01065 std::vector<std::string> mElementNames;
01066 std::vector<uint32_t> mArraySizes;
01067 std::vector<uint32_t> mVisibleElementMap;
01068 std::vector<uint32_t> mOffsetInBytes;
01069
01070 RsDataType mType;
01071 RsDataKind mKind;
01072 bool mNormalized;
01073 size_t mSizeBytes;
01074 size_t mVectorSize;
01075 };
01076
01077 class FieldPacker {
01078 protected:
01079 unsigned char* mData;
01080 size_t mPos;
01081 size_t mLen;
01082
01083 public:
01084 FieldPacker(size_t len)
01085 : mPos(0), mLen(len) {
01086 mData = new unsigned char[len];
01087 }
01088
01089 virtual ~FieldPacker() {
01090 delete [] mData;
01091 }
01092
01093 void align(size_t v) {
01094 if ((v & (v - 1)) != 0) {
01095
01096 return;
01097 }
01098
01099 while ((mPos & (v - 1)) != 0) {
01100 mData[mPos++] = 0;
01101 }
01102 }
01103
01104 void reset() {
01105 mPos = 0;
01106 }
01107
01108 void reset(size_t i) {
01109 if (i >= mLen) {
01110
01111 return;
01112 }
01113 mPos = i;
01114 }
01115
01116 void skip(size_t i) {
01117 size_t res = mPos + i;
01118 if (res > mLen) {
01119
01120 return;
01121 }
01122 mPos = res;
01123 }
01124
01125 void* getData() const {
01126 return mData;
01127 }
01128
01129 size_t getLength() const {
01130 return mLen;
01131 }
01132
01133 template <typename T>
01134 void add(T t) {
01135 align(sizeof(t));
01136 if (mPos + sizeof(t) <= mLen) {
01137 memcpy(&mData[mPos], &t, sizeof(t));
01138 mPos += sizeof(t);
01139 }
01140 }
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162 void add(sp<BaseObj> obj) {
01163 if (obj != NULL) {
01164 add((uint32_t) (uintptr_t) obj->getID());
01165 } else {
01166 add((uint32_t) 0);
01167 }
01168 }
01169 };
01170
01188 class Type : public BaseObj {
01189 protected:
01190 friend class Allocation;
01191
01192 uint32_t mDimX;
01193 uint32_t mDimY;
01194 uint32_t mDimZ;
01195 RSYuvFormat mYuvFormat;
01196 bool mDimMipmaps;
01197 bool mDimFaces;
01198 size_t mElementCount;
01199 sp<const Element> mElement;
01200
01201 Type(void *id, sp<RS> rs);
01202
01203 void calcElementCount();
01204 virtual void updateFromNative();
01205
01206 public:
01207
01212 RSYuvFormat getYuvFormat() const {
01213 return mYuvFormat;
01214 }
01215
01220 sp<const Element> getElement() const {
01221 return mElement;
01222 }
01223
01228 uint32_t getX() const {
01229 return mDimX;
01230 }
01231
01236 uint32_t getY() const {
01237 return mDimY;
01238 }
01239
01244 uint32_t getZ() const {
01245 return mDimZ;
01246 }
01247
01252 bool hasMipmaps() const {
01253 return mDimMipmaps;
01254 }
01255
01260 bool hasFaces() const {
01261 return mDimFaces;
01262 }
01263
01268 size_t getCount() const {
01269 return mElementCount;
01270 }
01271
01276 size_t getSizeBytes() const {
01277 return mElementCount * mElement->getSizeBytes();
01278 }
01279
01289 static sp<const Type> create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint32_t dimY, uint32_t dimZ);
01290
01291 class Builder {
01292 protected:
01293 RS* mRS;
01294 uint32_t mDimX;
01295 uint32_t mDimY;
01296 uint32_t mDimZ;
01297 RSYuvFormat mYuvFormat;
01298 bool mDimMipmaps;
01299 bool mDimFaces;
01300 sp<const Element> mElement;
01301
01302 public:
01303 Builder(sp<RS> rs, sp<const Element> e);
01304
01305 void setX(uint32_t value);
01306 void setY(uint32_t value);
01307 void setZ(uint32_t value);
01308 void setYuvFormat(RSYuvFormat format);
01309 void setMipmaps(bool value);
01310 void setFaces(bool value);
01311 sp<const Type> create();
01312 };
01313
01314 };
01315
01319 class Script : public BaseObj {
01320 private:
01321
01322 protected:
01323 Script(void *id, sp<RS> rs);
01324 void forEach(uint32_t slot, sp<const Allocation> in, sp<const Allocation> out,
01325 const void *v, size_t) const;
01326 void bindAllocation(sp<Allocation> va, uint32_t slot) const;
01327 void setVar(uint32_t index, const void *, size_t len) const;
01328 void setVar(uint32_t index, sp<const BaseObj> o) const;
01329 void invoke(uint32_t slot, const void *v, size_t len) const;
01330
01331
01332 void invoke(uint32_t slot) const {
01333 invoke(slot, NULL, 0);
01334 }
01335 void setVar(uint32_t index, float v) const {
01336 setVar(index, &v, sizeof(v));
01337 }
01338 void setVar(uint32_t index, double v) const {
01339 setVar(index, &v, sizeof(v));
01340 }
01341 void setVar(uint32_t index, int32_t v) const {
01342 setVar(index, &v, sizeof(v));
01343 }
01344 void setVar(uint32_t index, int64_t v) const {
01345 setVar(index, &v, sizeof(v));
01346 }
01347 void setVar(uint32_t index, bool v) const {
01348 setVar(index, &v, sizeof(v));
01349 }
01350
01351 public:
01352 class FieldBase {
01353 protected:
01354 sp<const Element> mElement;
01355 sp<Allocation> mAllocation;
01356
01357 void init(sp<RS> rs, uint32_t dimx, uint32_t usages = 0);
01358
01359 public:
01360 sp<const Element> getElement() {
01361 return mElement;
01362 }
01363
01364 sp<const Type> getType() {
01365 return mAllocation->getType();
01366 }
01367
01368 sp<const Allocation> getAllocation() {
01369 return mAllocation;
01370 }
01371
01372
01373 };
01374 };
01375
01379 class ScriptC : public Script {
01380 protected:
01381 ScriptC(sp<RS> rs,
01382 const void *codeTxt, size_t codeLength,
01383 const char *cachedName, size_t cachedNameLength,
01384 const char *cacheDir, size_t cacheDirLength);
01385
01386 };
01387
01392 class ScriptIntrinsic : public Script {
01393 protected:
01394 sp<const Element> mElement;
01395 ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e);
01396 virtual ~ScriptIntrinsic();
01397 };
01398
01405 class ScriptIntrinsic3DLUT : public ScriptIntrinsic {
01406 private:
01407 ScriptIntrinsic3DLUT(sp<RS> rs, sp<const Element> e);
01408 public:
01415 static sp<ScriptIntrinsic3DLUT> create(sp<RS> rs, sp<const Element> e);
01416
01422 void forEach(sp<Allocation> ain, sp<Allocation> aout);
01423
01429 void setLUT(sp<Allocation> lut);
01430 };
01431
01435 class ScriptIntrinsicBlend : public ScriptIntrinsic {
01436 private:
01437 ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e);
01438 public:
01445 static sp<ScriptIntrinsicBlend> create(sp<RS> rs, sp<const Element> e);
01451 void forEachClear(sp<Allocation> in, sp<Allocation> out);
01457 void forEachSrc(sp<Allocation> in, sp<Allocation> out);
01463 void forEachDst(sp<Allocation> in, sp<Allocation> out);
01469 void forEachSrcOver(sp<Allocation> in, sp<Allocation> out);
01475 void forEachDstOver(sp<Allocation> in, sp<Allocation> out);
01481 void forEachSrcIn(sp<Allocation> in, sp<Allocation> out);
01487 void forEachDstIn(sp<Allocation> in, sp<Allocation> out);
01493 void forEachSrcOut(sp<Allocation> in, sp<Allocation> out);
01499 void forEachDstOut(sp<Allocation> in, sp<Allocation> out);
01505 void forEachSrcAtop(sp<Allocation> in, sp<Allocation> out);
01511 void forEachDstAtop(sp<Allocation> in, sp<Allocation> out);
01517 void forEachXor(sp<Allocation> in, sp<Allocation> out);
01523 void forEachMultiply(sp<Allocation> in, sp<Allocation> out);
01529 void forEachAdd(sp<Allocation> in, sp<Allocation> out);
01535 void forEachSubtract(sp<Allocation> in, sp<Allocation> out);
01536 };
01537
01542 class ScriptIntrinsicBlur : public ScriptIntrinsic {
01543 private:
01544 ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e);
01545 public:
01552 static sp<ScriptIntrinsicBlur> create(sp<RS> rs, sp<const Element> e);
01557 void setInput(sp<Allocation> in);
01562 void forEach(sp<Allocation> out);
01567 void setRadius(float radius);
01568 };
01569
01577 class ScriptIntrinsicColorMatrix : public ScriptIntrinsic {
01578 private:
01579 ScriptIntrinsicColorMatrix(sp<RS> rs, sp<const Element> e);
01580 public:
01586 static sp<ScriptIntrinsicColorMatrix> create(sp<RS> rs);
01593 void forEach(sp<Allocation> in, sp<Allocation> out);
01599 void setAdd(float* add);
01600
01607 void setColorMatrix3(float* m);
01614 void setColorMatrix4(float* m);
01619 void setGreyscale();
01624 void setRGBtoYUV();
01629 void setYUVtoRGB();
01630 };
01631
01635 class ScriptIntrinsicConvolve3x3 : public ScriptIntrinsic {
01636 private:
01637 ScriptIntrinsicConvolve3x3(sp<RS> rs, sp<const Element> e);
01638 public:
01646 static sp<ScriptIntrinsicConvolve3x3> create(sp<RS> rs, sp<const Element> e);
01651 void setInput(sp<Allocation> in);
01656 void forEach(sp<Allocation> out);
01661 void setCoefficients(float* v);
01662 };
01663
01667 class ScriptIntrinsicConvolve5x5 : public ScriptIntrinsic {
01668 private:
01669 ScriptIntrinsicConvolve5x5(sp<RS> rs, sp<const Element> e);
01670 public:
01678 static sp<ScriptIntrinsicConvolve5x5> create(sp<RS> rs, sp<const Element> e);
01683 void setInput(sp<Allocation> in);
01688 void forEach(sp<Allocation> out);
01693 void setCoefficients(float* v);
01694 };
01695
01699 class ScriptIntrinsicHistogram : public ScriptIntrinsic {
01700 private:
01701 ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e);
01702 sp<Allocation> mOut;
01703 public:
01715 static sp<ScriptIntrinsicHistogram> create(sp<RS> rs);
01722 void setOutput(sp<Allocation> aout);
01734 void setDotCoefficients(float r, float g, float b, float a);
01747 void forEach(sp<Allocation> ain);
01758 void forEach_dot(sp<Allocation> ain);
01759 };
01760
01766 class ScriptIntrinsicLUT : public ScriptIntrinsic {
01767 private:
01768 sp<Allocation> LUT;
01769 bool mDirty;
01770 unsigned char mCache[1024];
01771 void setTable(unsigned int offset, unsigned char base, unsigned int length, unsigned char* lutValues);
01772 ScriptIntrinsicLUT(sp<RS> rs, sp<const Element> e);
01773
01774 public:
01785 static sp<ScriptIntrinsicLUT> create(sp<RS> rs, sp<const Element> e);
01793 void forEach(sp<Allocation> ain, sp<Allocation> aout);
01800 void setRed(unsigned char base, unsigned int length, unsigned char* lutValues);
01807 void setGreen(unsigned char base, unsigned int length, unsigned char* lutValues);
01814 void setBlue(unsigned char base, unsigned int length, unsigned char* lutValues);
01821 void setAlpha(unsigned char base, unsigned int length, unsigned char* lutValues);
01822 virtual ~ScriptIntrinsicLUT();
01823 };
01824
01832 class ScriptIntrinsicYuvToRGB : public ScriptIntrinsic {
01833 private:
01834 ScriptIntrinsicYuvToRGB(sp<RS> rs, sp<const Element> e);
01835 public:
01846 static sp<ScriptIntrinsicYuvToRGB> create(sp<RS> rs, sp<const Element> e);
01852 void setInput(sp<Allocation> in);
01853
01860 void forEach(sp<Allocation> out);
01861
01862 };
01863
01874 class Sampler : public BaseObj {
01875 private:
01876 Sampler(sp<RS> rs, void* id);
01877 RsSamplerValue mMin;
01878 RsSamplerValue mMag;
01879 RsSamplerValue mWrapS;
01880 RsSamplerValue mWrapT;
01881 RsSamplerValue mWrapR;
01882 float mAniso;
01883
01884 public:
01894 static sp<Sampler> create(sp<RS> rs, RsSamplerValue min, RsSamplerValue mag, RsSamplerValue wrapS, RsSamplerValue wrapT, float anisotropy);
01895
01899 RsSamplerValue getMinification();
01903 RsSamplerValue getMagnification();
01907 RsSamplerValue getWrapS();
01911 RsSamplerValue getWrapT();
01915 float getAnisotropy();
01916
01925 static sp<const Sampler> CLAMP_NEAREST(sp<RS> rs);
01934 static sp<const Sampler> CLAMP_LINEAR(sp<RS> rs);
01943 static sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR(sp<RS> rs);
01952 static sp<const Sampler> WRAP_NEAREST(sp<RS> rs);
01961 static sp<const Sampler> WRAP_LINEAR(sp<RS> rs);
01970 static sp<const Sampler> WRAP_LINEAR_MIP_LINEAR(sp<RS> rs);
01979 static sp<const Sampler> MIRRORED_REPEAT_NEAREST(sp<RS> rs);
01988 static sp<const Sampler> MIRRORED_REPEAT_LINEAR(sp<RS> rs);
01997 static sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR(sp<RS> rs);
01998
01999 };
02000
02001 class Byte2 {
02002 public:
02003 int8_t x, y;
02004
02005 Byte2(int8_t initX, int8_t initY)
02006 : x(initX), y(initY) {}
02007 Byte2() : x(0), y(0) {}
02008 };
02009
02010 class Byte3 {
02011 public:
02012 int8_t x, y, z;
02013
02014 Byte3(int8_t initX, int8_t initY, int8_t initZ)
02015 : x(initX), y(initY), z(initZ) {}
02016 Byte3() : x(0), y(0), z(0) {}
02017 };
02018
02019 class Byte4 {
02020 public:
02021 int8_t x, y, z, w;
02022
02023 Byte4(int8_t initX, int8_t initY, int8_t initZ, int8_t initW)
02024 : x(initX), y(initY), z(initZ), w(initW) {}
02025 Byte4() : x(0), y(0), z(0), w(0) {}
02026 };
02027
02028 class UByte2 {
02029 public:
02030 uint8_t x, y;
02031
02032 UByte2(uint8_t initX, uint8_t initY)
02033 : x(initX), y(initY) {}
02034 UByte2() : x(0), y(0) {}
02035 };
02036
02037 class UByte3 {
02038 public:
02039 uint8_t x, y, z;
02040
02041 UByte3(uint8_t initX, uint8_t initY, uint8_t initZ)
02042 : x(initX), y(initY), z(initZ) {}
02043 UByte3() : x(0), y(0), z(0) {}
02044 };
02045
02046 class UByte4 {
02047 public:
02048 uint8_t x, y, z, w;
02049
02050 UByte4(uint8_t initX, uint8_t initY, uint8_t initZ, uint8_t initW)
02051 : x(initX), y(initY), z(initZ), w(initW) {}
02052 UByte4() : x(0), y(0), z(0), w(0) {}
02053 };
02054
02055 class Short2 {
02056 public:
02057 short x, y;
02058
02059 Short2(short initX, short initY)
02060 : x(initX), y(initY) {}
02061 Short2() : x(0), y(0) {}
02062 };
02063
02064 class Short3 {
02065 public:
02066 short x, y, z;
02067
02068 Short3(short initX, short initY, short initZ)
02069 : x(initX), y(initY), z(initZ) {}
02070 Short3() : x(0), y(0), z(0) {}
02071 };
02072
02073 class Short4 {
02074 public:
02075 short x, y, z, w;
02076
02077 Short4(short initX, short initY, short initZ, short initW)
02078 : x(initX), y(initY), z(initZ), w(initW) {}
02079 Short4() : x(0), y(0), z(0), w(0) {}
02080 };
02081
02082 class UShort2 {
02083 public:
02084 uint16_t x, y;
02085
02086 UShort2(uint16_t initX, uint16_t initY)
02087 : x(initX), y(initY) {}
02088 UShort2() : x(0), y(0) {}
02089 };
02090
02091 class UShort3 {
02092 public:
02093 uint16_t x, y, z;
02094
02095 UShort3(uint16_t initX, uint16_t initY, uint16_t initZ)
02096 : x(initX), y(initY), z(initZ) {}
02097 UShort3() : x(0), y(0), z(0) {}
02098 };
02099
02100 class UShort4 {
02101 public:
02102 uint16_t x, y, z, w;
02103
02104 UShort4(uint16_t initX, uint16_t initY, uint16_t initZ, uint16_t initW)
02105 : x(initX), y(initY), z(initZ), w(initW) {}
02106 UShort4() : x(0), y(0), z(0), w(0) {}
02107 };
02108
02109 class Int2 {
02110 public:
02111 int x, y;
02112
02113 Int2(int initX, int initY)
02114 : x(initX), y(initY) {}
02115 Int2() : x(0), y(0) {}
02116 };
02117
02118 class Int3 {
02119 public:
02120 int x, y, z;
02121
02122 Int3(int initX, int initY, int initZ)
02123 : x(initX), y(initY), z(initZ) {}
02124 Int3() : x(0), y(0), z(0) {}
02125 };
02126
02127 class Int4 {
02128 public:
02129 int x, y, z, w;
02130
02131 Int4(int initX, int initY, int initZ, int initW)
02132 : x(initX), y(initY), z(initZ), w(initW) {}
02133 Int4() : x(0), y(0), z(0), w(0) {}
02134 };
02135
02136 class UInt2 {
02137 public:
02138 uint32_t x, y;
02139
02140 UInt2(uint32_t initX, uint32_t initY)
02141 : x(initX), y(initY) {}
02142 UInt2() : x(0), y(0) {}
02143 };
02144
02145 class UInt3 {
02146 public:
02147 uint32_t x, y, z;
02148
02149 UInt3(uint32_t initX, uint32_t initY, uint32_t initZ)
02150 : x(initX), y(initY), z(initZ) {}
02151 UInt3() : x(0), y(0), z(0) {}
02152 };
02153
02154 class UInt4 {
02155 public:
02156 uint32_t x, y, z, w;
02157
02158 UInt4(uint32_t initX, uint32_t initY, uint32_t initZ, uint32_t initW)
02159 : x(initX), y(initY), z(initZ), w(initW) {}
02160 UInt4() : x(0), y(0), z(0), w(0) {}
02161 };
02162
02163 class Long2 {
02164 public:
02165 int64_t x, y;
02166
02167 Long2(int64_t initX, int64_t initY)
02168 : x(initX), y(initY) {}
02169 Long2() : x(0), y(0) {}
02170 };
02171
02172 class Long3 {
02173 public:
02174 int64_t x, y, z;
02175
02176 Long3(int64_t initX, int64_t initY, int64_t initZ)
02177 : x(initX), y(initY), z(initZ) {}
02178 Long3() : x(0), y(0), z(0) {}
02179 };
02180
02181 class Long4 {
02182 public:
02183 int64_t x, y, z, w;
02184
02185 Long4(int64_t initX, int64_t initY, int64_t initZ, int64_t initW)
02186 : x(initX), y(initY), z(initZ), w(initW) {}
02187 Long4() : x(0), y(0), z(0), w(0) {}
02188 };
02189
02190 class ULong2 {
02191 public:
02192 uint64_t x, y;
02193
02194 ULong2(uint64_t initX, uint64_t initY)
02195 : x(initX), y(initY) {}
02196 ULong2() : x(0), y(0) {}
02197 };
02198
02199 class ULong3 {
02200 public:
02201 uint64_t x, y, z;
02202
02203 ULong3(uint64_t initX, uint64_t initY, uint64_t initZ)
02204 : x(initX), y(initY), z(initZ) {}
02205 ULong3() : x(0), y(0), z(0) {}
02206 };
02207
02208 class ULong4 {
02209 public:
02210 uint64_t x, y, z, w;
02211
02212 ULong4(uint64_t initX, uint64_t initY, uint64_t initZ, uint64_t initW)
02213 : x(initX), y(initY), z(initZ), w(initW) {}
02214 ULong4() : x(0), y(0), z(0), w(0) {}
02215 };
02216
02217 class Float2 {
02218 public:
02219 float x, y;
02220
02221 Float2(float initX, float initY)
02222 : x(initX), y(initY) {}
02223 Float2() : x(0), y(0) {}
02224 };
02225
02226 class Float3 {
02227 public:
02228 float x, y, z;
02229
02230 Float3(float initX, float initY, float initZ)
02231 : x(initX), y(initY), z(initZ) {}
02232 Float3() : x(0.f), y(0.f), z(0.f) {}
02233 };
02234
02235 class Float4 {
02236 public:
02237 float x, y, z, w;
02238
02239 Float4(float initX, float initY, float initZ, float initW)
02240 : x(initX), y(initY), z(initZ), w(initW) {}
02241 Float4() : x(0.f), y(0.f), z(0.f), w(0.f) {}
02242 };
02243
02244 class Double2 {
02245 public:
02246 double x, y;
02247
02248 Double2(double initX, double initY)
02249 : x(initX), y(initY) {}
02250 Double2() : x(0), y(0) {}
02251 };
02252
02253 class Double3 {
02254 public:
02255 double x, y, z;
02256
02257 Double3(double initX, double initY, double initZ)
02258 : x(initX), y(initY), z(initZ) {}
02259 Double3() : x(0), y(0), z(0) {}
02260 };
02261
02262 class Double4 {
02263 public:
02264 double x, y, z, w;
02265
02266 Double4(double initX, double initY, double initZ, double initW)
02267 : x(initX), y(initY), z(initZ), w(initW) {}
02268 Double4() : x(0), y(0), z(0), w(0) {}
02269 };
02270
02271 }
02272
02273 }
02274
02275 #endif