X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-graphics-texture.cpp;h=4950bbd2d4d536bd5d2fd6885dbd982f73e7a5c3;hb=HEAD;hp=9e1ad3ecb8da8b1d22d50a76062141302adad5a1;hpb=4c4f959f023cf5541feeef5c834cfe7e43fa05b2;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp index 9e1ad3e..4950bbd 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -15,6 +15,7 @@ */ #include "test-graphics-texture.h" +#include #include #include @@ -916,22 +917,6 @@ void TestGraphicsTexture::Prepare() { if(mCreateInfo.nativeImagePtr) { - /*********************************************************************************** - * If the native image source changes, we need to re-create the texture. * - * In EGL, this is done in native image implementation in PrepareTexture below. * - * * - * In Vulkan impl, this was done in dali-core side. I think we should make this * - * work in the graphics implementation instead. * - ***********************************************************************************/ - if(mCreateInfo.nativeImagePtr->SourceChanged()) - { - uint32_t width = mCreateInfo.nativeImagePtr->GetWidth(); - uint32_t height = mCreateInfo.nativeImagePtr->GetHeight(); - mCreateInfo.SetSize({width, height}); // Size may change - - // @todo Re-initialize this texture from the new create info. - } - // Ensure the native image is up-to-date mCreateInfo.nativeImagePtr->PrepareTexture(); } @@ -951,26 +936,74 @@ void TestGraphicsTexture::Update(Graphics::TextureUpdateInfo updateInfo, Graphic updateInfo.srcExtent2D.width != (mCreateInfo.size.width / (1 << updateInfo.level)) || updateInfo.srcExtent2D.height != (mCreateInfo.size.height / (1 << updateInfo.level))); + uint8_t* pixels = nullptr; + bool releasePixels = false; + + switch(source.sourceType) + { + case Graphics::TextureUpdateSourceInfo::Type::PIXEL_DATA: + { + auto pixelDataBuffer = Dali::Integration::GetPixelDataBuffer(source.pixelDataSource.pixelData); + + pixels = pixelDataBuffer.buffer; + releasePixels = Dali::Integration::IsPixelDataReleaseAfterUpload(source.pixelDataSource.pixelData) && updateInfo.srcOffset == 0u; + break; + } + case Graphics::TextureUpdateSourceInfo::Type::MEMORY: + { + pixels = reinterpret_cast(source.memorySource.memory); + releasePixels = true; + break; + } + default: + { + // TODO : Implement here + break; + } + } + if(!isSubImage) { if(!mIsCompressed) { - mGlAbstraction.TexImage2D(target, updateInfo.level, mGlInternalFormat, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, 0, mGlFormat, mPixelDataType, source.memorySource.memory); + mGlAbstraction.TexImage2D(target, updateInfo.level, mGlInternalFormat, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, 0, mGlFormat, mPixelDataType, pixels); } else { - mGlAbstraction.CompressedTexImage2D(target, updateInfo.level, mGlInternalFormat, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, 0, updateInfo.srcSize, source.memorySource.memory); + mGlAbstraction.CompressedTexImage2D(target, updateInfo.level, mGlInternalFormat, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, 0, updateInfo.srcSize, pixels); } } else { if(!mIsCompressed) { - mGlAbstraction.TexSubImage2D(target, updateInfo.level, updateInfo.dstOffset2D.x, updateInfo.dstOffset2D.y, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, mGlFormat, mPixelDataType, source.memorySource.memory); + mGlAbstraction.TexSubImage2D(target, updateInfo.level, updateInfo.dstOffset2D.x, updateInfo.dstOffset2D.y, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, mGlFormat, mPixelDataType, pixels); } else { - mGlAbstraction.CompressedTexSubImage2D(target, updateInfo.level, updateInfo.dstOffset2D.x, updateInfo.dstOffset2D.y, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, mGlFormat, updateInfo.srcSize, source.memorySource.memory); + mGlAbstraction.CompressedTexSubImage2D(target, updateInfo.level, updateInfo.dstOffset2D.x, updateInfo.dstOffset2D.y, updateInfo.srcExtent2D.width, updateInfo.srcExtent2D.height, mGlFormat, updateInfo.srcSize, pixels); + } + } + + if(releasePixels && pixels != nullptr) + { + switch(source.sourceType) + { + case Graphics::TextureUpdateSourceInfo::Type::PIXEL_DATA: + { + Dali::Integration::ReleasePixelDataBuffer(source.pixelDataSource.pixelData); + break; + } + case Graphics::TextureUpdateSourceInfo::Type::MEMORY: + { + free(reinterpret_cast(pixels)); + break; + } + default: + { + // TODO : Implement here + break; + } } } }