From 33d67109d442ad803e3b40697ab58fe153e4e4ff Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Fri, 9 Jun 2017 14:15:02 +0100 Subject: [PATCH] [3.0] Fix for texture Upload() * When a full texture is loaded in a GLES3.x context and the pixel data format is RGB and the internal format is RGBA, it needs to be converted to RGBA. Change-Id: Idcd3635d2d1bd378b9ffe96266c4fb8ced5e4087 Signed-off-by: Victor Cebollada --- dali/internal/render/renderers/render-texture.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp index 9025a31..689d53b 100644 --- a/dali/internal/render/renderers/render-texture.cpp +++ b/dali/internal/render/renderers/render-texture.cpp @@ -737,11 +737,20 @@ void NewTexture::Upload( Context& context, PixelDataPtr pixelData, const Interna //necessary to upload all the mipmap levels mMaxMipMapLevel = ( mMaxMipMapLevel > params.mipmap ) ? mMaxMipMapLevel : params.mipmap; -#if DALI_GLES_VERSION < 30 - if( pixelDataFormat == GL_RGB && mInternalFormat == GL_RGBA ) + const bool isSubImage = ( ( params.xOffset != 0 ) || + ( params.yOffset != 0 ) || + ( params.width != ( mWidth / ( 1 << params.mipmap ) ) ) || + ( params.height != ( mHeight / ( 1 << params.mipmap ) ) ) ); + + bool convert = ( ( pixelDataFormat == GL_RGB ) && ( mInternalFormat == GL_RGBA ) ); +#if DALI_GLES_VERSION >= 30 + // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded. + convert = convert && !isSubImage; +#endif + + if( convert ) { - //Convert manually from RGB to RGBA if GLES < 3 ( GLES 3 can do the conversion automatically when uploading ) - size_t dataSize = params.width * params.height; + size_t dataSize = static_cast< size_t >( params.width ) * params.height; tempBuffer = new unsigned char[dataSize*4u]; for( size_t i(0u); i