X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fimages%2Fimage-impl.h;h=15eeff27e36f0d156d23310d2f758eacdf0254f0;hb=ff364987bf3c2ef5bb2b57348747eeb784d8ba90;hp=d05918ebf6f00b03de9069e631e39ec2f9464448;hpb=7c6f8ed43521c52d6cc46a7e3e3e40069514f818;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/images/image-impl.h b/dali/internal/event/images/image-impl.h index d05918e..15eeff2 100644 --- a/dali/internal/event/images/image-impl.h +++ b/dali/internal/event/images/image-impl.h @@ -23,32 +23,20 @@ // INTERNAL INCLUDES #include -#include #include -#include -#include -#include #include #include namespace Dali { -class NativeImage; - namespace Internal { -typedef Dali::Image::LoadPolicy LoadPolicy; -typedef Dali::Image::ReleasePolicy ReleasePolicy; - class Image; class ImageFactory; typedef IntrusivePtr ImagePtr; -const LoadPolicy ImageLoadPolicyDefault = Dali::Image::Immediate; -const ReleasePolicy ImageReleasePolicyDefault = Dali::Image::Never; - /** * Image represents an image resource that can be added to actors etc. * When the Image object is created, resource loading will be attempted. @@ -56,77 +44,12 @@ const ReleasePolicy ImageReleasePolicyDefault = Dali::Image::Never; */ class Image : public BaseObject, public ResourceTicketObserver { -protected: - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~Image(); - - /** - * Constructor, with default parameters - */ - Image(LoadPolicy loadPol=ImageLoadPolicyDefault, ReleasePolicy releasePol=ImageReleasePolicyDefault); - public: - /** - * Creates a pointer to an uninitialized Image object. - * @return a pointer to a newly created object. - */ - static ImagePtr New(); - - /** - * Creates object and loads image from filesystem - * the maximum size of the image is limited by GL_MAX_TEXTURE_SIZE - * @param [in] filename the path of the image on the filesystem - * @param [in] attributes requested parameters for loading (size, scaling etc.) - * if width or height is specified as 0, the natural size will be used. - * @param [in] loadPol controls time of loading a resource from the filesystem (default: load when Image is created). - * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive). - * @return a pointer to a newly created object. - */ - static ImagePtr New( const std::string& filename, - const Dali::ImageAttributes& attributes=Dali::ImageAttributes::DEFAULT_ATTRIBUTES, - LoadPolicy loadPol=ImageLoadPolicyDefault, - ReleasePolicy releasePol=ImageReleasePolicyDefault ); - - /** - * Creates object with already loaded NativeImage - * the maximum size of the image is limited by GL_MAX_TEXTURE_SIZE - * @pre nativeImg should be initialised - * @param [in] nativeImg already initialised NativeImage - * @param [in] loadPol controls time of loading a resource from the filesystem (default: load when Image is created). - * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive). - * @return a pointer to a newly created object. - */ - static ImagePtr New( NativeImage& nativeImg, - LoadPolicy loadPol=ImageLoadPolicyDefault, - ReleasePolicy releasePol=ImageReleasePolicyDefault ); - - /** - * @copydoc Dali::Image::GetLoadingState() - */ - Dali::LoadingState GetLoadingState() const { return mTicket ? mTicket->GetLoadingState() : ResourceLoading; } - - /** - * @copydoc Dali::Image::GetLoadPolicy() - */ - LoadPolicy GetLoadPolicy () const { return mLoadPolicy; } - - /** - * @copydoc Dali::Image::GetReleasePolicy() - */ - ReleasePolicy GetReleasePolicy () const { return mReleasePolicy; } - - /** - * @copydoc Dali::Image::LoadingFinishedSignal() - */ - Dali::Image::ImageSignalV2& LoadingFinishedSignal() { return mLoadingFinishedV2; } /** * @copydoc Dali::Image::UploadedSignal() */ - Dali::Image::ImageSignalV2& UploadedSignal() { return mUploadedV2; } + Dali::Image::ImageSignalType& UploadedSignal() { return mUploaded; } /** * Connects a callback function with the object's signals. @@ -147,50 +70,28 @@ public: ResourceId GetResourceId() const; /** - * Get the attributes of the image. - * Only to be used after the image has finished loading. - * (Ticket's LoadingSucceeded callback was called) - * Reflects the last cached values after a LoadComplete. - * If requested width or height was 0, they are replaced by concrete dimensions. - * @return a copy of the attributes - */ - const Dali::ImageAttributes& GetAttributes() const; - - /** * Get the width of the image. * Only to be used after the image has finished loading. * (Ticket's LoadingSucceeded callback was called) * The returned value will reflect the true image dimensions once the asynchronous loading has finished. - * Connect to SignalLoadingFinished or use GetLoadingState to make sure this value is actual. * @pre image should be loaded */ - unsigned int GetWidth() const; + virtual unsigned int GetWidth() const; /** * Get the height of the image. * Only to be used after the image has finished loading. * (Ticket's LoadingSucceeded callback was called) * The returned value will reflect the true image dimensions once the asynchronous loading has finished. - * Connect to SignalLoadingFinished or use GetLoadingState to make sure this value is actual. * @pre image should be loaded */ - unsigned int GetHeight() const; + virtual unsigned int GetHeight() const; /** * Return the natural size of the image. * This is the size that the loaded image will take */ - Vector2 GetNaturalSize() const; - - /** - * @copydoc Dali::Image::GetFilename() - */ - const std::string& GetFilename() const; - - /** - * @copydoc Dali::Image::Reload() - */ - void Reload(); + virtual Vector2 GetNaturalSize() const; public: // From ResourceTicketObserver @@ -209,70 +110,47 @@ public: // From ResourceTicketObserver */ virtual void ResourceUploaded(const ResourceTicket& ticket); - /** - * @copydoc Dali::Internal::ResourceTicketObserver::ResourceSavingSucceeded() - */ - virtual void ResourceSavingSucceeded( const ResourceTicket& ticket ); - - /** - * @copydoc Dali::Internal::ResourceTicketObserver::ResourceSavingFailed() - */ - virtual void ResourceSavingFailed( const ResourceTicket& ticket ); - public: /** * Indicates that the image is used. */ - virtual void Connect(); + virtual void Connect() {} /** * Indicates that the image is not used anymore. */ - virtual void Disconnect(); + virtual void Disconnect() {} protected: + /** - * Second stage initialization + * A reference counted object may only be deleted by calling Unreference() */ - void Initialize(); - -private: + virtual ~Image(); /** - * Helper method to set new resource ticket. Stops observing current ticket if any, and starts observing - * the new one or just resets the intrusive pointer. - * @param[in] ticket pointer to new resource Ticket or NULL. + * Constructor, with default parameters */ - void SetTicket( ResourceTicket* ticket ); + Image(); /** - * Helper method to determine if the filename indicates that the image has a 9 patch border. - * @param[in] filename The filename to check - * @return true if it is a 9 patch image + * Second stage initialization */ - static bool IsNinePatchFileName( std::string filename ); - + void Initialize(); protected: - unsigned int mWidth; - unsigned int mHeight; - bool mNaturalSizeSet; - ResourceTicketPtr mTicket; - ImageFactoryCache::RequestPtr mRequest; ///< contains the initially requested attributes for image. Request is reissued when memory was released. - LoadPolicy mLoadPolicy; - ReleasePolicy mReleasePolicy; + ResourceTicketPtr mTicket; ///< smart pointer to the ticket object that gets completed when load finishes + + mutable unsigned int mWidth; ///< natural width of the image, needs to be mutable for lazy resolving and as the API for GetWidth is const + mutable unsigned int mHeight; ///< natural height of the image, needs to be mutable for lazy resolving and as the API for GetHeight is const - unsigned int mConnectionCount; ///< number of on-stage objects using this image - ImageFactory& mImageFactory; + unsigned int mConnectionCount; ///< number of on-stage objects using this image private: - Dali::Image::ImageSignalV2 mLoadingFinishedV2; - Dali::Image::ImageSignalV2 mUploadedV2; - // Changes scope, should be at end of class - DALI_LOG_OBJECT_STRING_DECLARATION; + Dali::Image::ImageSignalType mUploaded; }; } // namespace Internal