1 /*
2  * Copyright (C) 2011 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_RSD_VERTEX_ARRAY_H
18 #define ANDROID_RSD_VERTEX_ARRAY_H
19 
20 #include "rsUtils.h"
21 
22 namespace android {
23 namespace renderscript {
24 
25 class Context;
26 
27 }
28 }
29 
30 // An element is a group of Components that occupies one cell in a structure.
31 class RsdVertexArray {
32 public:
33     class Attrib {
34     public:
35         uint32_t buffer;
36         const uint8_t * ptr;
37         size_t offset;
38         uint32_t type;
39         uint32_t size;
40         uint32_t stride;
41         bool normalized;
42         android::String8 name;
43 
44         Attrib();
45         void clear();
46         void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, size_t offset, const char *name);
47     };
48 
49     RsdVertexArray(const Attrib *attribs, uint32_t numAttribs);
50     virtual ~RsdVertexArray();
51 
52     void setup(const android::renderscript::Context *rsc) const;
53     void logAttrib(uint32_t idx, uint32_t slot) const;
54 
55 protected:
56     void clear(uint32_t index);
57     uint32_t mActiveBuffer;
58     const uint8_t * mActivePointer;
59     uint32_t mCount;
60 
61     const Attrib *mAttribs;
62 };
63 
64 
65 class RsdVertexArrayState {
66 public:
67     RsdVertexArrayState();
68     ~RsdVertexArrayState();
69     void init(uint32_t maxAttrs);
70 
71     bool *mAttrsEnabled;
72     uint32_t mAttrsEnabledSize;
73 };
74 
75 
76 #endif //ANDROID_RSD_VERTEX_ARRAY_H
77 
78 
79 
80