blob: a7750511454f3969af0cf2fb6153ca95f5835261 [file] [log] [blame]
Jason Samsd01d9702009-12-23 14:35:29 -08001/*
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// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
26
27// An element is a group of Components that occupies one cell in a structure.
28class Component
29{
30public:
31 Component();
32 ~Component();
33
34 void set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize=1);
35
36 uint32_t getGLType() const;
37 uint32_t getGLFormat() const;
Jason Samsb4d35682010-01-04 16:52:27 -080038 String8 getGLSLType() const;
Jason Samsd01d9702009-12-23 14:35:29 -080039 void dumpLOGV(const char *prefix) const;
40
41
42 RsDataType getType() const {return mType;}
43 RsDataKind getKind() const {return mKind;}
44 bool getIsNormalized() const {return mNormalized;}
45 uint32_t getVectorSize() const {return mVectorSize;}
46 bool getIsFloat() const {return mIsFloat;}
47 bool getIsSigned() const {return mIsSigned;}
48 uint32_t getBits() const {return mBits;}
49
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070050 // Helpers for reading / writing this class out
51 void serialize(OStream *stream) const;
52 void loadFromStream(IStream *stream);
53
Jason Samse3929c92010-08-09 18:13:33 -070054 bool isReference() const;
55
Jason Samsd01d9702009-12-23 14:35:29 -080056protected:
57 RsDataType mType;
58 RsDataKind mKind;
59 bool mNormalized;
60 uint32_t mVectorSize;
61
62 // derived
63 uint32_t mBits;
64 uint32_t mTypeBits;
65 bool mIsFloat;
66 bool mIsSigned;
67 bool mIsPixel;
68};
69
70}
71}
72
73#endif
74