From: Seoyeon Kim Date: Tue, 13 Nov 2018 08:30:07 +0000 (+0900) Subject: [Tizen] Revert "Remove TypeRegistration from deprecated Image classes" X-Git-Tag: submit/tizen/20181113.092512^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=698c38bd1a76158dd449639aaf014d7046dd3ae4 [Tizen] Revert "Remove TypeRegistration from deprecated Image classes" This reverts commit 65bb67c665fe465e388e8510eeb5fadda45cf202. Change-Id: Id590893282037252fcfeb095b6f039bc18349d15 --- diff --git a/dali/internal/event/images/buffer-image-impl.cpp b/dali/internal/event/images/buffer-image-impl.cpp index 7ad879b..008a361 100644 --- a/dali/internal/event/images/buffer-image-impl.cpp +++ b/dali/internal/event/images/buffer-image-impl.cpp @@ -34,6 +34,11 @@ 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 ) diff --git a/dali/internal/event/images/encoded-buffer-image-impl.cpp b/dali/internal/event/images/encoded-buffer-image-impl.cpp index 255709a..d6d5de0 100644 --- a/dali/internal/event/images/encoded-buffer-image-impl.cpp +++ b/dali/internal/event/images/encoded-buffer-image-impl.cpp @@ -35,6 +35,8 @@ namespace Internal namespace { +TypeRegistration mType( typeid( Dali::EncodedBufferImage ), typeid( Dali::Image ), NULL ); + /** Raw bytes of a resource laid out exactly as it would be in a file, but in memory. */ typedef Dali::RefCountedVector RequestBuffer; /** Counting smart pointer for managing a buffer of raw bytes. */ diff --git a/dali/internal/event/images/frame-buffer-image-impl.cpp b/dali/internal/event/images/frame-buffer-image-impl.cpp index def730a..15aa6a8 100644 --- a/dali/internal/event/images/frame-buffer-image-impl.cpp +++ b/dali/internal/event/images/frame-buffer-image-impl.cpp @@ -30,6 +30,8 @@ namespace Internal namespace { +TypeRegistration mType( typeid( Dali::FrameBufferImage ), typeid( Dali::Image ), NULL ); + const int RenderBufferFormatToFrameBufferAttachments[] = { Dali::FrameBuffer::Attachment::NONE, Dali::FrameBuffer::Attachment::DEPTH, Dali::FrameBuffer::Attachment::STENCIL, diff --git a/dali/internal/event/images/image-impl.cpp b/dali/internal/event/images/image-impl.cpp index 49d7f54..8357fcf 100644 --- a/dali/internal/event/images/image-impl.cpp +++ b/dali/internal/event/images/image-impl.cpp @@ -37,6 +37,38 @@ namespace Dali namespace Internal { +namespace +{ + +// Signals + +const char* const SIGNAL_IMAGE_UPLOADED = "uploaded"; + +TypeRegistration mType( typeid( Dali::Image ), typeid( Dali::BaseHandle ), NULL ); + +Dali::SignalConnectorType signalConnector1( mType, SIGNAL_IMAGE_UPLOADED, &Image::DoConnectSignal ); + +} + +bool Image::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) +{ + bool connected( true ); + DALI_ASSERT_DEBUG( dynamic_cast( object ) && "Failed to downcast from BaseObject to Image.\n" ); + Image* image = static_cast(object); + + if( 0 == strcmp( signalName.c_str(), SIGNAL_IMAGE_UPLOADED ) ) + { + image->UploadedSignal().Connect( tracker, functor ); + } + else + { + // signalName does not match any signal + connected = false; + } + + return connected; +} + unsigned int Image::GetWidth() const { return mWidth; diff --git a/dali/internal/event/images/image-impl.h b/dali/internal/event/images/image-impl.h index de6df50..2a4f142 100644 --- a/dali/internal/event/images/image-impl.h +++ b/dali/internal/event/images/image-impl.h @@ -51,6 +51,17 @@ public: Dali::Image::ImageSignalType& UploadedSignal() { return mUploaded; } /** + * Connects a callback function with the object's signals. + * @param[in] object The object providing the signal. + * @param[in] tracker Used to disconnect the signal. + * @param[in] signalName The signal to connect to. + * @param[in] functor A newly allocated FunctorDelegate. + * @return True if the signal was connected. + * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. + */ + static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + + /** * Get the width of the image. * Only to be used after the image has finished loading. * (Ticket's LoadingSucceeded callback was called) diff --git a/dali/internal/event/images/native-image-impl.cpp b/dali/internal/event/images/native-image-impl.cpp index 39c8ecb..d7e3f9e 100644 --- a/dali/internal/event/images/native-image-impl.cpp +++ b/dali/internal/event/images/native-image-impl.cpp @@ -33,6 +33,11 @@ namespace Dali namespace Internal { +namespace +{ +TypeRegistration mType( typeid(Dali::NativeImage), typeid(Dali::Image), NULL ); +} + NativeImage::NativeImage( NativeImageInterface& resourceData ) : Image() { diff --git a/dali/internal/event/images/nine-patch-image-impl.cpp b/dali/internal/event/images/nine-patch-image-impl.cpp index ca96236..7662edc 100644 --- a/dali/internal/event/images/nine-patch-image-impl.cpp +++ b/dali/internal/event/images/nine-patch-image-impl.cpp @@ -167,6 +167,11 @@ namespace Dali namespace Internal { +namespace +{ +TypeRegistration mType( typeid( Dali::NinePatchImage ), typeid( Dali::Image ), NULL ); +} // unnamed namespace + NinePatchImagePtr NinePatchImage::New( const std::string& filename ) { Internal::NinePatchImagePtr internal( new NinePatchImage( filename ) ); diff --git a/dali/internal/event/images/resource-image-impl.cpp b/dali/internal/event/images/resource-image-impl.cpp index 737eb37..5efe567 100644 --- a/dali/internal/event/images/resource-image-impl.cpp +++ b/dali/internal/event/images/resource-image-impl.cpp @@ -38,6 +38,26 @@ namespace Dali namespace Internal { +namespace +{ + +// Signals + +const char* const SIGNAL_IMAGE_LOADING_FINISHED = "imageLoadingFinished"; + + +BaseHandle CreateImage() +{ + ImagePtr image = ResourceImage::New(); + return Dali::Image(image.Get()); +} + +TypeRegistration mType( typeid( Dali::ResourceImage ), typeid( Dali::Image ), CreateImage ); + +Dali::SignalConnectorType signalConnector1( mType, SIGNAL_IMAGE_LOADING_FINISHED, &ResourceImage::DoConnectSignal ); + +} + ResourceImage::ResourceImage() : Image(), mLoadingFinished(), @@ -87,6 +107,26 @@ ResourceImage::~ResourceImage() { } +bool ResourceImage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) +{ + bool connected( true ); + DALI_ASSERT_DEBUG( dynamic_cast( object ) && "Failed to downcast from BaseObject to ResourceImage.\n" ); + ResourceImage* image = static_cast(object); + + if( 0 == strcmp( signalName.c_str(), SIGNAL_IMAGE_LOADING_FINISHED ) ) + { + image->LoadingFinishedSignal().Connect( tracker, functor ); + } + else + { + // signalName does not match any signal + connected = false; + } + + return connected; +} + + const ImageAttributes& ResourceImage::GetAttributes() const { return mAttributes; diff --git a/dali/internal/event/images/resource-image-impl.h b/dali/internal/event/images/resource-image-impl.h index ce1d227..5843fd8 100644 --- a/dali/internal/event/images/resource-image-impl.h +++ b/dali/internal/event/images/resource-image-impl.h @@ -71,6 +71,17 @@ public: Dali::ResourceImage::ResourceImageSignal& LoadingFinishedSignal() { return mLoadingFinished; } /** + * Connects a callback function with the object's signals. + * @param[in] object The object providing the signal. + * @param[in] tracker Used to disconnect the signal. + * @param[in] signalName The signal to connect to. + * @param[in] functor A newly allocated FunctorDelegate. + * @return True if the signal was connected. + * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. + */ + static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + + /** * Get the attributes of the image. * Only to be used after the image has finished loading. * (Ticket's LoadingSucceeded callback was called)