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 #ifndef _GL_DECODER_CONTEXT_DATA_H_ 17 #define _GL_DECODER_CONTEXT_DATA_H_ 18 19 #include <assert.h> 20 #include <string.h> 21 #include "FixedBuffer.h" 22 #include "codec_defs.h" 23 24 class GLDecoderContextData { 25 public: 26 typedef enum { 27 VERTEX_LOCATION = 0, 28 NORMAL_LOCATION = 1, 29 COLOR_LOCATION = 2, 30 POINTSIZE_LOCATION = 3, 31 TEXCOORD0_LOCATION = 4, 32 TEXCOORD1_LOCATION = 5, 33 TEXCOORD2_LOCATION = 6, 34 TEXCOORD3_LOCATION = 7, 35 TEXCOORD4_LOCATION = 8, 36 TEXCOORD5_LOCATION = 9, 37 TEXCOORD6_LOCATION = 10, 38 TEXCOORD7_LOCATION = 11, 39 MATRIXINDEX_LOCATION = 12, 40 WEIGHT_LOCATION = 13, 41 LAST_LOCATION = 14 42 } PointerDataLocation; 43 44 GLDecoderContextData(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES) : 45 m_nLocations(nLocations) 46 { 47 m_pointerData = new FixedBuffer[m_nLocations]; 48 } 49 50 ~GLDecoderContextData() { 51 delete [] m_pointerData; 52 } 53 54 void storePointerData(unsigned int loc, void *data, size_t len) { 55 56 assert(loc < m_nLocations); 57 m_pointerData[loc].alloc(len); 58 memcpy(m_pointerData[loc].ptr(), data, len); 59 } 60 void *pointerData(unsigned int loc) { 61 assert(loc < m_nLocations); 62 return m_pointerData[loc].ptr(); 63 } 64 private: 65 FixedBuffer *m_pointerData; 66 int m_nLocations; 67 }; 68 69 #endif 70