blob: 7852ffcb33efe0887e1c1f8205fa19640451f7ee [file] [log] [blame]
Jason Sams326e0dd2009-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
39
40
41 size_t getSizeBits() const;
42 size_t getSizeBytes() const {
43 return (getSizeBits() + 7) >> 3;
44 }
45
46 size_t getComponentOffsetBits(uint32_t componentNumber) const;
47 size_t getComponentOffsetBytes(uint32_t componentNumber) const {
48 return (getComponentOffsetBits(componentNumber) + 7) >> 3;
49 }
50
51 uint32_t getComponentCount() const {return mComponentCount;}
52 Component * getComponent(uint32_t idx) const {return mComponents[idx].get();}
53
54protected:
55 // deallocate any components that are part of this element.
56 void clear();
57
58 size_t mComponentCount;
59 ObjectBaseRef<Component> * mComponents;
60 //uint32_t *mOffsetTable;
61
62 Element();
63};
64
65
66class ElementState {
67public:
68 ElementState();
69 ~ElementState();
70
71 Vector<Element *> mAllElements;
72 Vector<Component *> mComponentBuildList;
73
74
75
76 struct Predefined {
77 Predefined() {
78 mElement = NULL;
79 }
80 Predefined(RsElementPredefined en, Element *e) {
81 mEnum = en;
82 mElement = e;
83 }
84 RsElementPredefined mEnum;
85 Element * mElement;
86 };
87 Vector<Predefined> mPredefinedList;
88
89 void initPredefined();
90
91};
92
93
94}
95}
96#endif //ANDROID_STRUCTURED_ELEMENT_H