From 21b8fb0307cd72d9c5e7c8599e2d2fb1a6989611 Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Fri, 15 Mar 2019 14:01:26 +0000 Subject: [PATCH] Revert "Remove dependency of OpenGL es version." This reverts commit 9d38b085d8a186cc7980a6f854492591353ddfe5. Change-Id: Iec561d896c2f731912b66934225153bdf2fec076 --- .travis.yml | 2 +- README.md | 15 +++++++++ .../dali-test-suite-utils/test-gl-abstraction.cpp | 6 +--- .../dali-test-suite-utils/test-gl-abstraction.h | 4 +-- build/tizen-cmake/CMakeLists.txt | 2 ++ build/tizen/configure.ac | 9 ++++++ dali/integration-api/gl-abstraction.h | 11 +------ dali/internal/render/common/render-manager.cpp | 3 +- dali/internal/render/gl-resources/context.h | 10 +----- dali/internal/render/renderers/render-texture.cpp | 36 ++++++++++++++++++++-- packaging/dali.spec | 5 +++ 11 files changed, 71 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04f43d6..9fcfc79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ script: - autoreconf --install - export CXXFLAGS="--coverage " - export LD_LIBRARY_PATH=/usr/local/lib - - ./configure --enable-profile=UBUNTU --enable-debug + - ./configure --enable-profile=UBUNTU --enable-gles=20 --enable-debug - make -j7 - sudo make install - popd diff --git a/README.md b/README.md index b374d3a..98db879 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,21 @@ Then run the following commands: $ ./configure --prefix=$DESKTOP_PREFIX $ make install -j8 +### Build target options + +OpenGL ES context: + +When building, the OpenGL ES version of the target should be specified. + +Valid version options are 20, 30, 31 + +With configure: +Add: *--enable-gles=X* + +With gbs: +Add to the gbs build line: *--define "%target_gles_version X"* + + ### Building and executing test cases See the README.md in dali-core/automated-tests. diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp index 44c6a33..02439bc 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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,10 +104,6 @@ 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/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h index c69e4e3..c68573b 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h @@ -2,7 +2,7 @@ #define TEST_GL_ABSTRACTION_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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,8 +59,6 @@ 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/build/tizen-cmake/CMakeLists.txt b/build/tizen-cmake/CMakeLists.txt index 8faa8a1..baf23b0 100644 --- a/build/tizen-cmake/CMakeLists.txt +++ b/build/tizen-cmake/CMakeLists.txt @@ -21,10 +21,12 @@ OPTION(ENABLE_DEBUG "Enable Debug" OFF) OPTION(ENABLE_BACKTRACE "Enable Backtrace" OFF) OPTION(ENABLE_LOCK_BACKTRACE "Enable" OFF) OPTION(ENABLE_COVERAGE "Coverage" OFF) +SET(GLES_VERSION 20 CACHE INTEGER "Gles Version") # Set up compiler definitions ADD_DEFINITIONS(-DPLATFORM_TIZEN -DDALI_COMPILATION) +ADD_DEFINITIONS(-DDALI_GLES_VERSION=${GLES_VERSION}) ADD_DEFINITIONS(-DPIC -DSTDC_HEADERS) IF("${ARCH}" STREQUAL "arm") diff --git a/build/tizen/configure.ac b/build/tizen/configure.ac index 4082251..75b5615 100644 --- a/build/tizen/configure.ac +++ b/build/tizen/configure.ac @@ -57,6 +57,12 @@ AC_ARG_ENABLE([lock_backtrace], [enable_lock_backtrace=$enableval], [enable_lock_backtrace=no]) +AC_ARG_ENABLE([gles], + [AC_HELP_STRING([--enable-gles], + [Specify the OpenGL ES version for backwards compatibility])], + [enable_gles=$enableval], + [enable_gles=30]) + AC_ARG_ENABLE([cxx03_abi], [AC_HELP_STRING([--enable-cxx03-abi], [Specify abi for the build])], @@ -76,6 +82,8 @@ if test "x$enable_cxx03_abi" = "xyes"; then DALI_CFLAGS="$DALI_CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0" fi +DALI_CFLAGS="$DALI_CFLAGS -DDALI_GLES_VERSION=${enable_gles}" + if test "x$enable_debug" = "xyes"; then DALI_CFLAGS="$DALI_CFLAGS -DDEBUG_ENABLED" fi @@ -144,6 +152,7 @@ Configuration Data Dir (Read Only): $dataReadOnlyDir Backtrace: $enable_backtrace ScopedLock Backtrace: $enable_lock_backtrace + OpenGL ES version: $enable_gles C++03 ABI: $enable_cxx03_abi Rename so file: $enable_rename_so " diff --git a/dali/integration-api/gl-abstraction.h b/dali/integration-api/gl-abstraction.h index d8cda34..a5d81f3 100644 --- a/dali/integration-api/gl-abstraction.h +++ b/dali/integration-api/gl-abstraction.h @@ -2,7 +2,7 @@ #define __DALI_INTEGRATION_GL_ABSTRACTION_H__ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2014 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. @@ -116,15 +116,6 @@ public: virtual void PostRender() = 0; /** - * Determine whether to convert pixel format or not. - * @param[in] imageGlFormat GLformat of input image. - * @param[in] textureGlFormat GLformat of Texture. - * @param[in] isSubImage Boolian value for the whether the image is subimage or not - * @return Whether the texture will be convert or not. - */ - virtual void ConvertTexture( uint8_t* buffer, GLenum& imageGlFormat, const uint32_t dataSize, const GLenum textureGlFormat, const bool isSubImage ) = 0; - - /** * The number of texture units an implementation supports is implementation dependent, but must be at least 8. */ static const unsigned int MIN_TEXTURE_UNIT_LIMIT = 8; diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 7886686..a69d02f 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -561,7 +561,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) { surfaceFrameBuffer = static_cast( instruction.mFrameBuffer ); - // For the Multi-Windows +#if DALI_GLES_VERSION >= 30 Context* surfaceContext = surfaceFrameBuffer->GetContext(); if ( mImpl->currentContext != surfaceContext ) { @@ -570,6 +570,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) // Clear the current cached program when the context is switched mImpl->programController.ClearCurrentProgram(); } +#endif surfaceRect = Rect( 0, 0, static_cast( surfaceFrameBuffer->GetWidth() ), static_cast( surfaceFrameBuffer->GetHeight() ) ); backgroundColor = surfaceFrameBuffer->GetBackgroundColor(); diff --git a/dali/internal/render/gl-resources/context.h b/dali/internal/render/gl-resources/context.h index 80da02e..81561ba 100644 --- a/dali/internal/render/gl-resources/context.h +++ b/dali/internal/render/gl-resources/context.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_CONTEXT_H__ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -130,14 +130,6 @@ public: ****************************************************************************************/ /** - * Wrapper for ConvertTexture of Dali::Integration::GlAbstraction - */ - void ConvertTexture( uint8_t* buffer, GLenum& imageGlFormat, const uint32_t dataSize, const GLenum textureGlFormat, const bool isSubImage ) - { - return mGlAbstraction.ConvertTexture( buffer, imageGlFormat, dataSize, textureGlFormat, isSubImage ); - } - - /** * Wrapper for OpenGL ES 2.0 glActiveTexture() */ void ActiveTexture( TextureUnit textureUnit ) diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp index c993e67..99fca0d 100644 --- a/dali/internal/render/renderers/render-texture.cpp +++ b/dali/internal/render/renderers/render-texture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -766,6 +766,9 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal:: //Get pointer to the data of the PixelData object uint8_t* buffer( pixelData->GetBuffer() ); + //This buffer is only used if manually converting from RGB to RGBA + uint8_t* tempBuffer(0); + //Retrieves the pixel data element type, the gl format and gl internal format of the data contained in the PixelData object. GLenum glFormat; GLint glInternalFormat; @@ -781,8 +784,27 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal:: ( params.width != ( mWidth / ( 1 << params.mipmap ) ) ) || ( params.height != ( mHeight / ( 1 << params.mipmap ) ) ) ); - uint32_t dataSize = static_cast< uint32_t >( params.width ) * params.height; - context.ConvertTexture( buffer, glFormat, dataSize, mGlFormat, isSubImage ); + bool convert = ( ( glFormat == GL_RGB ) && ( mGlFormat == 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 ) + { + uint32_t dataSize = static_cast< uint32_t >( params.width ) * params.height; + 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; + glFormat = mGlFormat; // Set the glFormat to GL_RGBA + } //Upload data to the texture @@ -823,6 +845,10 @@ void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal:: glFormat, static_cast( pixelData->GetBufferSize() ), buffer ); } } + + + //Destroy temp buffer used for conversion RGB->RGBA + delete[] tempBuffer; } bool Texture::Bind( Context& context, uint32_t textureUnit, Render::Sampler* sampler ) @@ -888,10 +914,14 @@ void Texture::ApplySampler( Context& context, Render::Sampler* sampler ) } } +#if DALI_GLES_VERSION >= 30 + //In GLES 3.0 we do not need to upload all of the mipmap levels, but GL_TEXTURE_MAX_LEVEL must be set if(mMaxMipMapLevel) { context.TexParameteri( mTarget, GL_TEXTURE_MAX_LEVEL, mMaxMipMapLevel ); } +#endif + } } diff --git a/packaging/dali.spec b/packaging/dali.spec index 998e589..cf06396 100644 --- a/packaging/dali.spec +++ b/packaging/dali.spec @@ -124,6 +124,9 @@ DALI_DATA_RO_DIR="%{dali_data_ro_dir}" export DALI_DATA_RW_DIR export DALI_DATA_RO_DIR +# Default to GLES 2.0 if not specified. +%{!?target_gles_version: %define target_gles_version 20} + CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS; CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS; LDFLAGS="${LDFLAGS:-%optflags}" ; export LDFLAGS; @@ -142,6 +145,7 @@ LDFLAGS="${LDFLAGS:-%optflags}" ; export LDFLAGS; --localstatedir=%{_localstatedir} \ --sharedstatedir=%{_sharedstatedir} \ --mandir=%{_mandir} \ + --enable-gles=%{target_gles_version} \ %if 0%{?enable_debug} --enable-debug \ %endif @@ -180,6 +184,7 @@ make clean --sharedstatedir=%{_sharedstatedir} \ --mandir=%{_mandir} \ --enable-cxx03-abi=yes \ + --enable-gles=%{target_gles_version} \ %if 0%{?enable_debug} --enable-debug \ %endif -- 2.7.4