Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_RS_ADAPTER_H |
| 18 | #define ANDROID_RS_ADAPTER_H |
| 19 | |
| 20 | #include "rsAllocation.h" |
| 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 26 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 27 | class Adapter1D : public ObjectBase { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 28 | |
| 29 | public: |
| 30 | // By policy this allocation will hold a pointer to the type |
| 31 | // but will not destroy it on destruction. |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 32 | Adapter1D(Context *); |
| 33 | Adapter1D(Context *, Allocation *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | void reset(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 35 | |
| 36 | void setAllocation(Allocation *a) {mAllocation.set(a);} |
| 37 | |
| 38 | uint32_t getDimX() const {return mAllocation->getType()->getLODDimX(mLOD);} |
| 39 | |
| 40 | const Type * getBaseType() const {return mAllocation->getType();} |
| 41 | |
| 42 | inline void setY(uint32_t y) {mY = y;} |
| 43 | inline void setZ(uint32_t z) {mZ = z;} |
| 44 | inline void setLOD(uint32_t lod) {mLOD = lod;} |
Jason Sams | a6dd823 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 45 | inline void setFace(RsAllocationCubemapFace face) {mFace = face;} |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 46 | |
Jason Sams | a6dd823 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 47 | void data(Context *rsc, uint32_t xoff, uint32_t count, const void *data, size_t sizeBytes); |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 48 | |
Jason Sams | e3150cf | 2012-07-24 18:10:20 -0700 | [diff] [blame] | 49 | virtual void serialize(Context *rsc, OStream *stream) const; |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 50 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ADAPTER_1D; } |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 51 | static Adapter1D *createFromStream(Context *rsc, IStream *stream); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 52 | |
| 53 | protected: |
| 54 | ObjectBaseRef<Allocation> mAllocation; |
| 55 | uint32_t mY; |
| 56 | uint32_t mZ; |
| 57 | uint32_t mLOD; |
Jason Sams | a6dd823 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 58 | RsAllocationCubemapFace mFace; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 61 | class Adapter2D : public ObjectBase { |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 62 | |
| 63 | public: |
| 64 | // By policy this allocation will hold a pointer to the type |
| 65 | // but will not destroy it on destruction. |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 66 | Adapter2D(Context *); |
| 67 | Adapter2D(Context *, Allocation *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 68 | void reset(); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 69 | |
| 70 | uint32_t getDimX() const {return mAllocation->getType()->getLODDimX(mLOD);} |
| 71 | uint32_t getDimY() const {return mAllocation->getType()->getLODDimY(mLOD);} |
| 72 | const Type * getBaseType() const {return mAllocation->getType();} |
| 73 | |
| 74 | void setAllocation(Allocation *a) {mAllocation.set(a);} |
| 75 | inline void setZ(uint32_t z) {mZ = z;} |
| 76 | inline void setLOD(uint32_t lod) {mLOD = lod;} |
Jason Sams | a6dd823 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 77 | inline void setFace(RsAllocationCubemapFace face) {mFace = face;} |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 78 | |
Jason Sams | a6dd823 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 79 | void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, |
| 80 | const void *data, size_t sizeBytes); |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 81 | |
Jason Sams | e3150cf | 2012-07-24 18:10:20 -0700 | [diff] [blame] | 82 | virtual void serialize(Context *rsc, OStream *stream) const; |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 83 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ADAPTER_2D; } |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 84 | static Adapter2D *createFromStream(Context *rsc, IStream *stream); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 85 | |
| 86 | protected: |
| 87 | ObjectBaseRef<Allocation> mAllocation; |
| 88 | uint32_t mZ; |
| 89 | uint32_t mLOD; |
Jason Sams | a6dd823 | 2012-07-25 19:33:43 -0700 | [diff] [blame] | 90 | RsAllocationCubemapFace mFace; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | #endif |
| 96 | |