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
20namespace android {
21namespace renderscript {
22
23class Context;
24
25}
26}
27
28#include <utils/String8.h>
29
30// An element is a group of Components that occupies one cell in a structure.
31class RsdVertexArray {
32public:
33    class Attrib {
34    public:
35        uint32_t buffer;
36        const uint8_t * ptr;
37        uint32_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, uint32_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
55protected:
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
65class RsdVertexArrayState {
66public:
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