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_MESH_OBJ_H
18 #define ANDROID_RSD_MESH_OBJ_H
19 
20 // ---------------------------------------------------------------------------
21 namespace android {
22 namespace renderscript {
23 
24     class Context;
25     class Mesh;
26     class Element;
27 
28 }
29 }
30 
31 #include "driver/rsdVertexArray.h"
32 
33 // An element is a group of Components that occupies one cell in a structure.
34 class RsdMeshObj {
35 public:
36     RsdMeshObj(const android::renderscript::Context *,
37             const android::renderscript::Mesh *);
38     ~RsdMeshObj();
39 
40     void renderPrimitiveRange(const android::renderscript::Context *,
41                               uint32_t primIndex, size_t start, uint32_t len) const;
42 
43     bool init(const android::renderscript::Context *rsc);
44 
45 protected:
46     const android::renderscript::Mesh *mRSMesh;
47 
48     uint32_t *mGLPrimitives;
49     void updateGLPrimitives(const android::renderscript::Context *rsc);
50 
51     bool isValidGLComponent(const android::renderscript::Element *elem, uint32_t fieldIdx);
52     // Attribues that allow us to map to GL
53     RsdVertexArray::Attrib *mAttribs;
54     // This allows us to figure out which allocation the attribute
55     // belongs to. In the event the allocation is uploaded to GL
56     // buffer, it lets us properly map it
57     uint32_t *mAttribAllocationIndex;
58     uint32_t mAttribCount;
59 };
60 
61 #endif //ANDROID_RSD_MESH_OBJ_H
62 
63 
64 
65