From: Adeel Kazmi Date: Fri, 12 Jun 2020 16:57:06 +0000 (+0100) Subject: BufferImage Removal X-Git-Tag: dali_1.9.17~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F236087%2F2;p=platform%2Fcore%2Fuifw%2Fdali-core.git BufferImage Removal Change-Id: Ib7daba0bd04cdcbb850488f23746f1ae85d055ad --- diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp index 1d658f9..3c87cd0 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp @@ -17,6 +17,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -57,7 +58,7 @@ void main() Actor CreateMeshActorToStage( TestApplication& application, Vector3 parentOrigin = ParentOrigin::CENTER, Vector3 anchorPoint = AnchorPoint::CENTER, Shader::Hint::Value shaderHints = Shader::Hint::NONE ) { - PixelBuffer* pixelBuffer = new PixelBuffer[ 4 ]; + Integration::PixelBuffer* pixelBuffer = new Integration::PixelBuffer[ 4 ]; PixelData pixelData = PixelData::New(pixelBuffer, 4, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY); Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1); image.Upload(pixelData); diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index ca65fcc..2685421 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -12,7 +12,6 @@ SET(TC_SOURCES utc-Dali-Animation.cpp utc-Dali-Any.cpp utc-Dali-BaseHandle.cpp - utc-Dali-BufferImage.cpp utc-Dali-CameraActor.cpp utc-Dali-CircularQueue.cpp utc-Dali-ConditionalWait.cpp diff --git a/automated-tests/src/dali/utc-Dali-BufferImage.cpp b/automated-tests/src/dali/utc-Dali-BufferImage.cpp deleted file mode 100644 index 381499e..0000000 --- a/automated-tests/src/dali/utc-Dali-BufferImage.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include - -#include -#include -#include - -using std::max; -using namespace Dali; - -void utc_dali_buffer_image_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_buffer_image_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliBufferImageNew01(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageNew01 - BufferImage::New(unsigned int, unsigned int, Pixel::Format)"); - - // invoke default handle constructor - BufferImage image; - - // initialise handle - image = BufferImage::New(16, 16); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - DALI_TEST_CHECK( image.GetWidth() == 16); - END_TEST; -} - -int UtcDaliBufferImageNew02(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageNew02 - BufferImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int)"); - - PixelBuffer* buffer = new PixelBuffer[16 * 16]; - BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - DALI_TEST_CHECK( image.GetWidth() == 16); - - delete [] buffer; - END_TEST; -} - -int UtcDaliBufferImageDownCast(void) -{ - TestApplication application; - tet_infoline("Testing Dali::BufferImage::DownCast()"); - - Image image = BufferImage::New(1, 1, Dali::Pixel::BGRA8888); - BufferImage bufferImage = BufferImage::DownCast( image ); - - DALI_TEST_CHECK(bufferImage); - END_TEST; -} - -int UtcDaliBufferImageDownCast2(void) -{ - TestApplication application; - tet_infoline("Testing Dali::BufferImage::DownCast()"); - - Image image = ResourceImage::New("IncorrectImageName"); - Actor actor = CreateRenderableActor( image ); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - BufferImage bufferImage = BufferImage::DownCast( image ); - DALI_TEST_CHECK(!bufferImage); - - Actor unInitialzedActor; - bufferImage = BufferImage::DownCast( unInitialzedActor ); - DALI_TEST_CHECK(!bufferImage); - END_TEST; -} - -int UtcDaliBufferImageWHITE(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageWHITE - BufferImage::WHITE()"); - - BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - PixelBuffer* buffer = image.GetBuffer(); - - DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide - buffer != NULL && // valid buffer - *buffer == 0xff); // r component is 255 - END_TEST; -} - -int UtcDaliBufferImageGetBuffer(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageGetBuffer"); - - BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel - - PixelBuffer* buffer = image.GetBuffer(); - application.SendNotification(); - application.Render(); - application.Render(); - application.SendNotification(); - - DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide - buffer != NULL && // valid buffer - *((unsigned int*)buffer) == 0xffffffff); // all component are 255 - END_TEST; -} - -int UtcDaliBufferImageGetBufferSize(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageGetBufferSize"); - - BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel - application.SendNotification(); - application.Render(); - application.Render(); - application.SendNotification(); - - PixelBuffer* buffer = image.GetBuffer(); - unsigned int bufferSize = image.GetBufferSize(); - unsigned int pixelSize = Pixel::GetBytesPerPixel(image.GetPixelFormat()); - - DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide - buffer != NULL && // valid buffer - bufferSize == pixelSize); // r component is 255 - END_TEST; -} - -int UtcDaliBufferImageGetBufferStride(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageGetBufferStride"); - - BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel - application.SendNotification(); - application.Render(); - application.Render(); - application.SendNotification(); - - unsigned int pixelSize = Pixel::GetBytesPerPixel(image.GetPixelFormat()); - unsigned int bufferStride = image.GetBufferStride(); - DALI_TEST_CHECK( bufferStride == pixelSize ); - DALI_TEST_CHECK( !image.IsDataExternal() ); - - PixelBuffer* buffer = new PixelBuffer[20 * 16]; - image = BufferImage::New(buffer, 16, 16, Pixel::A8, 20); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - bufferStride = image.GetBufferStride(); - - DALI_TEST_CHECK( bufferStride == 20); - DALI_TEST_CHECK( image.IsDataExternal() ); - - delete [] buffer; - END_TEST; -} - -int UtcDaliBufferImageGetPixelFormat(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageGetPixelFormat"); - - // Set pixel format to a non-default - BufferImage image = BufferImage::New( 16, 16, Pixel::A8 ); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - DALI_TEST_CHECK( image.GetPixelFormat() == Pixel::A8 ); - END_TEST; -} - - -int UtcDaliBufferImageIsDataExternal(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageIsDataExternal - BufferImage::IsDataExternal()"); - - PixelBuffer* buffer = new PixelBuffer[16 * 16]; - BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8); - application.SendNotification(); - application.Render(); - application.Render(); - application.SendNotification(); - - DALI_TEST_CHECK( image.IsDataExternal() ); - END_TEST; -} - -int UtcDaliBufferImageUpdate01(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageUpdate01 - single empty rect"); - - PixelBuffer* buffer = new PixelBuffer[16 * 16]; - - BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8); - Actor actor = CreateRenderableActor( image ); - Stage::GetCurrent().Add(actor); - actor.SetProperty( Actor::Property::VISIBLE,true); - - std::vector ids; - ids.push_back(200); - ids.push_back(201); - ids.push_back(202); - application.GetGlAbstraction().SetNextTextureIds(ids); - - // Allow actor to be staged and rendered - application.SendNotification(); - application.Render(0); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - - DALI_TEST_CHECK( image.IsDataExternal() ); - application.GetGlAbstraction().EnableTextureCallTrace(true); - - image.Update();//(RectArea()); // notify Core that the image has been updated - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - - const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace(); - - std::stringstream out; - out << GL_TEXTURE_2D <<", "<< 0u << ", " << 16u <<", "<< 16u; - DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexImage2D", out.str().c_str() ), true, TEST_LOCATION); - END_TEST; -} - -int UtcDaliBufferImageUpdate02(void) -{ - TestApplication application; - - tet_infoline("UtcDaliBufferImageUpdate02 - Multiple rects"); - - PixelBuffer* buffer = new PixelBuffer[16 * 16]; - BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8); - Actor actor = CreateRenderableActor( image ); - Stage::GetCurrent().Add(actor); - actor.SetProperty( Actor::Property::VISIBLE,true); - - application.SendNotification(); - application.Render(0); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - - DALI_TEST_CHECK( image.IsDataExternal() ); - application.GetGlAbstraction().EnableTextureCallTrace(true); - - // Check that multiple updates in a frame will be properly uploaded - image.Update(RectArea(9,9,5,5)); - image.Update(RectArea(2,2,4,4)); - image.Update(RectArea(3,3,1,6)); - - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - - const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace(); - - { - std::stringstream out; - out << GL_TEXTURE_2D <<", "<< 0u << ", " << 9u << ", " << 9u << ", " << 5u <<", "<< 5u; - DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION); - } - - { - std::stringstream out; - out << GL_TEXTURE_2D <<", "<< 0u << ", " << 2u << ", " << 2u << ", " << 4u <<", "<< 4u; - DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION); - } - - { - std::stringstream out; - out << GL_TEXTURE_2D <<", "<< 0u << ", " << 3u << ", " << 3u << ", " << 1u <<", "<< 6u; - DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION); - } - - END_TEST; -} - diff --git a/automated-tests/src/dali/utc-Dali-TextureSet.cpp b/automated-tests/src/dali/utc-Dali-TextureSet.cpp index 56a164d..7c6fcb3 100644 --- a/automated-tests/src/dali/utc-Dali-TextureSet.cpp +++ b/automated-tests/src/dali/utc-Dali-TextureSet.cpp @@ -298,20 +298,6 @@ int UtcDaliTextureSetSetSampler(void) END_TEST; } -int UtcDaliTextureSetGetImage(void) -{ - TestApplication application; - - TextureSet textureSet = CreateTextureSet(); - Image imageSource = BufferImage::New( 64, 64, Pixel::RGBA8888 ); - TextureSetImage( textureSet, 0u, imageSource ); - - Image imageReturn = TextureGetImage( textureSet, 0u ); - DALI_TEST_EQUALS( imageSource, imageReturn, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliTextureSetGetTexture(void) { TestApplication application; diff --git a/dali/internal/event/images/buffer-image-impl.cpp b/dali/internal/event/images/buffer-image-impl.cpp deleted file mode 100644 index 68c0027..0000000 --- a/dali/internal/event/images/buffer-image-impl.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - -using namespace Dali::Integration; - -namespace Dali -{ -namespace Internal -{ - -namespace -{ -TypeRegistration mType( typeid( Dali::BufferImage ), typeid( Dali::Image ), NULL ); -} // unnamed namespace - -BufferImagePtr BufferImage::New( unsigned int width, - unsigned int height, - Pixel::Format pixelformat ) -{ - BufferImagePtr internal = new BufferImage( width, height, pixelformat ); - internal->Initialize(); - internal->Update( RectArea() ); - return internal; -} - -BufferImagePtr BufferImage::New( PixelBuffer* pixBuf, - unsigned int width, - unsigned int height, - Pixel::Format pixelformat, - unsigned int stride ) -{ - BufferImagePtr internal = new BufferImage( pixBuf, width, height, pixelformat, stride ); - internal->Initialize(); - internal->Update( RectArea() ); - return internal; -} - -BufferImage::BufferImage(unsigned int width, unsigned int height, Pixel::Format pixelformat) -: Image(), - mInternalBuffer( NULL ), - mExternalBuffer( NULL ), - mBufferSize( 0 ), - mByteStride( 0 ), - mBytesPerPixel( 0 ), - mBufferWidth( 0 ), - mPixelFormat( pixelformat ), - mResourcePolicy( ResourcePolicy::OWNED_DISCARD ) -{ - SetupBuffer( width, height, pixelformat, width ); - - // Allocate a persistent internal buffer - mInternalBuffer = new PixelBuffer[ mBufferSize ]; -} - -BufferImage::BufferImage(PixelBuffer* pixBuf, - unsigned int width, - unsigned int height, - Pixel::Format pixelformat, - unsigned int stride) -: Image(), - mInternalBuffer( NULL ), - mExternalBuffer( pixBuf ), - mBufferSize( 0 ), - mByteStride( 0 ), - mBytesPerPixel( 0 ), - mBufferWidth( 0 ), - mPixelFormat( pixelformat ), - mResourcePolicy( ResourcePolicy::OWNED_DISCARD ) -{ - SetupBuffer( width, height, pixelformat, stride ? stride: width ); -} - -BufferImage::~BufferImage() -{ - delete[] mInternalBuffer; -} - -void BufferImage::SetupBuffer( unsigned int width, - unsigned int height, - Pixel::Format pixelformat, - unsigned int byteStride ) -{ - mWidth = width; - mHeight = height; - mPixelFormat = pixelformat; - mBytesPerPixel = Pixel::GetBytesPerPixel( pixelformat ); - - mByteStride = byteStride * mBytesPerPixel; - mBufferSize = height * mByteStride; - - // Respect the desired release policy - mResourcePolicy = ResourcePolicy::OWNED_RETAIN; -} - -bool BufferImage::IsDataExternal() const -{ - return ( mExternalBuffer ? true : false ); -} - -void BufferImage::Update( const RectArea& updateArea ) -{ - if ( !mTexture ) - { - mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, mPixelFormat, mWidth, mHeight ); - } - DALI_ASSERT_DEBUG( updateArea.x + updateArea.width <= mWidth && updateArea.y + updateArea.height <= mHeight ); - UploadArea( updateArea ); -} - -void BufferImage::UploadArea( const RectArea& area ) -{ - DALI_ASSERT_DEBUG( area.width <= mWidth && area.height <= mHeight ); - - mBufferWidth = area.width ? area.width : mWidth; - uint32_t bufferHeight = area.height ? area.height : mHeight; - uint32_t bufferSize = mBytesPerPixel * mBufferWidth * bufferHeight; - Dali::Integration::PixelBuffer* buffer = reinterpret_cast< Dali::Integration::PixelBuffer* >( malloc( bufferSize ) ); - DALI_ASSERT_DEBUG(buffer != 0); - - // Are we uploading from an external or internal buffer ? - if ( mExternalBuffer ) - { - // Check if we're doing the entire area without stride mismatch between source and dest ? - if( ( mByteStride == mWidth * mBytesPerPixel ) && area.IsEmpty() ) - { - memcpy( buffer, mExternalBuffer, mBufferSize ); - } - else - { - UpdateBufferArea( mExternalBuffer, buffer, area ); - } - } - else - { - // Check if we're doing the entire internal buffer ? - if( area.IsEmpty() ) - { - memcpy( buffer, mInternalBuffer, bufferSize ); - } - else - { - UpdateBufferArea( mInternalBuffer, buffer, area ); - } - } - PixelDataPtr pixelData = PixelData::New( buffer, bufferSize, mBufferWidth, bufferHeight, mPixelFormat, Dali::PixelData::FREE ); - mTexture->Upload( pixelData, 0u, 0u, area.x, area.y, mBufferWidth, bufferHeight ); -} - -void BufferImage::UpdateBufferArea( PixelBuffer* src, PixelBuffer* dest, const RectArea& area ) -{ - DALI_ASSERT_DEBUG( area.x + area.width <= mWidth && area.y + area.height <= mHeight ); - - uint32_t width = mBufferWidth * mBytesPerPixel; - - src += ( area.y * mByteStride ) + ( area.x * mBytesPerPixel ); - for ( uint32_t i = 0; i < area.height; ++i ) - { - memcpy( dest, src, width ); - src += mByteStride; - dest += width; - } -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/images/buffer-image-impl.h b/dali/internal/event/images/buffer-image-impl.h deleted file mode 100644 index 17bf270..0000000 --- a/dali/internal/event/images/buffer-image-impl.h +++ /dev/null @@ -1,225 +0,0 @@ -#ifndef DALI_INTERNAL_BUFFER_IMAGE_H -#define DALI_INTERNAL_BUFFER_IMAGE_H - -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include // for uint32_t - -// INTERNAL INCLUDES -#include // For Integration::BitmapPtr -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -class BufferImage; -typedef IntrusivePtr BufferImagePtr; - -/** - * BufferImage represents an image resource that can be added to actors etc. - * Its pixel buffer data is provided by the application developer. - * Pixel buffer memory allocation can be handled by dali or application. - */ -class BufferImage : public Image -{ -public: - /** - * Create a new BufferImage. - * Also a pixel buffer for image data is allocated. - * Dali has ownership of the buffer. - * For better performance and portability use power of two dimensions. - * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE. - * @param [in] width image width in pixels - * @param [in] height image height in pixels - * @param [in] pixelformat the pixel format (rgba 32 bit by default) - */ - static BufferImagePtr New( unsigned int width, - unsigned int height, - Pixel::Format pixelformat ); - - /** - * @DEPRECATED_1_1.5. Support for externally owned Pixel Buffers is due to be removed TBA. It is recommended that a BufferImage owned Buffer be used instead. - * - * @brief Create a new BufferImage, which uses external data source. - * - * Pixel buffer has to be allocated by application. - * An internal copy is made of the Pixel Buffer, which can then be freed by the Application, unless if there will be a call to Update() later. - * The buffer should only be freed when there is no chance of an Update() being called again. - * Obtaining the buffer with GetBuffer() and altering the contents, then Update() will not work with externally owned buffers. - * For better performance and portability use power of two dimensions. - * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE. - * - * @param [in] pixBuf pixel buffer. has to be allocated by application. - * @param [in] width image width in pixels - * @param [in] height image height in pixels - * @param [in] pixelformat the pixel format (rgba 32 bit by default) - * @param [in] stride the internal stride of the pixelbuffer in pixels - */ - static BufferImagePtr New( PixelBuffer* pixBuf, - unsigned int width, - unsigned int height, - Pixel::Format pixelformat, - unsigned int stride ); - - /** - * Create a new BufferImage. - * Also a pixel buffer for image data is allocated. - * Dali has ownership of the buffer. - * For better performance use power of two dimensions. - * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE. - * @param [in] width image width in pixels - * @param [in] height image height in pixels - * @param [in] pixelformat the pixel format (rgba 32 bit by default) - */ - BufferImage(unsigned int width, - unsigned int height, - Pixel::Format pixelformat ); - - /** - * Create a new BufferImage, which uses external data source. - * Pixel buffer has to be allocated by application. - * An internal copy is made of the Pixel Buffer, which can then be freed by the Application, unless if there will be a call to Update() later. - * The buffer should only be freed when there is no chance of Update() being called again. - * Note: obtaining the buffer with GetBuffer(), writing changes, then Update() will cause any changes to be lost. - * In this case, the BufferImage will update from the external buffer and so changes should be written there. - * For better performance and portability use power of two dimensions. - * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE. - * @param [in] pixBuf pixel buffer. has to be allocated by application. - * @param [in] width image width in pixels - * @param [in] height image height in pixels - * @param [in] pixelformat the pixel format (rgba 32 bit by default) - * @param [in] stride the internal stride of the pixelbuffer in pixels - */ - BufferImage(PixelBuffer* pixBuf, - unsigned int width, - unsigned int height, - Pixel::Format pixelformat, - unsigned int stride ); - -protected: - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~BufferImage(); - -public: - /** - * Notify Dali that the contents of the buffer have changed. - * @param [in] updateArea area that has changed in buffer. An empty rect means the whole buffer has changed. - */ - void Update( const RectArea& updateArea); - - /** - * @copydoc Dali::BufferImage::IsDataExternal - */ - bool IsDataExternal() const; - - /** - * Returns the pixel buffer of the Image. - * The application developer can write to the buffer. - * Upload the modified contents with Update(). - * @return the pixel buffer - */ - PixelBuffer* GetBuffer() const - { - return ( mExternalBuffer ? mExternalBuffer : mInternalBuffer ); - } - - /** - * Returns buffer size in bytes. - * @return the buffer size in bytes - */ - unsigned int GetBufferSize() const - { - return mBufferSize; - } - - /** - * Returns buffer stride (in bytes). - * @return the buffer stride - */ - unsigned int GetBufferStride() const - { - return mByteStride; - } - - /** - * Get the pixel format - * @return The pixel format - */ - Pixel::Format GetPixelFormat() const - { - return mPixelFormat; - } - -private: - - void SetupBuffer( unsigned int width, - unsigned int height, - Pixel::Format pixelformat, - unsigned int byteStride ); - - void UploadArea( const RectArea& area ); - - void UpdateBufferArea( PixelBuffer* src, PixelBuffer* dest, const RectArea& area ); - -private: - - PixelBuffer* mInternalBuffer; ///< NULL if the data is supplied by an external buffer. - PixelBuffer* mExternalBuffer; ///< NULL if there is no external pixel data (this is never owned by BufferImage). - uint32_t mBufferSize; ///< size of the pixel buffer. - uint32_t mByteStride; ///< width of the pixel buffer in bytes. - uint32_t mBytesPerPixel; ///< width of a pixel in bytes. - uint32_t mBufferWidth; ///< cached pixel width of bitmap used for transport. - Pixel::Format mPixelFormat; ///< pixel format of bitmap. - ResourcePolicy::Discardable mResourcePolicy; ///< whether to discard the pixel buffer when removed from the stage or to retain the data. -}; - -} // namespace Internal - -/** - * Helper methods for public API. - */ -inline Internal::BufferImage& GetImplementation(Dali::BufferImage& image) -{ - DALI_ASSERT_ALWAYS( image && "BufferImage handle is empty" ); - - BaseObject& handle = image.GetBaseObject(); - - return static_cast(handle); -} - -inline const Internal::BufferImage& GetImplementation(const Dali::BufferImage& image) -{ - DALI_ASSERT_ALWAYS( image && "BufferImage handle is empty" ); - - const BaseObject& handle = image.GetBaseObject(); - - return static_cast(handle); -} - -} // namespace Dali - -#endif // DALI_INTERNAL_BUFFER_IMAGE_H diff --git a/dali/internal/file.list b/dali/internal/file.list index b0bb6f3..c1dccf0 100644 --- a/dali/internal/file.list +++ b/dali/internal/file.list @@ -80,7 +80,6 @@ SET( internal_src_files ${internal_src_dir}/event/images/bitmap-packed-pixel.cpp ${internal_src_dir}/event/images/bitmap-compressed.cpp ${internal_src_dir}/event/images/image-impl.cpp - ${internal_src_dir}/event/images/buffer-image-impl.cpp ${internal_src_dir}/event/images/frame-buffer-image-impl.cpp ${internal_src_dir}/event/images/resource-image-impl.cpp ${internal_src_dir}/event/images/native-image-impl.cpp diff --git a/dali/public-api/dali-core.h b/dali/public-api/dali-core.h index ac33dd6..c9530e4 100644 --- a/dali/public-api/dali-core.h +++ b/dali/public-api/dali-core.h @@ -65,7 +65,6 @@ #include #include -#include #include #include #include diff --git a/dali/public-api/file.list b/dali/public-api/file.list index 61e7526..ec0fe0f 100644 --- a/dali/public-api/file.list +++ b/dali/public-api/file.list @@ -40,7 +40,6 @@ SET( public_api_src_files ${public_api_src_dir}/images/image.cpp ${public_api_src_dir}/images/pixel.cpp ${public_api_src_dir}/images/pixel-data.cpp - ${public_api_src_dir}/images/buffer-image.cpp ${public_api_src_dir}/images/frame-buffer-image.cpp ${public_api_src_dir}/images/resource-image.cpp ${public_api_src_dir}/images/native-image.cpp @@ -161,7 +160,6 @@ SET( public_api_core_events_header_files SET( public_api_core_images_header_files - ${public_api_src_dir}/images/buffer-image.h ${public_api_src_dir}/images/frame-buffer-image.h ${public_api_src_dir}/images/image.h ${public_api_src_dir}/images/image-operations.h diff --git a/dali/public-api/images/buffer-image.cpp b/dali/public-api/images/buffer-image.cpp deleted file mode 100644 index 205f4cc..0000000 --- a/dali/public-api/images/buffer-image.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ - -BufferImage::BufferImage() -{ -} - -BufferImage::BufferImage(Internal::BufferImage* internal) - : Image(internal) -{ -} - -BufferImage BufferImage::DownCast( BaseHandle handle ) -{ - return BufferImage( dynamic_cast(handle.GetObjectPtr()) ); -} - -BufferImage::~BufferImage() -{ -} - -BufferImage::BufferImage(const BufferImage& handle) -: Image(handle) -{ -} - -BufferImage& BufferImage::operator=(const BufferImage& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} - -const BufferImage BufferImage::WHITE() -{ - Internal::BufferImage* internal = new Internal::BufferImage(1,1,Pixel::RGBA8888); - PixelBuffer* pBuf = internal->GetBuffer(); - if ( pBuf ) - { - pBuf[0] = pBuf[1] = pBuf[2] = pBuf[3] = 0xFF; - } - return BufferImage(internal); -} - -BufferImage BufferImage::New(uint32_t width, uint32_t height, Pixel::Format pixelformat) -{ - DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" ); - DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" ); - - Internal::BufferImagePtr internal = Internal::BufferImage::New(width, height, pixelformat); - return BufferImage(internal.Get()); -} - -BufferImage BufferImage::New(PixelBuffer* pixBuf, uint32_t width, uint32_t height, Pixel::Format pixelformat, uint32_t stride) -{ - DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" ); - DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" ); - - Internal::BufferImagePtr internal = Internal::BufferImage::New(pixBuf, width, height, pixelformat, stride); - return BufferImage(internal.Get()); -} - -PixelBuffer* BufferImage::GetBuffer() -{ - return GetImplementation(*this).GetBuffer(); -} - -uint32_t BufferImage::GetBufferSize() const -{ - return GetImplementation(*this).GetBufferSize(); -} - -uint32_t BufferImage::GetBufferStride() const -{ - return GetImplementation(*this).GetBufferStride(); -} - -Pixel::Format BufferImage::GetPixelFormat() const -{ - return GetImplementation(*this).GetPixelFormat(); -} - -void BufferImage::Update () -{ - RectArea area; - GetImplementation(*this).Update(area); -} - -void BufferImage::Update (RectArea updateArea) -{ - GetImplementation(*this).Update(updateArea); -} - -bool BufferImage::IsDataExternal() const -{ - return GetImplementation(*this).IsDataExternal(); -} - -} // namespace Dali diff --git a/dali/public-api/images/buffer-image.h b/dali/public-api/images/buffer-image.h deleted file mode 100644 index 4c823de..0000000 --- a/dali/public-api/images/buffer-image.h +++ /dev/null @@ -1,280 +0,0 @@ -#ifndef DALI_BUFFER_IMAGE_H -#define DALI_BUFFER_IMAGE_H - -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ -/** - * @addtogroup dali_core_images - * @{ - */ - -namespace Internal DALI_INTERNAL -{ -class BufferImage; -} - -typedef uint8_t PixelBuffer; ///< pixel data buffer @SINCE_1_0.0 -typedef Rect RectArea; ///< rectangular area (x,y,w,h) @SINCE_1_0.0 - - -/** - * @DEPRECATED_1_2.41 - * - * @brief BufferImage represents an image resource as a pixel data buffer. - * - * Its pixel buffer data is provided by the application developer. - * - * If the pixel format of the pixel buffer contains an alpha channel, - * then the image is considered to be have transparent pixels without - * regard for the actual content of the channel, and will be blended. - * - * @SINCE_1_0.0 - */ -class DALI_CORE_API BufferImage : public Image -{ -public: - - /** - * @DEPRECATED_1_2.41 - * - * @brief Constructor which creates an uninitialized BufferImage object. - * - * Use BufferImage::New(...) to create an initialized object. - * @SINCE_1_0.0 - */ - BufferImage() DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Creates a new BufferImage. - * - * Also a pixel buffer for image data is allocated. - * Dali has ownership of the buffer. - * For better performance and portability use power of two dimensions. - * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE. - * @SINCE_1_0.0 - * @param[in] width Image width in pixels - * @param[in] height Image height in pixels - * @param[in] pixelformat The pixel format (rgba 32 bit by default) - * @return A handle to a new instance of BufferImage - * @pre width & height are greater than zero - * @note default resource management policies are Immediate and Never - * - */ - static BufferImage New(uint32_t width, - uint32_t height, - Pixel::Format pixelformat=Pixel::RGBA8888) DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Creates a new BufferImage, which uses an external data source. - * - * The PixelBuffer has to be allocated by application. - * - * The application holds ownership of the buffer. It must not - * destroy the PixelBuffer on a staged image if it has called - * Update() and hasn't received a Image::UploadedSignal, or if it has just - * added it to the stage and has not received a Image::UploadedSignal. - * - * For better performance and portability use power of two dimensions. - * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE. - * - * @SINCE_1_0.0 - * @param[in] pixelBuffer Pixel buffer has to be allocated by application - * @param[in] width Image width in pixels - * @param[in] height Image height in pixels - * @param[in] pixelFormat The pixel format (rgba 32 bit by default) - * @param[in] stride The internal stride of the pixelbuffer in pixels - * @return A handle to a new instance of BufferImage - * @pre width & height are greater than zero - */ - static BufferImage New(PixelBuffer* pixelBuffer, - uint32_t width, - uint32_t height, - Pixel::Format pixelFormat=Pixel::RGBA8888, - uint32_t stride=0) DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Downcasts a handle to BufferImage handle. - * - * If the handle points to a BufferImage, the downcast produces valid handle. - * If not, the returned handle is left uninitialized. - * - * @SINCE_1_0.0 - * @param[in] handle Handle to an object - * @return Handle to a BufferImage or an uninitialized handle - */ - static BufferImage DownCast( BaseHandle handle ) DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Destructor. - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - * @SINCE_1_0.0 - */ - ~BufferImage() DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief This copy constructor is required for (smart) pointer semantics. - * - * @SINCE_1_0.0 - * @param[in] handle A reference to the copied handle - */ - BufferImage(const BufferImage& handle) DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief This assignment operator is required for (smart) pointer semantics. - * - * @SINCE_1_0.0 - * @param[in] rhs A reference to the copied handle - * @return A reference to this - */ - BufferImage& operator=(const BufferImage& rhs) DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief White pixel as image data. - * - * Can be used to create solid color actors. - * @SINCE_1_0.0 - * @return 1 white pixel with 32 bit colordepth - */ - static const BufferImage WHITE() DALI_DEPRECATED_API; - -public: - - /** - * @DEPRECATED_1_2.41 - * - * @brief Returns the pixel buffer of the Image. - * - * The application can write to the buffer to modify its contents. - * - * Whilst the image is on stage, after writing to the buffer the - * application should call Update() and wait for the - * Image::UploadedSignal() method before writing again. - * - * @SINCE_1_0.0 - * @return The pixel buffer - */ - PixelBuffer* GetBuffer() DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Returns buffer size in bytes. - * - * @SINCE_1_0.0 - * @return The buffer size in bytes - */ - uint32_t GetBufferSize() const DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Returns buffer stride (in bytes). - * - * @SINCE_1_0.0 - * @return The buffer stride - */ - uint32_t GetBufferStride() const DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Returns the pixel format of the contained buffer - * - * @SINCE_1_0.0 - * @return The pixel format - */ - Pixel::Format GetPixelFormat() const DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Inform Dali that the contents of the buffer have changed. - * - * Image::UploadedSignal will be sent in response if the image is on stage - * and the image data has been successfully copied to graphics - * memory. To avoid visual tearing, the application should wait for - * the Image::UploadedSignal before modifying the data. - * - * The application must not destroy an external PixelBuffer on a staged - * image after calling this method until the Image::UploadedSignal has been - * successfully received. - * - * @SINCE_1_0.0 - * @note BufferImage::Update might not work with BGR/BGRA formats! - * @note Some GPUs may not support Non power of two buffer updates (for - * example C110/SGX540) - */ - void Update() DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @copydoc Update() - * @param[in] updateArea Area that has changed in buffer - */ - void Update( RectArea updateArea ) DALI_DEPRECATED_API; - - /** - * @DEPRECATED_1_2.41 - * - * @brief Returns whether BufferImage uses external data source or not. - * - * If not, dali holds ownership of the PixelBuffer, otherwise the application - * is responsible for freeing it. - * - * The application must not destroy an external PixelBuffer on a staged image - * if it has called Update() and hasn't received a Image::UploadedSignal. - * - * @SINCE_1_0.0 - * @return @c true if application owns data, @c false otherwise - */ - bool IsDataExternal() const DALI_DEPRECATED_API; - -public: // Not intended for application developers - - explicit DALI_INTERNAL BufferImage(Internal::BufferImage*); -}; - -/** - * @} - */ -} // namespace Dali - -#endif // DALI_BUFFER_IMAGE_H