blob: 7c609b26583495ec0b4a1fe7b02b02cf3cfe3bd1 [file] [log] [blame]
Jason Samsbb51c402009-11-25 13:22:07 -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_VERTEX_ARRAY_H
18#define ANDROID_VERTEX_ARRAY_H
19
20
21#include "rsObjectBase.h"
22
23// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
27class ShaderCache;
28
29// An element is a group of Components that occupies one cell in a structure.
30class VertexArray
31{
32public:
33 VertexArray();
34 virtual ~VertexArray();
35
Jason Samsbb51c402009-11-25 13:22:07 -080036
Jason Samsa09a6e12010-01-06 11:57:52 -080037 class Attrib {
38 public:
Jason Samsbb51c402009-11-25 13:22:07 -080039 uint32_t buffer;
Jason Samseeeaccc2010-06-25 12:45:41 -070040 const uint8_t * ptr;
Jason Samsbb51c402009-11-25 13:22:07 -080041 uint32_t offset;
42 uint32_t type;
43 uint32_t size;
44 uint32_t stride;
45 bool normalized;
Jason Samsa09a6e12010-01-06 11:57:52 -080046 String8 name;
47
48 Attrib();
49 void set(const Attrib &);
50 void clear();
51 };
Jason Samsbb51c402009-11-25 13:22:07 -080052
53
54 void clearAll();
Jason Samseeeaccc2010-06-25 12:45:41 -070055 void setActiveBuffer(uint32_t id) {
56 mActiveBuffer = id;
57 mActivePointer = NULL;
58 }
59 void setActiveBuffer(const void *ptr) {
60 mActiveBuffer = 0;
61 mActivePointer = (const uint8_t *)ptr;
62 }
63
Jason Sams8cb39de2010-06-01 15:47:01 -070064 void add(const Attrib &, uint32_t stride);
65 //void addLegacy(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset);
66 void add(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
Jason Samsbb51c402009-11-25 13:22:07 -080067
Jason Sams718cd1f2009-12-23 14:35:29 -080068 void setupGL(const Context *rsc, class VertexArrayState *) const;
69 void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const;
Jason Samsa09a6e12010-01-06 11:57:52 -080070 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsbb51c402009-11-25 13:22:07 -080071
72protected:
Jason Samsdf48b572010-01-25 12:31:24 -080073 void clear(uint32_t index);
Jason Samsbb51c402009-11-25 13:22:07 -080074 uint32_t mActiveBuffer;
Jason Samseeeaccc2010-06-25 12:45:41 -070075 const uint8_t * mActivePointer;
Jason Samsdf48b572010-01-25 12:31:24 -080076 uint32_t mCount;
77
Jason Samsa09a6e12010-01-06 11:57:52 -080078 Attrib mAttribs[RS_MAX_ATTRIBS];
Jason Samsbb51c402009-11-25 13:22:07 -080079};
80
81
82class VertexArrayState {
83public:
84 void init(Context *);
85
Jason Sams5dbfe932010-01-27 14:41:43 -080086 uint32_t mLastEnableCount;
Jason Samsa09a6e12010-01-06 11:57:52 -080087 //VertexArray::Attrib mAttribs[VertexArray::_LAST];
Jason Samsbb51c402009-11-25 13:22:07 -080088};
89
90
91}
92}
93#endif //ANDROID_LIGHT_H
94
95
96