blob: 3e807a30cbd0d64eed80a939ec7fdb7a3e614907 [file] [log] [blame]
Jason Samsc460e552009-11-25 13:22:07 -08001/*
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -07002 * Copyright (C) 2011 The Android Open Source Project
Jason Samsc460e552009-11-25 13:22:07 -08003 *
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
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070017#ifndef ANDROID_RSD_VERTEX_ARRAY_H
18#define ANDROID_RSD_VERTEX_ARRAY_H
Jason Samsc460e552009-11-25 13:22:07 -080019
Jason Samsc460e552009-11-25 13:22:07 -080020namespace android {
21namespace renderscript {
22
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070023class Context;
24
25}
26}
27
28#include <utils/String8.h>
Jason Samsc460e552009-11-25 13:22:07 -080029
30// An element is a group of Components that occupies one cell in a structure.
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070031class RsdVertexArray {
Jason Samsc460e552009-11-25 13:22:07 -080032public:
Jason Sams433eca32010-01-06 11:57:52 -080033 class Attrib {
34 public:
Jason Samsc460e552009-11-25 13:22:07 -080035 uint32_t buffer;
Jason Sams760f1f72010-06-25 12:45:41 -070036 const uint8_t * ptr;
Jason Samsc460e552009-11-25 13:22:07 -080037 uint32_t offset;
38 uint32_t type;
39 uint32_t size;
40 uint32_t stride;
41 bool normalized;
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070042 android::String8 name;
Jason Sams433eca32010-01-06 11:57:52 -080043
44 Attrib();
Jason Sams433eca32010-01-06 11:57:52 -080045 void clear();
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080046 void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
Jason Sams433eca32010-01-06 11:57:52 -080047 };
Jason Samsc460e552009-11-25 13:22:07 -080048
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070049 RsdVertexArray(const Attrib *attribs, uint32_t numAttribs);
50 virtual ~RsdVertexArray();
Jason Samsc460e552009-11-25 13:22:07 -080051
Alex Sakhartchoukc19ff012011-05-06 14:59:45 -070052 void setup(const android::renderscript::Context *rsc) const;
Jason Sams433eca32010-01-06 11:57:52 -080053 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsc460e552009-11-25 13:22:07 -080054
55protected:
Jason Samsbe504f22010-01-25 12:31:24 -080056 void clear(uint32_t index);
Jason Samsc460e552009-11-25 13:22:07 -080057 uint32_t mActiveBuffer;
Jason Sams760f1f72010-06-25 12:45:41 -070058 const uint8_t * mActivePointer;
Jason Samsbe504f22010-01-25 12:31:24 -080059 uint32_t mCount;
60
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080061 const Attrib *mAttribs;
Jason Samsc460e552009-11-25 13:22:07 -080062};
63
64
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070065class RsdVertexArrayState {
Jason Samsc460e552009-11-25 13:22:07 -080066public:
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070067 RsdVertexArrayState();
68 ~RsdVertexArrayState();
69 void init(uint32_t maxAttrs);
Jason Samsc460e552009-11-25 13:22:07 -080070
Alex Sakhartchouk2d791972010-12-13 14:48:21 -080071 bool *mAttrsEnabled;
72 uint32_t mAttrsEnabledSize;
Jason Samsc460e552009-11-25 13:22:07 -080073};
74
75
Alex Sakhartchouka04e30d2011-04-29 16:49:08 -070076#endif //ANDROID_RSD_VERTEX_ARRAY_H
Jason Samsc460e552009-11-25 13:22:07 -080077
78
79