platform.SetSynchronouslyLoadedResource( resourcePtr );
}
-PixelDataPtr CreatePixelData(unsigned int width, unsigned int height, Pixel::Format pixelFormat)
+PixelData CreatePixelData(unsigned int width, unsigned int height, Pixel::Format pixelFormat)
{
unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( pixelFormat );
unsigned char* buffer = new unsigned char [ bufferSize ];
- return new PixelData( buffer, width, height, pixelFormat, PixelData::DELETE_ARRAY );
+ return PixelData::New( buffer, width, height, pixelFormat, PixelData::DELETE_ARRAY );
}
}
PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 16 ) );
- PixelDataPtr pixelData = CreatePixelData( 6,8,Pixel::RGBA8888 );
+ PixelData pixelData = CreatePixelData( 6,8,Pixel::RGBA8888 );
DALI_TEST_CHECK( atlas.Upload( pixelData, 2, 32 ) );
TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
PrepareResourceImage( application, 12, 12, Pixel::A8 );
DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 6, 6 ) );
- PixelDataPtr pixelData = CreatePixelData( 8,8,Pixel::LA88 );
+ PixelData pixelData = CreatePixelData( 8,8,Pixel::LA88 );
DALI_TEST_CHECK( atlas.Upload( pixelData, 10, 10 ) );
TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 10, 10 ) );
- PixelDataPtr pixelData = CreatePixelData( 6,6,Pixel::RGBA8888 );
+ PixelData pixelData = CreatePixelData( 6,6,Pixel::RGBA8888 );
DALI_TEST_CHECK( !atlas.Upload( pixelData, 11, 11 ) );
TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::RGB888 );
unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
- PixelDataPtr pixelData = PixelData::New( buffer, width, height, Pixel::RGB888, PixelData::FREE );
+ PixelData pixelData = PixelData::New( buffer, width, height, Pixel::RGB888, PixelData::FREE );
DALI_TEST_CHECK( pixelData );
- DALI_TEST_CHECK( pixelData->GetWidth() == width );
- DALI_TEST_CHECK( pixelData->GetHeight() == height );
- DALI_TEST_CHECK( pixelData->GetPixelFormat() == Pixel::RGB888 );
- DALI_TEST_CHECK( pixelData->GetBuffer() == buffer );
+ DALI_TEST_CHECK( pixelData.GetWidth() == width );
+ DALI_TEST_CHECK( pixelData.GetHeight() == height );
+ DALI_TEST_CHECK( pixelData.GetPixelFormat() == Pixel::RGB888 );
END_TEST;
}
unsigned char* buffer = new unsigned char [ bufferSize ];
buffer[0] = 'a';
- PixelDataPtr pixelData2 = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
+ PixelData pixelData = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
- DALI_TEST_CHECK( pixelData2 );
- DALI_TEST_CHECK( pixelData2->GetBuffer()[0] == 'a' );
+ DALI_TEST_CHECK( pixelData);
+ DALI_TEST_CHECK( pixelData.GetWidth() == width );
+ DALI_TEST_CHECK( pixelData.GetHeight() == height );
+ DALI_TEST_CHECK( pixelData.GetPixelFormat() == Pixel::L8 );
- buffer[0] = 'b';
- DALI_TEST_CHECK( pixelData2->GetBuffer()[0] == 'b' );
+ END_TEST;
+}
+
+int UtcDaliPixelDataCopyConstructor(void)
+{
+ TestApplication application;
+
+ unsigned int width = 10u;
+ unsigned int height = 10u;
+ unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::L8 );
+ unsigned char* buffer = new unsigned char [ bufferSize ];
+ PixelData pixelData = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
+ PixelData pixelDataCopy(pixelData);
+
+ DALI_TEST_EQUALS( (bool)pixelDataCopy, true, TEST_LOCATION );
END_TEST;
}
-int UtcDaliPixelDataNonCopyable(void)
+int UtcDaliPixelDataAssignmentOperator(void)
{
- // we want to make sure that PixelData is not copyable (its copy constructor is not defined)
- // this test will stop compiling if PixelData has compiler generated copy constructor
- DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( PixelData ) );
+ TestApplication application;
+
+ unsigned int width = 10u;
+ unsigned int height = 10u;
+ unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::L8 );
+ unsigned char* buffer = new unsigned char [ bufferSize ];
+ PixelData pixelData = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
+
+ PixelData pixelData2;
+ DALI_TEST_EQUALS( (bool)pixelData2, false, TEST_LOCATION );
+
+ pixelData2 = pixelData;
+ DALI_TEST_EQUALS( (bool)pixelData2, true, TEST_LOCATION );
- DALI_TEST_CHECK( true );
END_TEST;
}
+
// INTERNAL INCLUDES
#include <dali/internal/event/images/atlas-impl.h>
#include <dali/internal/event/images/buffer-image-impl.h>
+#include <dali/internal/event/images/pixel-data-impl.h>
namespace Dali
{
return GetImplementation(*this).Upload( url, xOffset, yOffset );
}
-bool Atlas::Upload( PixelDataPtr pixelData,
+bool Atlas::Upload( PixelData pixelData,
SizeType xOffset,
SizeType yOffset )
{
- return GetImplementation(*this).Upload( pixelData, xOffset, yOffset );
+ Internal::PixelData& internalPixelData = GetImplementation( pixelData );
+ return GetImplementation(*this).Upload( &internalPixelData, xOffset, yOffset );
}
Atlas Atlas::DownCast( BaseHandle handle )
* @param [in] xOffset Specifies an offset in the x direction within the atlas.
* @param [in] yOffset Specifies an offset in the y direction within the atlas.
*/
- bool Upload( PixelDataPtr pixelData,
+ bool Upload( PixelData pixelData,
SizeType xOffset,
SizeType yOffset );
/**
// EXTERNAL INLCUDES
#include <stdlib.h>
+// INTERNAL INCLUDES
+#include <dali/internal/event/images/pixel-data-impl.h>
+
namespace Dali
{
-PixelData::PixelData( unsigned char* buffer,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- ReleaseFunction releaseFunction )
-: mBuffer( buffer ),
- mWidth( width ),
- mHeight( height ),
- mPixelFormat( pixelFormat ),
- mReleaseFunction( releaseFunction )
+PixelData PixelData::New(unsigned char* buffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ ReleaseFunction releaseFunction)
+{
+ IntrusivePtr<Internal::PixelData> internal = Internal::PixelData::New( buffer, width, height, pixelFormat, releaseFunction );
+ return PixelData( internal.Get() );
+}
+
+PixelData::PixelData()
{
}
PixelData::~PixelData()
{
- if( mBuffer )
- {
- if( mReleaseFunction == FREE)
- {
- free( mBuffer );
- }
- else
- {
- delete[] mBuffer;
- }
- }
- }
+}
-PixelDataPtr PixelData::New(unsigned char* buffer,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- ReleaseFunction releaseFunction)
+PixelData::PixelData( Internal::PixelData* internal )
+: BaseHandle( internal )
{
- return new PixelData( buffer, width, height, pixelFormat, releaseFunction );
}
-unsigned int PixelData::GetWidth() const
+PixelData::PixelData(const PixelData& handle)
+: BaseHandle( handle )
{
- return mWidth;
}
-unsigned int PixelData::GetHeight() const
+PixelData& PixelData::operator=(const PixelData& rhs)
{
- return mHeight;
+ BaseHandle::operator=(rhs);
+ return *this;
}
-Pixel::Format PixelData::GetPixelFormat() const
+unsigned int PixelData::GetWidth() const
{
- return mPixelFormat;
+ return GetImplementation(*this).GetWidth();
}
-unsigned char* PixelData::GetBuffer() const
+unsigned int PixelData::GetHeight() const
+{
+ return GetImplementation(*this).GetHeight();
+}
+
+Pixel::Format PixelData::GetPixelFormat() const
{
- return mBuffer;
+ return GetImplementation(*this).GetPixelFormat();
}
} // namespace Dali
*/
#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/object/base-handle.h>
namespace Dali
{
+namespace Internal
+{
class PixelData;
-typedef IntrusivePtr<PixelData> PixelDataPtr;
+}
/**
- * @brief Reference counted pixel data .
+ * @brief The PixelData object holds a pixel buffer .
*
* The PixelData takes over the ownership of the pixel buffer.
* The buffer memory must NOT be released outside of this class, instead, the PixelData object will release it automatically when the reference count falls to zero.
*/
-class DALI_IMPORT_API PixelData : public RefObject
+class DALI_IMPORT_API PixelData : public BaseHandle
{
public:
* @param [in] pixelFormat The pixel format
* @param [in] releaseFunction The function used to release the memory.
*/
- static PixelDataPtr New( unsigned char* buffer,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- ReleaseFunction releaseFunction);
+ static PixelData New( unsigned char* buffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ ReleaseFunction releaseFunction);
/**
- * Get the width of the buffer in pixels.
- * @return The width of the buffer in pixels
+ * @brief Create an empty handle.
+ *
+ * Use PixelData::New() to create an initialized object.
*/
- unsigned int GetWidth() const;
+ PixelData();
/**
- * Get the height of the buffer in pixels
- * @return The height of the buffer in pixels
+ * Destructor
*/
- unsigned int GetHeight() const;
-
- /**
- * Get the pixel format
- * @return The pixel format
- */
- Pixel::Format GetPixelFormat() const;
+ ~PixelData();
/**
- * Get the pixel buffer if it's present.
- * @return The buffer if exits, or NULL if there is no pixel buffer.
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param [in] handle A reference to the copied handle
*/
- unsigned char* GetBuffer() const;
-
-public:
+ PixelData(const PixelData& handle);
/**
- * @brief Constructor.
+ * @brief This assignment operator is required for (smart) pointer semantics.
*
- * @param [in] buffer The raw pixel data.
- * @param [in] width Buffer width in pixels
- * @param [in] height Buffer height in pixels
- * @param [in] pixelFormat The pixel format
- * @param [in] releaseFunction The function used to release the memory.
+ * @param [in] rhs A reference to the copied handle
+ * @return A reference to this
*/
- PixelData( unsigned char* buffer,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- ReleaseFunction releaseFunction );
+ PixelData& operator=(const PixelData& rhs);
/**
- * @brief Destructor.
- *
- * Release the pixel buffer if exists.
+ * Get the width of the buffer in pixels.
+ * @return The width of the buffer in pixels
*/
- ~PixelData();
-
-
-private:
+ unsigned int GetWidth() const;
- /*
- * Undefined copy constructor.
+ /**
+ * Get the height of the buffer in pixels
+ * @return The height of the buffer in pixels
*/
- PixelData(const PixelData& other);
+ unsigned int GetHeight() const;
- /*
- * Undefined assignment operator.
+ /**
+ * Get the pixel format
+ * @return The pixel format
*/
- PixelData& operator = (const PixelData& other);
+ Pixel::Format GetPixelFormat() const;
-private:
+public: // Not intended for application developers
- unsigned char* mBuffer; ///< The raw pixel data.
- unsigned int mWidth; ///< Buffer width in pixels.
- unsigned int mHeight; ///< Buffer height in pixels.
- Pixel::Format mPixelFormat; ///< Pixel format
- ReleaseFunction mReleaseFunction; ///< Function for releasing memory
+ explicit DALI_INTERNAL PixelData( Internal::PixelData* );
};
SizeType yOffset );
/**
- * @copydoc Dali::Atlas::Upload( Dali::Atlas::PixelDataPtr, uint32_t )
+ * @copydoc Dali::Atlas::Upload( Dali::PixelData, uint32_t, uint32_t )
*/
bool Upload( PixelDataPtr pixelData,
SizeType xOffset,
--- /dev/null
+/*
+ * 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 <dali/internal/event/images/pixel-data-impl.h>
+
+// EXTERNAL INCLUDES
+#include <stdlib.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+PixelData::PixelData( unsigned char* buffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction )
+: mBuffer( buffer ),
+ mWidth( width ),
+ mHeight( height ),
+ mPixelFormat( pixelFormat ),
+ mReleaseFunction( releaseFunction )
+{
+}
+
+PixelData::~PixelData()
+{
+ if( mBuffer )
+ {
+ if( mReleaseFunction == Dali::PixelData::FREE)
+ {
+ free( mBuffer );
+ }
+ else
+ {
+ delete[] mBuffer;
+ }
+ }
+ }
+
+PixelDataPtr PixelData::New(unsigned char* buffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction)
+{
+ return new PixelData( buffer, width, height, pixelFormat, releaseFunction );
+}
+
+unsigned int PixelData::GetWidth() const
+{
+ return mWidth;
+}
+
+unsigned int PixelData::GetHeight() const
+{
+ return mHeight;
+}
+
+Pixel::Format PixelData::GetPixelFormat() const
+{
+ return mPixelFormat;
+}
+
+unsigned char* PixelData::GetBuffer() const
+{
+ return mBuffer;
+}
+
+}// namespace Internal
+
+}// namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_PIXEL_DATA_H__
+#define __DALI_INTERNAL_PIXEL_DATA_H__
+
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/images/pixel-data.h>
+#include <dali/public-api/object/base-object.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+class PixelData;
+typedef IntrusivePtr<PixelData> PixelDataPtr;
+
+class PixelData : public BaseObject
+{
+public:
+
+ /**
+ * @brief Create a PixelData object.
+ *
+ * @param [in] buffer The raw pixel data.
+ * @param [in] width Buffer width in pixels
+ * @param [in] height Buffer height in pixels
+ * @param [in] pixelFormat The pixel format
+ * @param [in] releaseFunction The function used to release the memory.
+ */
+ static PixelDataPtr New( unsigned char* buffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction);
+
+ /**
+ * @brief Constructor.
+ *
+ * @param [in] buffer The raw pixel data.
+ * @param [in] width Buffer width in pixels
+ * @param [in] height Buffer height in pixels
+ * @param [in] pixelFormat The pixel format
+ * @param [in] releaseFunction The function used to release the memory.
+ */
+ PixelData( unsigned char* buffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction );
+
+protected:
+
+ /**
+ * @brief Destructor.
+ *
+ * Release the pixel buffer if exists.
+ */
+ ~PixelData();
+
+public:
+
+ /**
+ * Get the width of the buffer in pixels.
+ * @return The width of the buffer in pixels
+ */
+ unsigned int GetWidth() const;
+
+ /**
+ * Get the height of the buffer in pixels
+ * @return The height of the buffer in pixels
+ */
+ unsigned int GetHeight() const;
+
+ /**
+ * Get the pixel format
+ * @return The pixel format
+ */
+ Pixel::Format GetPixelFormat() const;
+
+ /**
+ * Get the pixel buffer if it's present.
+ * @return The buffer if exists, or NULL if there is no pixel buffer.
+ */
+ unsigned char* GetBuffer() const;
+
+private:
+
+ /*
+ * Undefined copy constructor.
+ */
+ PixelData(const PixelData& other);
+
+ /*
+ * Undefined assignment operator.
+ */
+ PixelData& operator = (const PixelData& other);
+
+private:
+
+ unsigned char* mBuffer; ///< The raw pixel data.
+ unsigned int mWidth; ///< Buffer width in pixels.
+ unsigned int mHeight; ///< Buffer height in pixels.
+ Pixel::Format mPixelFormat; ///< Pixel format
+ Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory
+};
+
+} // namespace Internal
+
+/**
+ * Helper methods for public API
+ */
+inline Internal::PixelData& GetImplementation( Dali::PixelData& handle )
+{
+ DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+
+ BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<Internal::PixelData&>( object );
+}
+
+inline const Internal::PixelData& GetImplementation( const Dali::PixelData& handle )
+{
+ DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+
+ const BaseObject& object = handle.GetBaseObject();
+
+ return static_cast<const Internal::PixelData&>( object );
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PIXEL_DATA_H__
#include <dali/public-api/images/frame-buffer-image.h>
#include <dali/public-api/images/native-image-interface.h>
#include <dali/devel-api/common/ref-counted-dali-vector.h>
-#include <dali/devel-api/images/pixel-data.h>
+#include <dali/internal/event/images/pixel-data-impl.h>
#include <dali/internal/event/resources/resource-client-declarations.h>
#include <dali/internal/event/resources/image-ticket.h>
#include <dali/internal/event/resources/resource-ticket-lifetime-observer.h>
$(internal_src_dir)/event/images/nine-patch-image-impl.cpp \
$(internal_src_dir)/event/images/resource-image-impl.cpp \
$(internal_src_dir)/event/images/native-image-impl.cpp \
+ $(internal_src_dir)/event/images/pixel-data-impl.cpp \
$(internal_src_dir)/event/object/custom-object-internal.cpp \
$(internal_src_dir)/event/render-tasks/render-task-impl.cpp \
$(internal_src_dir)/event/render-tasks/render-task-list-impl.cpp \
#include <dali/public-api/images/native-image.h>
#include <dali/public-api/math/rect.h>
#include <dali/public-api/object/ref-object.h>
-#include <dali/devel-api/images/pixel-data.h>
#include <dali/integration-api/bitmap.h>
#include <dali/integration-api/gl-abstraction.h>
+#include <dali/internal/event/images/pixel-data-impl.h>
#include <dali/internal/render/gl-resources/gl-resource-owner.h>
#include <dali/internal/render/gl-resources/texture-units.h>
#include <dali/public-api/images/frame-buffer-image.h>
#include <dali/public-api/images/native-image-interface.h>
#include <dali/public-api/images/pixel.h>
-#include <dali/devel-api/images/pixel-data.h>
#include <dali/internal/common/message.h>
+#include <dali/internal/event/images/pixel-data-impl.h>
#include <dali/internal/event/resources/resource-client.h> // For RectArea
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/integration-api/resource-declarations.h>
#include <dali/public-api/images/native-image-interface.h>
#include <dali/public-api/images/buffer-image.h>
#include <dali/devel-api/common/ref-counted-dali-vector.h>
-#include <dali/devel-api/images/pixel-data.h>
#include <dali/integration-api/bitmap.h>
#include <dali/integration-api/platform-abstraction.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/event/images/pixel-data-impl.h>
#include <dali/internal/event/resources/resource-type-path.h>
#include <dali/internal/event/resources/resource-client-declarations.h>
#include <dali/internal/update/resources/resource-manager-declarations.h>