blob: 2434977dbc2a9bb42ca3a5317759577b1c08b76e [file] [log] [blame]
Jason Samsd19f10d2009-05-22 14:03:28 -07001/*
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_STRUCTURED_ELEMENT_H
18#define ANDROID_STRUCTURED_ELEMENT_H
19
20#include <utils/Vector.h>
21
22#include "rsComponent.h"
23
24// ---------------------------------------------------------------------------
25namespace android {
26namespace renderscript {
27
28
29// An element is a group of Components that occupies one cell in a structure.
30class Element : public ObjectBase
31{
32public:
33 Element(uint32_t count);
34 ~Element();
35
36
37 void setComponent(uint32_t idx, Component *c);
38
Jason Samse2ae85f2009-06-03 16:04:54 -070039 uint32_t getGLType() const;
40 uint32_t getGLFormat() const;
Jason Samsd19f10d2009-05-22 14:03:28 -070041
42
43 size_t getSizeBits() const;
44 size_t getSizeBytes() const {
45 return (getSizeBits() + 7) >> 3;
46 }
47
48 size_t getComponentOffsetBits(uint32_t componentNumber) const;
49 size_t getComponentOffsetBytes(uint32_t componentNumber) const {
50 return (getComponentOffsetBits(componentNumber) + 7) >> 3;
51 }
52
53 uint32_t getComponentCount() const {return mComponentCount;}
54 Component * getComponent(uint32_t idx) const {return mComponents[idx].get();}
55
56protected:
57 // deallocate any components that are part of this element.
58 void clear();
59
60 size_t mComponentCount;
61 ObjectBaseRef<Component> * mComponents;
62 //uint32_t *mOffsetTable;
63
64 Element();
65};
66
67
68class ElementState {
69public:
70 ElementState();
71 ~ElementState();
72
73 Vector<Element *> mAllElements;
74 Vector<Component *> mComponentBuildList;
75
76
77
78 struct Predefined {
79 Predefined() {
80 mElement = NULL;
81 }
82 Predefined(RsElementPredefined en, Element *e) {
83 mEnum = en;
84 mElement = e;
85 }
86 RsElementPredefined mEnum;
87 Element * mElement;
88 };
89 Vector<Predefined> mPredefinedList;
90
91 void initPredefined();
92
93};
94
95
96}
97}
98#endif //ANDROID_STRUCTURED_ELEMENT_H