X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fintegration-api%2Fbitmap.cpp;h=373af9cca100f7aa255cc0b8151955ec463dcb41;hb=c2605260e4a76ab1fda23bea51002f5228d8c88b;hp=bfff2d5ab9c32e5b8a60f6394ba64da2a462bf42;hpb=54dff6a35a504884c076a370b660ed9a0a6c6bdb;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/integration-api/bitmap.cpp b/dali/integration-api/bitmap.cpp index bfff2d5..373af9c 100644 --- a/dali/integration-api/bitmap.cpp +++ b/dali/integration-api/bitmap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 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. @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -163,80 +162,272 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i break; } + // GLES 2 extension compressed formats: + case COMPRESSED_RGB8_ETC1: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n" ); + internalFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. + break; + } + case COMPRESSED_RGB_PVRTC_4BPPV1: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n" ); + internalFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. + break; + } + // GLES 3.0 standard compressed formats: case COMPRESSED_R11_EAC: { DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_R11_EAC.\n"); - internalFormat = 0x9270; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_R11_EAC; break; } case COMPRESSED_SIGNED_R11_EAC: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n" ); - internalFormat = 0x9271; ///! < Hardcoded until we move to GLES 3.0 or greater. - ; + internalFormat = GL_COMPRESSED_SIGNED_R11_EAC; break; } case COMPRESSED_RG11_EAC: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n" ); - internalFormat = 0x9272; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_RG11_EAC; break; } case COMPRESSED_SIGNED_RG11_EAC: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n" ); - internalFormat = 0x9273; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_SIGNED_RG11_EAC; break; } case COMPRESSED_RGB8_ETC2: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n" ); - internalFormat = 0x9274; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_RGB8_ETC2; break; } case COMPRESSED_SRGB8_ETC2: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n" ); - internalFormat = 0x9275; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_SRGB8_ETC2; break; } case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); - internalFormat = 0x9276; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; break; } case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); - internalFormat = 0x9277; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; break; } case COMPRESSED_RGBA8_ETC2_EAC: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n" ); - internalFormat = 0x9278; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; break; } case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: { DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n" ); - internalFormat = 0x9279; ///! < Hardcoded until we move to GLES 3.0 or greater. + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; break; } - // GLES 2 extension compressed formats: - case COMPRESSED_RGB8_ETC1: + // GLES 3.1 extension compressed formats: + case COMPRESSED_RGBA_ASTC_4x4_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n" ); - internalFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; } - case COMPRESSED_RGB_PVRTC_4BPPV1: + case COMPRESSED_RGBA_ASTC_5x4_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n" ); - internalFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_5x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_6x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_6x6_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_8x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_8x6_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_8x8_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_10x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_10x6_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_10x8_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_10x10_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_12x10_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR; + break; + } + case COMPRESSED_RGBA_ASTC_12x12_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n" ); + internalFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; + break; + } + case COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n" ); + internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; + break; + } + + // GLES 3.0 floating point formats. + case RGB16F: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); + pixelDataType = GL_HALF_FLOAT; + internalFormat= GL_RGB; + break; + } + case RGB32F: + { + DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); + pixelDataType = GL_FLOAT; + internalFormat= GL_RGB; + break; + } + + case INVALID: + { + DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" ); + internalFormat = 0; break; } } @@ -280,6 +471,13 @@ Bitmap::Bitmap( ResourcePolicy::Discardable discardable, Dali::Integration::Pixe { } +PixelBuffer* Bitmap::GetBufferOwnership() +{ + PixelBuffer* buffer = mData; + mData = NULL; + return buffer; +} + void Bitmap::DiscardBuffer() { if( mDiscardable == ResourcePolicy::OWNED_DISCARD ) @@ -291,13 +489,7 @@ void Bitmap::DiscardBuffer() Bitmap::~Bitmap() { DALI_LOG_TRACE_METHOD(Debug::Filter::gImage); - - // If owned - if( mDiscardable == ResourcePolicy::OWNED_DISCARD || - mDiscardable == ResourcePolicy::OWNED_RETAIN ) - { - DeletePixelBuffer(); - } + DeletePixelBuffer(); } /**