diff options
| author | Guy Zadikario <guy@graphtech.co.il> | 2011-04-10 10:31:14 +0300 |
|---|---|---|
| committer | Guy Zadikario <guy@graphtech.co.il> | 2011-04-13 13:33:26 +0300 |
| commit | fc2d0b09ececb6316cf054264e58c8f453737cfb (patch) | |
| tree | 190c137db95002ec723c507ca6465dae1407861e /tools/emulator/opengl/shared/OpenglCodecCommon | |
| parent | caafd4df2e0443e0c20dc405b1bfe3e947df36f8 (diff) | |
emulator opengl: Added glUtilsPixelBitSize function to glUtils.
moved pixel size calculation from GLClientState to glUtils to be used
outside the client state scope. (needed for the renderControl encoder
which will follow in next commit).
Change-Id: I5adbc40b241537054c6743e2afc52ba44454664f
Diffstat (limited to 'tools/emulator/opengl/shared/OpenglCodecCommon')
3 files changed, 58 insertions, 50 deletions
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp index 7fc506821..9c70fc16c 100644 --- a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp @@ -164,56 +164,7 @@ int GLClientState::setPixelStore(GLenum param, GLint value) size_t GLClientState::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) { - - int components = 0; - int componentsize = 0; - int pixelsize = 0; - switch(type) { - case GL_UNSIGNED_BYTE: - componentsize = 1; - break; - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - pixelsize = 2; - break; - default: - ERR("pixelDataSize: unknown pixel type - assuming pixel data 0\n"); - componentsize = 0; - } - - if (pixelsize == 0) { - switch(format) { -#if 0 - case GL_RED: - case GL_GREEN: - case GL_BLUE: -#endif - case GL_ALPHA: - case GL_LUMINANCE: - components = 1; - break; - case GL_LUMINANCE_ALPHA: - components = 2; - break; - case GL_RGB: -#if 0 - case GL_BGR: -#endif - components = 3; - break; - case GL_RGBA: -#if 0 - case GL_BGRA: -#endif - components = 4; - break; - default: - ERR("pixelDataSize: unknown pixel format...\n"); - components = 0; - } - pixelsize = components * componentsize; - } + int pixelsize = glUtilsPixelBitSize(format, type) >> 3; int alignment = pack ? m_pixelStore.pack_alignment : m_pixelStore.unpack_alignment; diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp index ad4888a9b..645d08fb3 100644 --- a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.cpp @@ -145,3 +145,59 @@ void glUtilsPackPointerData(unsigned char *dst, unsigned char *src, } } } + +int glUtilsPixelBitSize(GLenum format, GLenum type) +{ + int components = 0; + int componentsize = 0; + int pixelsize = 0; + switch(type) { + case GL_UNSIGNED_BYTE: + componentsize = 8; + break; + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_RGB565_OES: + case GL_RGB5_A1_OES: + case GL_RGBA4_OES: + pixelsize = 16; + break; + default: + ERR("glUtilsPixelBitSize: unknown pixel type - assuming pixel data 0\n"); + componentsize = 0; + } + + if (pixelsize == 0) { + switch(format) { +#if 0 + case GL_RED: + case GL_GREEN: + case GL_BLUE: +#endif + case GL_ALPHA: + case GL_LUMINANCE: + components = 1; + break; + case GL_LUMINANCE_ALPHA: + components = 2; + break; + case GL_RGB: +#if 0 + case GL_BGR: +#endif + components = 3; + break; + case GL_RGBA: + case GL_BGRA_EXT: + components = 4; + break; + default: + ERR("glUtilsPixelBitSize: unknown pixel format...\n"); + components = 0; + } + pixelsize = components * componentsize; + } + + return pixelsize; +} diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.h b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.h index 96b29d660..35964066a 100644 --- a/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.h +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/glUtils.h @@ -49,6 +49,7 @@ extern "C" { void glUtilsPackPointerData(unsigned char *dst, unsigned char *str, int size, GLenum type, unsigned int stride, unsigned int datalen); + int glUtilsPixelBitSize(GLenum format, GLenum type); #ifdef __cplusplus }; #endif |
