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
00096 bool init(uint32_t flags = 0);
00097
00104 void setErrorHandler(ErrorHandlerFunc_t func);
00105
00111 ErrorHandlerFunc_t getErrorHandler() { return mErrorFunc; }
00112
00119 void setMessageHandler(MessageHandlerFunc_t func);
00120
00126 MessageHandlerFunc_t getMessageHandler() { return mMessageFunc; }
00127
00133 RSError getError();
00134
00139 void finish();
00140
00141 RsContext getContext() { return mContext; }
00142 void throwError(RSError error, const char *errMsg);
00143
00144 static dispatchTable* dispatch;
00145
00146 private:
00147 static bool usingNative;
00148 static bool initDispatch(int targetApi);
00149
00150 bool init(int targetApi, uint32_t flags);
00151 static void * threadProc(void *);
00152
00153 static bool gInitialized;
00154 static pthread_mutex_t gInitMutex;
00155
00156 pthread_t mMessageThreadId;
00157 pid_t mNativeMessageThreadId;
00158 bool mMessageRun;
00159
00160 RsDevice mDev;
00161 RsContext mContext;
00162 RSError mCurrentError;
00163
00164 ErrorHandlerFunc_t mErrorFunc;
00165 MessageHandlerFunc_t mMessageFunc;
00166 bool mInit;
00167
00168 struct {
00169 sp<const Element> U8;
00170 sp<const Element> U8_2;
00171 sp<const Element> U8_3;
00172 sp<const Element> U8_4;
00173 sp<const Element> I8;
00174 sp<const Element> I8_2;
00175 sp<const Element> I8_3;
00176 sp<const Element> I8_4;
00177 sp<const Element> U16;
00178 sp<const Element> U16_2;
00179 sp<const Element> U16_3;
00180 sp<const Element> U16_4;
00181 sp<const Element> I16;
00182 sp<const Element> I16_2;
00183 sp<const Element> I16_3;
00184 sp<const Element> I16_4;
00185 sp<const Element> U32;
00186 sp<const Element> U32_2;
00187 sp<const Element> U32_3;
00188 sp<const Element> U32_4;
00189 sp<const Element> I32;
00190 sp<const Element> I32_2;
00191 sp<const Element> I32_3;
00192 sp<const Element> I32_4;
00193 sp<const Element> U64;
00194 sp<const Element> U64_2;
00195 sp<const Element> U64_3;
00196 sp<const Element> U64_4;
00197 sp<const Element> I64;
00198 sp<const Element> I64_2;
00199 sp<const Element> I64_3;
00200 sp<const Element> I64_4;
00201 sp<const Element> F32;
00202 sp<const Element> F32_2;
00203 sp<const Element> F32_3;
00204 sp<const Element> F32_4;
00205 sp<const Element> F64;
00206 sp<const Element> F64_2;
00207 sp<const Element> F64_3;
00208 sp<const Element> F64_4;
00209 sp<const Element> BOOLEAN;
00210
00211 sp<const Element> ELEMENT;
00212 sp<const Element> TYPE;
00213 sp<const Element> ALLOCATION;
00214 sp<const Element> SAMPLER;
00215 sp<const Element> SCRIPT;
00216 sp<const Element> MESH;
00217 sp<const Element> PROGRAM_FRAGMENT;
00218 sp<const Element> PROGRAM_VERTEX;
00219 sp<const Element> PROGRAM_RASTER;
00220 sp<const Element> PROGRAM_STORE;
00221
00222 sp<const Element> A_8;
00223 sp<const Element> RGB_565;
00224 sp<const Element> RGB_888;
00225 sp<const Element> RGBA_5551;
00226 sp<const Element> RGBA_4444;
00227 sp<const Element> RGBA_8888;
00228
00229 sp<const Element> YUV;
00230
00231 sp<const Element> MATRIX_4X4;
00232 sp<const Element> MATRIX_3X3;
00233 sp<const Element> MATRIX_2X2;
00234 } mElements;
00235
00236 struct {
00237 sp<const Sampler> CLAMP_NEAREST;
00238 sp<const Sampler> CLAMP_LINEAR;
00239 sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR;
00240 sp<const Sampler> WRAP_NEAREST;
00241 sp<const Sampler> WRAP_LINEAR;
00242 sp<const Sampler> WRAP_LINEAR_MIP_LINEAR;
00243 sp<const Sampler> MIRRORED_REPEAT_NEAREST;
00244 sp<const Sampler> MIRRORED_REPEAT_LINEAR;
00245 sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR;
00246 } mSamplers;
00247 friend class Sampler;
00248 friend class Element;
00249 };
00250
00254 class BaseObj : public android::RSC::LightRefBase<BaseObj> {
00255 public:
00256 void * getID() const;
00257 virtual ~BaseObj();
00258 virtual void updateFromNative();
00259 virtual bool equals(sp<const BaseObj> obj);
00260
00261 protected:
00262 void *mID;
00263 sp<RS> mRS;
00264 std::string mName;
00265
00266 BaseObj(void *id, sp<RS> rs);
00267 void checkValid();
00268
00269 static void * getObjID(sp<const BaseObj> o);
00270
00271 };
00272
00288 class Allocation : public BaseObj {
00289 protected:
00290 sp<const Type> mType;
00291 uint32_t mUsage;
00292 sp<Allocation> mAdaptedAllocation;
00293
00294 bool mConstrainedLOD;
00295 bool mConstrainedFace;
00296 bool mConstrainedY;
00297 bool mConstrainedZ;
00298 bool mReadAllowed;
00299 bool mWriteAllowed;
00300 uint32_t mSelectedY;
00301 uint32_t mSelectedZ;
00302 uint32_t mSelectedLOD;
00303 RsAllocationCubemapFace mSelectedFace;
00304
00305 uint32_t mCurrentDimX;
00306 uint32_t mCurrentDimY;
00307 uint32_t mCurrentDimZ;
00308 uint32_t mCurrentCount;
00309
00310 void * getIDSafe() const;
00311 void updateCacheInfo(sp<const Type> t);
00312
00313 Allocation(void *id, sp<RS> rs, sp<const Type> t, uint32_t usage);
00314
00315 void validateIsInt32();
00316 void validateIsInt16();
00317 void validateIsInt8();
00318 void validateIsFloat32();
00319 void validateIsObject();
00320
00321 virtual void updateFromNative();
00322
00323 void validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h);
00324 void validate3DRange(uint32_t xoff, uint32_t yoff, uint32_t zoff,
00325 uint32_t w, uint32_t h, uint32_t d);
00326
00327 public:
00328
00333 sp<const Type> getType() const {
00334 return mType;
00335 }
00336
00341 void syncAll(RsAllocationUsageType srcLocation);
00342 void ioSendOutput();
00343 void ioGetInput();
00344
00352 void generateMipmaps();
00353
00360 void copy1DRangeFrom(uint32_t off, size_t count, const void *data);
00361
00369 void copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, uint32_t dataOff);
00370
00377 void copy1DRangeTo(uint32_t off, size_t count, void *data);
00378
00383 void copy1DFrom(const void* data);
00384
00389 void copy1DTo(void* data);
00390
00400 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00401 const void *data);
00402
00412 void copy2DRangeTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00413 void *data);
00414
00425 void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00426 sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff);
00427
00437 void copy2DStridedFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00438 const void *data, size_t stride);
00439
00445 void copy2DStridedFrom(const void *data, size_t stride);
00446
00456 void copy2DStridedTo(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
00457 void *data, size_t stride);
00458
00464 void copy2DStridedTo(void *data, size_t stride);
00465
00466
00478 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w,
00479 uint32_t h, uint32_t d, const void* data);
00480
00494 void copy3DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t zoff,
00495 uint32_t w, uint32_t h, uint32_t d,
00496 sp<const Allocation> data,
00497 uint32_t dataXoff, uint32_t dataYoff, uint32_t dataZoff);
00498
00507 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
00508 RsAllocationMipmapControl mips, uint32_t usage);
00509
00520 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
00521 RsAllocationMipmapControl mips, uint32_t usage, void * pointer);
00522
00530 static sp<Allocation> createTyped(sp<RS> rs, sp<const Type> type,
00531 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
00540 static sp<Allocation> createSized(sp<RS> rs, sp<const Element> e, size_t count,
00541 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
00542
00552 static sp<Allocation> createSized2D(sp<RS> rs, sp<const Element> e,
00553 size_t x, size_t y,
00554 uint32_t usage = RS_ALLOCATION_USAGE_SCRIPT);
00555
00556
00557 };
00558
00579 class Element : public BaseObj {
00580 public:
00581 bool isComplex();
00582
00590 size_t getSubElementCount() {
00591 return mVisibleElementMap.size();
00592 }
00593
00599 sp<const Element> getSubElement(uint32_t index);
00600
00607 const char * getSubElementName(uint32_t index);
00608
00615 size_t getSubElementArraySize(uint32_t index);
00616
00622 uint32_t getSubElementOffsetBytes(uint32_t index);
00623
00628 RsDataType getDataType() const {
00629 return mType;
00630 }
00631
00636 RsDataKind getDataKind() const {
00637 return mKind;
00638 }
00639
00644 size_t getSizeBytes() const {
00645 return mSizeBytes;
00646 }
00647
00652 uint32_t getVectorSize() const {
00653 return mVectorSize;
00654 }
00655
00661 static sp<const Element> BOOLEAN(sp<RS> rs);
00667 static sp<const Element> U8(sp<RS> rs);
00673 static sp<const Element> I8(sp<RS> rs);
00679 static sp<const Element> U16(sp<RS> rs);
00685 static sp<const Element> I16(sp<RS> rs);
00691 static sp<const Element> U32(sp<RS> rs);
00697 static sp<const Element> I32(sp<RS> rs);
00703 static sp<const Element> U64(sp<RS> rs);
00709 static sp<const Element> I64(sp<RS> rs);
00715 static sp<const Element> F32(sp<RS> rs);
00721 static sp<const Element> F64(sp<RS> rs);
00727 static sp<const Element> ELEMENT(sp<RS> rs);
00733 static sp<const Element> TYPE(sp<RS> rs);
00739 static sp<const Element> ALLOCATION(sp<RS> rs);
00745 static sp<const Element> SAMPLER(sp<RS> rs);
00751 static sp<const Element> SCRIPT(sp<RS> rs);
00757 static sp<const Element> A_8(sp<RS> rs);
00763 static sp<const Element> RGB_565(sp<RS> rs);
00769 static sp<const Element> RGB_888(sp<RS> rs);
00775 static sp<const Element> RGBA_5551(sp<RS> rs);
00781 static sp<const Element> RGBA_4444(sp<RS> rs);
00787 static sp<const Element> RGBA_8888(sp<RS> rs);
00788
00794 static sp<const Element> F32_2(sp<RS> rs);
00800 static sp<const Element> F32_3(sp<RS> rs);
00806 static sp<const Element> F32_4(sp<RS> rs);
00812 static sp<const Element> F64_2(sp<RS> rs);
00818 static sp<const Element> F64_3(sp<RS> rs);
00824 static sp<const Element> F64_4(sp<RS> rs);
00830 static sp<const Element> U8_2(sp<RS> rs);
00836 static sp<const Element> U8_3(sp<RS> rs);
00842 static sp<const Element> U8_4(sp<RS> rs);
00848 static sp<const Element> I8_2(sp<RS> rs);
00854 static sp<const Element> I8_3(sp<RS> rs);
00860 static sp<const Element> I8_4(sp<RS> rs);
00866 static sp<const Element> U16_2(sp<RS> rs);
00872 static sp<const Element> U16_3(sp<RS> rs);
00878 static sp<const Element> U16_4(sp<RS> rs);
00884 static sp<const Element> I16_2(sp<RS> rs);
00890 static sp<const Element> I16_3(sp<RS> rs);
00896 static sp<const Element> I16_4(sp<RS> rs);
00902 static sp<const Element> U32_2(sp<RS> rs);
00908 static sp<const Element> U32_3(sp<RS> rs);
00914 static sp<const Element> U32_4(sp<RS> rs);
00920 static sp<const Element> I32_2(sp<RS> rs);
00926 static sp<const Element> I32_3(sp<RS> rs);
00932 static sp<const Element> I32_4(sp<RS> rs);
00938 static sp<const Element> U64_2(sp<RS> rs);
00944 static sp<const Element> U64_3(sp<RS> rs);
00950 static sp<const Element> U64_4(sp<RS> rs);
00956 static sp<const Element> I64_2(sp<RS> rs);
00962 static sp<const Element> I64_3(sp<RS> rs);
00968 static sp<const Element> I64_4(sp<RS> rs);
00974 static sp<const Element> YUV(sp<RS> rs);
00980 static sp<const Element> MATRIX_4X4(sp<RS> rs);
00986 static sp<const Element> MATRIX_3X3(sp<RS> rs);
00992 static sp<const Element> MATRIX_2X2(sp<RS> rs);
00993
00994 void updateFromNative();
00995
01002 static sp<const Element> createUser(sp<RS> rs, RsDataType dt);
01010 static sp<const Element> createVector(sp<RS> rs, RsDataType dt, uint32_t size);
01018 static sp<const Element> createPixel(sp<RS> rs, RsDataType dt, RsDataKind dk);
01019
01025 bool isCompatible(sp<const Element>e) const;
01026
01032 class Builder {
01033 private:
01034 sp<RS> mRS;
01035 std::vector<sp<Element> > mElements;
01036 std::vector<std::string> mElementNames;
01037 std::vector<uint32_t> mArraySizes;
01038 bool mSkipPadding;
01039
01040 public:
01041 Builder(sp<RS> rs);
01042 ~Builder();
01043 void add(sp<Element> e, std::string &name, uint32_t arraySize = 1);
01044 sp<const Element> create();
01045 };
01046
01047 protected:
01048 Element(void *id, sp<RS> rs,
01049 std::vector<sp<Element> > &elements,
01050 std::vector<std::string> &elementNames,
01051 std::vector<uint32_t> &arraySizes);
01052 Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
01053 Element(sp<RS> rs);
01054 virtual ~Element();
01055
01056 private:
01057 void updateVisibleSubElements();
01058
01059 std::vector<sp<Element> > mElements;
01060 std::vector<std::string> mElementNames;
01061 std::vector<uint32_t> mArraySizes;
01062 std::vector<uint32_t> mVisibleElementMap;
01063 std::vector<uint32_t> mOffsetInBytes;
01064
01065 RsDataType mType;
01066 RsDataKind mKind;
01067 bool mNormalized;
01068 size_t mSizeBytes;
01069 size_t mVectorSize;
01070 };
01071
01072 class FieldPacker {
01073 protected:
01074 unsigned char* mData;
01075 size_t mPos;
01076 size_t mLen;
01077
01078 public:
01079 FieldPacker(size_t len)
01080 : mPos(0), mLen(len) {
01081 mData = new unsigned char[len];
01082 }
01083
01084 virtual ~FieldPacker() {
01085 delete [] mData;
01086 }
01087
01088 void align(size_t v) {
01089 if ((v & (v - 1)) != 0) {
01090
01091 return;
01092 }
01093
01094 while ((mPos & (v - 1)) != 0) {
01095 mData[mPos++] = 0;
01096 }
01097 }
01098
01099 void reset() {
01100 mPos = 0;
01101 }
01102
01103 void reset(size_t i) {
01104 if (i >= mLen) {
01105
01106 return;
01107 }
01108 mPos = i;
01109 }
01110
01111 void skip(size_t i) {
01112 size_t res = mPos + i;
01113 if (res > mLen) {
01114
01115 return;
01116 }
01117 mPos = res;
01118 }
01119
01120 void* getData() const {
01121 return mData;
01122 }
01123
01124 size_t getLength() const {
01125 return mLen;
01126 }
01127
01128 template <typename T>
01129 void add(T t) {
01130 align(sizeof(t));
01131 if (mPos + sizeof(t) <= mLen) {
01132 memcpy(&mData[mPos], &t, sizeof(t));
01133 mPos += sizeof(t);
01134 }
01135 }
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157 void add(sp<BaseObj> obj) {
01158 if (obj != NULL) {
01159 add((uint32_t) (uintptr_t) obj->getID());
01160 } else {
01161 add((uint32_t) 0);
01162 }
01163 }
01164 };
01165
01183 class Type : public BaseObj {
01184 protected:
01185 friend class Allocation;
01186
01187 uint32_t mDimX;
01188 uint32_t mDimY;
01189 uint32_t mDimZ;
01190 RSYuvFormat mYuvFormat;
01191 bool mDimMipmaps;
01192 bool mDimFaces;
01193 size_t mElementCount;
01194 sp<const Element> mElement;
01195
01196 Type(void *id, sp<RS> rs);
01197
01198 void calcElementCount();
01199 virtual void updateFromNative();
01200
01201 public:
01202
01207 RSYuvFormat getYuvFormat() const {
01208 return mYuvFormat;
01209 }
01210
01215 sp<const Element> getElement() const {
01216 return mElement;
01217 }
01218
01223 uint32_t getX() const {
01224 return mDimX;
01225 }
01226
01231 uint32_t getY() const {
01232 return mDimY;
01233 }
01234
01239 uint32_t getZ() const {
01240 return mDimZ;
01241 }
01242
01247 bool hasMipmaps() const {
01248 return mDimMipmaps;
01249 }
01250
01255 bool hasFaces() const {
01256 return mDimFaces;
01257 }
01258
01263 size_t getCount() const {
01264 return mElementCount;
01265 }
01266
01271 size_t getSizeBytes() const {
01272 return mElementCount * mElement->getSizeBytes();
01273 }
01274
01284 static sp<const Type> create(sp<RS> rs, sp<const Element> e, uint32_t dimX, uint32_t dimY, uint32_t dimZ);
01285
01286 class Builder {
01287 protected:
01288 sp<RS> mRS;
01289 uint32_t mDimX;
01290 uint32_t mDimY;
01291 uint32_t mDimZ;
01292 RSYuvFormat mYuvFormat;
01293 bool mDimMipmaps;
01294 bool mDimFaces;
01295 sp<const Element> mElement;
01296
01297 public:
01298 Builder(sp<RS> rs, sp<const Element> e);
01299
01300 void setX(uint32_t value);
01301 void setY(uint32_t value);
01302 void setZ(uint32_t value);
01303 void setYuvFormat(RSYuvFormat format);
01304 void setMipmaps(bool value);
01305 void setFaces(bool value);
01306 sp<const Type> create();
01307 };
01308
01309 };
01310
01314 class Script : public BaseObj {
01315 private:
01316
01317 protected:
01318 Script(void *id, sp<RS> rs);
01319 void forEach(uint32_t slot, sp<const Allocation> in, sp<const Allocation> out,
01320 const void *v, size_t) const;
01321 void bindAllocation(sp<Allocation> va, uint32_t slot) const;
01322 void setVar(uint32_t index, const void *, size_t len) const;
01323 void setVar(uint32_t index, sp<const BaseObj> o) const;
01324 void invoke(uint32_t slot, const void *v, size_t len) const;
01325
01326
01327 void invoke(uint32_t slot) const {
01328 invoke(slot, NULL, 0);
01329 }
01330 void setVar(uint32_t index, float v) const {
01331 setVar(index, &v, sizeof(v));
01332 }
01333 void setVar(uint32_t index, double v) const {
01334 setVar(index, &v, sizeof(v));
01335 }
01336 void setVar(uint32_t index, int32_t v) const {
01337 setVar(index, &v, sizeof(v));
01338 }
01339 void setVar(uint32_t index, int64_t v) const {
01340 setVar(index, &v, sizeof(v));
01341 }
01342 void setVar(uint32_t index, bool v) const {
01343 setVar(index, &v, sizeof(v));
01344 }
01345
01346 public:
01347 class FieldBase {
01348 protected:
01349 sp<const Element> mElement;
01350 sp<Allocation> mAllocation;
01351
01352 void init(sp<RS> rs, uint32_t dimx, uint32_t usages = 0);
01353
01354 public:
01355 sp<const Element> getElement() {
01356 return mElement;
01357 }
01358
01359 sp<const Type> getType() {
01360 return mAllocation->getType();
01361 }
01362
01363 sp<const Allocation> getAllocation() {
01364 return mAllocation;
01365 }
01366
01367
01368 };
01369 };
01370
01374 class ScriptC : public Script {
01375 protected:
01376 ScriptC(sp<RS> rs,
01377 const void *codeTxt, size_t codeLength,
01378 const char *cachedName, size_t cachedNameLength,
01379 const char *cacheDir, size_t cacheDirLength);
01380
01381 };
01382
01387 class ScriptIntrinsic : public Script {
01388 protected:
01389 sp<const Element> mElement;
01390 ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e);
01391 virtual ~ScriptIntrinsic();
01392 };
01393
01400 class ScriptIntrinsic3DLUT : public ScriptIntrinsic {
01401 private:
01402 ScriptIntrinsic3DLUT(sp<RS> rs, sp<const Element> e);
01403 public:
01410 static sp<ScriptIntrinsic3DLUT> create(sp<RS> rs, sp<const Element> e);
01411
01417 void forEach(sp<Allocation> ain, sp<Allocation> aout);
01418
01424 void setLUT(sp<Allocation> lut);
01425 };
01426
01430 class ScriptIntrinsicBlend : public ScriptIntrinsic {
01431 private:
01432 ScriptIntrinsicBlend(sp<RS> rs, sp<const Element> e);
01433 public:
01440 static sp<ScriptIntrinsicBlend> create(sp<RS> rs, sp<const Element> e);
01446 void forEachClear(sp<Allocation> in, sp<Allocation> out);
01452 void forEachSrc(sp<Allocation> in, sp<Allocation> out);
01458 void forEachDst(sp<Allocation> in, sp<Allocation> out);
01464 void forEachSrcOver(sp<Allocation> in, sp<Allocation> out);
01470 void forEachDstOver(sp<Allocation> in, sp<Allocation> out);
01476 void forEachSrcIn(sp<Allocation> in, sp<Allocation> out);
01482 void forEachDstIn(sp<Allocation> in, sp<Allocation> out);
01488 void forEachSrcOut(sp<Allocation> in, sp<Allocation> out);
01494 void forEachDstOut(sp<Allocation> in, sp<Allocation> out);
01500 void forEachSrcAtop(sp<Allocation> in, sp<Allocation> out);
01506 void forEachDstAtop(sp<Allocation> in, sp<Allocation> out);
01512 void forEachXor(sp<Allocation> in, sp<Allocation> out);
01518 void forEachMultiply(sp<Allocation> in, sp<Allocation> out);
01524 void forEachAdd(sp<Allocation> in, sp<Allocation> out);
01530 void forEachSubtract(sp<Allocation> in, sp<Allocation> out);
01531 };
01532
01537 class ScriptIntrinsicBlur : public ScriptIntrinsic {
01538 private:
01539 ScriptIntrinsicBlur(sp<RS> rs, sp<const Element> e);
01540 public:
01547 static sp<ScriptIntrinsicBlur> create(sp<RS> rs, sp<const Element> e);
01552 void setInput(sp<Allocation> in);
01557 void forEach(sp<Allocation> out);
01562 void setRadius(float radius);
01563 };
01564
01572 class ScriptIntrinsicColorMatrix : public ScriptIntrinsic {
01573 private:
01574 ScriptIntrinsicColorMatrix(sp<RS> rs, sp<const Element> e);
01575 public:
01581 static sp<ScriptIntrinsicColorMatrix> create(sp<RS> rs);
01588 void forEach(sp<Allocation> in, sp<Allocation> out);
01594 void setAdd(float* add);
01595
01602 void setColorMatrix3(float* m);
01609 void setColorMatrix4(float* m);
01614 void setGreyscale();
01619 void setRGBtoYUV();
01624 void setYUVtoRGB();
01625 };
01626
01630 class ScriptIntrinsicConvolve3x3 : public ScriptIntrinsic {
01631 private:
01632 ScriptIntrinsicConvolve3x3(sp<RS> rs, sp<const Element> e);
01633 public:
01641 static sp<ScriptIntrinsicConvolve3x3> create(sp<RS> rs, sp<const Element> e);
01646 void setInput(sp<Allocation> in);
01651 void forEach(sp<Allocation> out);
01656 void setCoefficients(float* v);
01657 };
01658
01662 class ScriptIntrinsicConvolve5x5 : public ScriptIntrinsic {
01663 private:
01664 ScriptIntrinsicConvolve5x5(sp<RS> rs, sp<const Element> e);
01665 public:
01673 static sp<ScriptIntrinsicConvolve5x5> create(sp<RS> rs, sp<const Element> e);
01678 void setInput(sp<Allocation> in);
01683 void forEach(sp<Allocation> out);
01688 void setCoefficients(float* v);
01689 };
01690
01694 class ScriptIntrinsicHistogram : public ScriptIntrinsic {
01695 private:
01696 ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e);
01697 sp<Allocation> mOut;
01698 public:
01710 static sp<ScriptIntrinsicHistogram> create(sp<RS> rs);
01717 void setOutput(sp<Allocation> aout);
01729 void setDotCoefficients(float r, float g, float b, float a);
01742 void forEach(sp<Allocation> ain);
01753 void forEach_dot(sp<Allocation> ain);
01754 };
01755
01761 class ScriptIntrinsicLUT : public ScriptIntrinsic {
01762 private:
01763 sp<Allocation> LUT;
01764 bool mDirty;
01765 unsigned char mCache[1024];
01766 void setTable(unsigned int offset, unsigned char base, unsigned int length, unsigned char* lutValues);
01767 ScriptIntrinsicLUT(sp<RS> rs, sp<const Element> e);
01768
01769 public:
01780 static sp<ScriptIntrinsicLUT> create(sp<RS> rs, sp<const Element> e);
01788 void forEach(sp<Allocation> ain, sp<Allocation> aout);
01795 void setRed(unsigned char base, unsigned int length, unsigned char* lutValues);
01802 void setGreen(unsigned char base, unsigned int length, unsigned char* lutValues);
01809 void setBlue(unsigned char base, unsigned int length, unsigned char* lutValues);
01816 void setAlpha(unsigned char base, unsigned int length, unsigned char* lutValues);
01817 virtual ~ScriptIntrinsicLUT();
01818 };
01819
01827 class ScriptIntrinsicYuvToRGB : public ScriptIntrinsic {
01828 private:
01829 ScriptIntrinsicYuvToRGB(sp<RS> rs, sp<const Element> e);
01830 public:
01841 static sp<ScriptIntrinsicYuvToRGB> create(sp<RS> rs, sp<const Element> e);
01847 void setInput(sp<Allocation> in);
01848
01855 void forEach(sp<Allocation> out);
01856
01857 };
01858
01869 class Sampler : public BaseObj {
01870 private:
01871 Sampler(sp<RS> rs, void* id);
01872 RsSamplerValue mMin;
01873 RsSamplerValue mMag;
01874 RsSamplerValue mWrapS;
01875 RsSamplerValue mWrapT;
01876 RsSamplerValue mWrapR;
01877 float mAniso;
01878
01879 public:
01889 static sp<Sampler> create(sp<RS> rs, RsSamplerValue min, RsSamplerValue mag, RsSamplerValue wrapS, RsSamplerValue wrapT, float anisotropy);
01890
01894 RsSamplerValue getMinification();
01898 RsSamplerValue getMagnification();
01902 RsSamplerValue getWrapS();
01906 RsSamplerValue getWrapT();
01910 float getAnisotropy();
01911
01920 sp<const Sampler> CLAMP_NEAREST(sp<RS> rs);
01929 sp<const Sampler> CLAMP_LINEAR(sp<RS> rs);
01938 sp<const Sampler> CLAMP_LINEAR_MIP_LINEAR(sp<RS> rs);
01947 sp<const Sampler> WRAP_NEAREST(sp<RS> rs);
01956 sp<const Sampler> WRAP_LINEAR(sp<RS> rs);
01965 sp<const Sampler> WRAP_LINEAR_MIP_LINEAR(sp<RS> rs);
01974 sp<const Sampler> MIRRORED_REPEAT_NEAREST(sp<RS> rs);
01983 sp<const Sampler> MIRRORED_REPEAT_LINEAR(sp<RS> rs);
01992 sp<const Sampler> MIRRORED_REPEAT_LINEAR_MIP_LINEAR(sp<RS> rs);
01993
01994 };
01995
01996 class Byte2 {
01997 public:
01998 int8_t x, y;
01999
02000 Byte2(int8_t initX, int8_t initY)
02001 : x(initX), y(initY) {}
02002 Byte2() : x(0), y(0) {}
02003 };
02004
02005 class Byte3 {
02006 public:
02007 int8_t x, y, z;
02008
02009 Byte3(int8_t initX, int8_t initY, int8_t initZ)
02010 : x(initX), y(initY), z(initZ) {}
02011 Byte3() : x(0), y(0), z(0) {}
02012 };
02013
02014 class Byte4 {
02015 public:
02016 int8_t x, y, z, w;
02017
02018 Byte4(int8_t initX, int8_t initY, int8_t initZ, int8_t initW)
02019 : x(initX), y(initY), z(initZ), w(initW) {}
02020 Byte4() : x(0), y(0), z(0), w(0) {}
02021 };
02022
02023 class UByte2 {
02024 public:
02025 uint8_t x, y;
02026
02027 UByte2(uint8_t initX, uint8_t initY)
02028 : x(initX), y(initY) {}
02029 UByte2() : x(0), y(0) {}
02030 };
02031
02032 class UByte3 {
02033 public:
02034 uint8_t x, y, z;
02035
02036 UByte3(uint8_t initX, uint8_t initY, uint8_t initZ)
02037 : x(initX), y(initY), z(initZ) {}
02038 UByte3() : x(0), y(0), z(0) {}
02039 };
02040
02041 class UByte4 {
02042 public:
02043 uint8_t x, y, z, w;
02044
02045 UByte4(uint8_t initX, uint8_t initY, uint8_t initZ, uint8_t initW)
02046 : x(initX), y(initY), z(initZ), w(initW) {}
02047 UByte4() : x(0), y(0), z(0), w(0) {}
02048 };
02049
02050 class Short2 {
02051 public:
02052 short x, y;
02053
02054 Short2(short initX, short initY)
02055 : x(initX), y(initY) {}
02056 Short2() : x(0), y(0) {}
02057 };
02058
02059 class Short3 {
02060 public:
02061 short x, y, z;
02062
02063 Short3(short initX, short initY, short initZ)
02064 : x(initX), y(initY), z(initZ) {}
02065 Short3() : x(0), y(0), z(0) {}
02066 };
02067
02068 class Short4 {
02069 public:
02070 short x, y, z, w;
02071
02072 Short4(short initX, short initY, short initZ, short initW)
02073 : x(initX), y(initY), z(initZ), w(initW) {}
02074 Short4() : x(0), y(0), z(0), w(0) {}
02075 };
02076
02077 class UShort2 {
02078 public:
02079 uint16_t x, y;
02080
02081 UShort2(uint16_t initX, uint16_t initY)
02082 : x(initX), y(initY) {}
02083 UShort2() : x(0), y(0) {}
02084 };
02085
02086 class UShort3 {
02087 public:
02088 uint16_t x, y, z;
02089
02090 UShort3(uint16_t initX, uint16_t initY, uint16_t initZ)
02091 : x(initX), y(initY), z(initZ) {}
02092 UShort3() : x(0), y(0), z(0) {}
02093 };
02094
02095 class UShort4 {
02096 public:
02097 uint16_t x, y, z, w;
02098
02099 UShort4(uint16_t initX, uint16_t initY, uint16_t initZ, uint16_t initW)
02100 : x(initX), y(initY), z(initZ), w(initW) {}
02101 UShort4() : x(0), y(0), z(0), w(0) {}
02102 };
02103
02104 class Int2 {
02105 public:
02106 int x, y;
02107
02108 Int2(int initX, int initY)
02109 : x(initX), y(initY) {}
02110 Int2() : x(0), y(0) {}
02111 };
02112
02113 class Int3 {
02114 public:
02115 int x, y, z;
02116
02117 Int3(int initX, int initY, int initZ)
02118 : x(initX), y(initY), z(initZ) {}
02119 Int3() : x(0), y(0), z(0) {}
02120 };
02121
02122 class Int4 {
02123 public:
02124 int x, y, z, w;
02125
02126 Int4(int initX, int initY, int initZ, int initW)
02127 : x(initX), y(initY), z(initZ), w(initW) {}
02128 Int4() : x(0), y(0), z(0), w(0) {}
02129 };
02130
02131 class UInt2 {
02132 public:
02133 uint32_t x, y;
02134
02135 UInt2(uint32_t initX, uint32_t initY)
02136 : x(initX), y(initY) {}
02137 UInt2() : x(0), y(0) {}
02138 };
02139
02140 class UInt3 {
02141 public:
02142 uint32_t x, y, z;
02143
02144 UInt3(uint32_t initX, uint32_t initY, uint32_t initZ)
02145 : x(initX), y(initY), z(initZ) {}
02146 UInt3() : x(0), y(0), z(0) {}
02147 };
02148
02149 class UInt4 {
02150 public:
02151 uint32_t x, y, z, w;
02152
02153 UInt4(uint32_t initX, uint32_t initY, uint32_t initZ, uint32_t initW)
02154 : x(initX), y(initY), z(initZ), w(initW) {}
02155 UInt4() : x(0), y(0), z(0), w(0) {}
02156 };
02157
02158 class Long2 {
02159 public:
02160 int64_t x, y;
02161
02162 Long2(int64_t initX, int64_t initY)
02163 : x(initX), y(initY) {}
02164 Long2() : x(0), y(0) {}
02165 };
02166
02167 class Long3 {
02168 public:
02169 int64_t x, y, z;
02170
02171 Long3(int64_t initX, int64_t initY, int64_t initZ)
02172 : x(initX), y(initY), z(initZ) {}
02173 Long3() : x(0), y(0), z(0) {}
02174 };
02175
02176 class Long4 {
02177 public:
02178 int64_t x, y, z, w;
02179
02180 Long4(int64_t initX, int64_t initY, int64_t initZ, int64_t initW)
02181 : x(initX), y(initY), z(initZ), w(initW) {}
02182 Long4() : x(0), y(0), z(0), w(0) {}
02183 };
02184
02185 class ULong2 {
02186 public:
02187 uint64_t x, y;
02188
02189 ULong2(uint64_t initX, uint64_t initY)
02190 : x(initX), y(initY) {}
02191 ULong2() : x(0), y(0) {}
02192 };
02193
02194 class ULong3 {
02195 public:
02196 uint64_t x, y, z;
02197
02198 ULong3(uint64_t initX, uint64_t initY, uint64_t initZ)
02199 : x(initX), y(initY), z(initZ) {}
02200 ULong3() : x(0), y(0), z(0) {}
02201 };
02202
02203 class ULong4 {
02204 public:
02205 uint64_t x, y, z, w;
02206
02207 ULong4(uint64_t initX, uint64_t initY, uint64_t initZ, uint64_t initW)
02208 : x(initX), y(initY), z(initZ), w(initW) {}
02209 ULong4() : x(0), y(0), z(0), w(0) {}
02210 };
02211
02212 class Float2 {
02213 public:
02214 float x, y;
02215
02216 Float2(float initX, float initY)
02217 : x(initX), y(initY) {}
02218 Float2() : x(0), y(0) {}
02219 };
02220
02221 class Float3 {
02222 public:
02223 float x, y, z;
02224
02225 Float3(float initX, float initY, float initZ)
02226 : x(initX), y(initY), z(initZ) {}
02227 Float3() : x(0.f), y(0.f), z(0.f) {}
02228 };
02229
02230 class Float4 {
02231 public:
02232 float x, y, z, w;
02233
02234 Float4(float initX, float initY, float initZ, float initW)
02235 : x(initX), y(initY), z(initZ), w(initW) {}
02236 Float4() : x(0.f), y(0.f), z(0.f), w(0.f) {}
02237 };
02238
02239 class Double2 {
02240 public:
02241 double x, y;
02242
02243 Double2(double initX, double initY)
02244 : x(initX), y(initY) {}
02245 Double2() : x(0), y(0) {}
02246 };
02247
02248 class Double3 {
02249 public:
02250 double x, y, z;
02251
02252 Double3(double initX, double initY, double initZ)
02253 : x(initX), y(initY), z(initZ) {}
02254 Double3() : x(0), y(0), z(0) {}
02255 };
02256
02257 class Double4 {
02258 public:
02259 double x, y, z, w;
02260
02261 Double4(double initX, double initY, double initZ, double initW)
02262 : x(initX), y(initY), z(initZ), w(initW) {}
02263 Double4() : x(0), y(0), z(0), w(0) {}
02264 };
02265
02266 }
02267
02268 }
02269
02270 #endif