2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 // Convenient class used to hold the common context data shared
25 // by both the GLESv1 and GLESv2 decoders. This corresponds to
26 // vertex attribute buffers.
27 class GLDecoderContextData {
29 // List of supported vertex attribute indices, as they appear in
30 // a glVertexAttribPointer() call.
35 POINTSIZE_LOCATION = 3,
36 TEXCOORD0_LOCATION = 4,
37 TEXCOORD1_LOCATION = 5,
38 TEXCOORD2_LOCATION = 6,
39 TEXCOORD3_LOCATION = 7,
40 TEXCOORD4_LOCATION = 8,
41 TEXCOORD5_LOCATION = 9,
42 TEXCOORD6_LOCATION = 10,
43 TEXCOORD7_LOCATION = 11,
44 MATRIXINDEX_LOCATION = 12,
47 } PointerDataLocation;
49 // Default constructor.
50 GLDecoderContextData(int numLocations = kMaxVertexAttributes)
52 mNumLocations(static_cast<unsigned>(numLocations)) {
53 mPointerData.resize(mNumLocations);
56 // Store |len| bytes from |data| into the buffer associated with
57 // vertex attribute index |loc|.
58 void storePointerData(unsigned int loc, void *data, size_t len) {
59 if (loc < mNumLocations) {
60 std::string& ptrData = mPointerData[loc];
61 ptrData.assign(reinterpret_cast<char*>(data), len);
63 // User error, don't do anything here
67 // Return pointer to data associated with vertex attribute index |loc|
68 void* pointerData(unsigned int loc) const {
69 if (loc < mNumLocations) {
70 return const_cast<char*>(mPointerData[loc].c_str());
72 // User error. Return nullptr.
78 static const int kMaxVertexAttributes = 64;
80 std::vector<std::string> mPointerData;
81 unsigned mNumLocations = 0;