Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [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_COMPONENT_H |
| 18 | #define ANDROID_COMPONENT_H |
| 19 | |
| 20 | #include "rsUtils.h" |
| 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
| 26 | |
| 27 | // An element is a group of Components that occupies one cell in a structure. |
Alex Sakhartchouk | ed9f210 | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 28 | class Component { |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 29 | public: |
| 30 | Component(); |
| 31 | ~Component(); |
| 32 | |
| 33 | void set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize=1); |
| 34 | |
| 35 | uint32_t getGLType() const; |
| 36 | uint32_t getGLFormat() const; |
Jason Sams | e17964e | 2010-01-04 16:52:27 -0800 | [diff] [blame] | 37 | String8 getGLSLType() const; |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 38 | void dumpLOGV(const char *prefix) const; |
| 39 | |
| 40 | |
| 41 | RsDataType getType() const {return mType;} |
| 42 | RsDataKind getKind() const {return mKind;} |
| 43 | bool getIsNormalized() const {return mNormalized;} |
| 44 | uint32_t getVectorSize() const {return mVectorSize;} |
| 45 | bool getIsFloat() const {return mIsFloat;} |
| 46 | bool getIsSigned() const {return mIsSigned;} |
| 47 | uint32_t getBits() const {return mBits;} |
| 48 | |
Alex Sakhartchouk | aa7d288 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 49 | // Helpers for reading / writing this class out |
| 50 | void serialize(OStream *stream) const; |
| 51 | void loadFromStream(IStream *stream); |
| 52 | |
Jason Sams | b28ca96f | 2010-08-09 18:13:33 -0700 | [diff] [blame] | 53 | bool isReference() const; |
| 54 | |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 55 | protected: |
| 56 | RsDataType mType; |
| 57 | RsDataKind mKind; |
| 58 | bool mNormalized; |
| 59 | uint32_t mVectorSize; |
| 60 | |
| 61 | // derived |
| 62 | uint32_t mBits; |
| 63 | uint32_t mTypeBits; |
| 64 | bool mIsFloat; |
| 65 | bool mIsSigned; |
| 66 | bool mIsPixel; |
| 67 | }; |
| 68 | |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | #endif |
| 73 | |