blob: 8629d0d9d6b9a012d857a1a78e9605113e0d6896 [file] [log] [blame]
Jason Sams718cd1f2009-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.
Alex Sakhartchouked9f2102010-11-09 17:00:54 -080028class Component {
Jason Sams718cd1f2009-12-23 14:35:29 -080029public:
30 Component();
31 ~Component();
32
33 void set(RsDataType dt, RsDataKind dk, bool norm, uint32_t vecSize=1);
34
Jason Sams718cd1f2009-12-23 14:35:29 -080035 void dumpLOGV(const char *prefix) const;
36
Jason Sams718cd1f2009-12-23 14:35:29 -080037 RsDataType getType() const {return mType;}
38 RsDataKind getKind() const {return mKind;}
39 bool getIsNormalized() const {return mNormalized;}
40 uint32_t getVectorSize() const {return mVectorSize;}
41 bool getIsFloat() const {return mIsFloat;}
42 bool getIsSigned() const {return mIsSigned;}
43 uint32_t getBits() const {return mBits;}
Alex Sakhartchouke60149d2011-11-15 15:15:21 -080044 uint32_t getBitsUnpadded() const {return mBitsUnpadded;}
Jason Sams718cd1f2009-12-23 14:35:29 -080045
Alex Sakhartchoukaa7d2882010-05-21 12:53:13 -070046 // Helpers for reading / writing this class out
47 void serialize(OStream *stream) const;
48 void loadFromStream(IStream *stream);
49
Jason Samsb28ca96f2010-08-09 18:13:33 -070050 bool isReference() const;
51
Jason Sams718cd1f2009-12-23 14:35:29 -080052protected:
53 RsDataType mType;
54 RsDataKind mKind;
55 bool mNormalized;
56 uint32_t mVectorSize;
57
58 // derived
59 uint32_t mBits;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -080060 uint32_t mBitsUnpadded;
Jason Sams718cd1f2009-12-23 14:35:29 -080061 uint32_t mTypeBits;
62 bool mIsFloat;
63 bool mIsSigned;
64 bool mIsPixel;
65};
66
67}
68}
69
70#endif
71