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