• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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_VERTEX_ARRAY_H
18 #define ANDROID_VERTEX_ARRAY_H
19 
20 
21 #include "rsObjectBase.h"
22 
23 // ---------------------------------------------------------------------------
24 namespace android {
25 namespace renderscript {
26 
27 class ShaderCache;
28 
29 // An element is a group of Components that occupies one cell in a structure.
30 class VertexArray
31 {
32 public:
33     VertexArray();
34     virtual ~VertexArray();
35 
36 
37     class Attrib {
38     public:
39         uint32_t buffer;
40         uint32_t offset;
41         uint32_t type;
42         uint32_t size;
43         uint32_t stride;
44         bool normalized;
45         String8 name;
46         RsDataKind kind;
47 
48         Attrib();
49         void set(const Attrib &);
50         void clear();
51     };
52 
53 
54     void clearAll();
setActiveBuffer(uint32_t id)55     void setActiveBuffer(uint32_t id) {mActiveBuffer = id;}
56     void addUser(const Attrib &, uint32_t stride);
57     void addLegacy(uint32_t type, uint32_t size, uint32_t stride, RsDataKind kind, bool normalized, uint32_t offset);
58 
59     void setupGL(const Context *rsc, class VertexArrayState *) const;
60     void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const;
61     void logAttrib(uint32_t idx, uint32_t slot) const;
62 
63 protected:
64     void clear(uint32_t index);
65     uint32_t mActiveBuffer;
66     uint32_t mCount;
67 
68     Attrib mAttribs[RS_MAX_ATTRIBS];
69 };
70 
71 
72 class VertexArrayState {
73 public:
74     void init(Context *);
75 
76     uint32_t mLastEnableCount;
77     //VertexArray::Attrib mAttribs[VertexArray::_LAST];
78 };
79 
80 
81 }
82 }
83 #endif //ANDROID_LIGHT_H
84 
85 
86 
87