From 68367ae969fc78d948d6ee02c54b9afd78ffad29 Mon Sep 17 00:00:00 2001 From: Jacky Romano Date: Wed, 13 Apr 2011 10:03:53 +0300 Subject: [PATCH] emulator Opengl - number of supported vertex attributes make the number of suppoted vertex attributes (by the codec) common across the encoder and the decoder. Change-Id: I699ef62821566cec0764982872adb92ebb8861e9 --- .../shared/OpenglCodecCommon/FixedBuffer.h | 6 ++---- .../shared/OpenglCodecCommon/GLClientState.h | 3 ++- .../OpenglCodecCommon/GLDecoderContextData.h | 20 +++++++++++++++---- .../shared/OpenglCodecCommon/codec_defs.h | 2 ++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h b/tools/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h index 78fa244fd..7b8223d40 100644 --- a/tools/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/FixedBuffer.h @@ -25,10 +25,8 @@ public: } ~FixedBuffer() { - if (m_buffer != NULL) { - delete m_buffer; - m_bufferLen = 0; - } + delete m_buffer; + m_bufferLen = 0; } void * alloc(size_t size) { diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h index 2126241a7..9e4c9160c 100644 --- a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h @@ -30,6 +30,7 @@ #include #include #include "ErrorLog.h" +#include "codec_defs.h" class GLClientState { public: @@ -70,7 +71,7 @@ public: } PixelStoreState; public: - GLClientState(int nLocations = 32); + GLClientState(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES); ~GLClientState(); int nLocations() { return m_nLocations; } const PixelStoreState *pixelStoreState() { return &m_pixelStore; } diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h index eeb473432..2700554f2 100644 --- a/tools/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h @@ -19,6 +19,7 @@ #include #include #include "FixedBuffer.h" +#include "codec_defs.h" class GLDecoderContextData { public: @@ -40,18 +41,29 @@ public: LAST_LOCATION = 14 } PointerDataLocation; - void storePointerData(PointerDataLocation loc, void *data, size_t len) { - assert(loc < LAST_LOCATION); + GLDecoderContextData(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES) : + m_nLocations(nLocations) + { + m_pointerData = new FixedBuffer(m_nLocations); + } + ~GLDecoderContextData() { + delete m_pointerData; + } + + void storePointerData(PointerDataLocation loc, void *data, size_t len) { + + assert(loc < m_nLocations); m_pointerData[loc].alloc(len); memcpy(m_pointerData[loc].ptr(), data, len); } void *pointerData(PointerDataLocation loc) { - assert(loc < LAST_LOCATION); + assert(loc < m_nLocations); return m_pointerData[loc].ptr(); } private: - FixedBuffer m_pointerData[LAST_LOCATION]; + FixedBuffer *m_pointerData; + int m_nLocations; }; #endif diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h b/tools/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h index 968ea3fdc..f19f51414 100644 --- a/tools/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/codec_defs.h @@ -18,4 +18,6 @@ #define CODEC_SERVER_PORT 22468 +#define CODEC_MAX_VERTEX_ATTRIBUTES 64 + #endif