From: Seungho, Baek Date: Fri, 8 Mar 2019 06:08:36 +0000 (+0900) Subject: Convert texture's gl format (from dali-core). X-Git-Tag: dali_1.4.11~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F201077%2F7;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Convert texture's gl format (from dali-core). - ConvertTexture function in gl-implementation. - To remove dali-core's dependency of OpenGL es version. Change-Id: I25a2f7035b92fa39e068125e207c81fe31a8e1f4 Signed-off-by: Seungho, Baek --- diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp index 02439bc..44c6a33 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -104,6 +104,10 @@ void TestGlAbstraction::PostRender() { } +void TestGlAbstraction::ConvertTexture( uint8_t* buffer, GLenum& imageGlFormat, const uint32_t dataSize, const GLenum textureGlFormat, const bool isSubImage ) +{ +} + } // Namespace dali bool BlendEnabled(const Dali::TraceCallStack& callStack) diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h index c68573b..c69e4e3 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-gl-abstraction.h @@ -2,7 +2,7 @@ #define TEST_GL_ABSTRACTION_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,8 @@ public: void PreRender(); void PostRender(); + void ConvertTexture( uint8_t* buffer, GLenum& imageGlFormat, const uint32_t dataSize, const GLenum textureGlFormat, const bool isSubImage ); + /* OpenGL ES 2.0 */ inline void ActiveTexture( GLenum textureUnit ) diff --git a/dali/internal/graphics/gles/gl-implementation.h b/dali/internal/graphics/gles/gl-implementation.h index b1ce82d..1c12bd2 100644 --- a/dali/internal/graphics/gles/gl-implementation.h +++ b/dali/internal/graphics/gles/gl-implementation.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_GL_IMPLEMENTATION_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,35 @@ public: /* Do nothing in main implementation */ } + void ConvertTexture( uint8_t* buffer, GLenum& imageGlFormat, const uint32_t dataSize, const GLenum textureGlFormat, const bool isSubImage ) + { + bool convert = ( ( imageGlFormat == GL_RGB ) && ( textureGlFormat == 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 // DALI_GLES_VERSION >= 30 + + if( convert ) + { + //This buffer is only used if manually converting from RGB to RGBA + uint8_t* tempBuffer(0); + + tempBuffer = new uint8_t[dataSize*4u]; + for( uint32_t i = 0u; i < dataSize; ++i ) + { + tempBuffer[i*4u] = buffer[i*3u]; + tempBuffer[i*4u+1] = buffer[i*3u+1]; + tempBuffer[i*4u+2] = buffer[i*3u+2]; + tempBuffer[i*4u+3] = 0xFF; + } + buffer = tempBuffer; + imageGlFormat = textureGlFormat; // Set the glFormat to GL_RGBA + + //Destroy temp buffer used for conversion RGB->RGBA + delete[] tempBuffer; + } + } + /* OpenGL ES 2.0 */ void ActiveTexture (GLenum texture)