X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fimages%2Fimage-impl.h;h=d517b8cc8f01553bc1d4e9aebe35a0b5fffe2c88;hb=b046151664c733d32951d1cef5dcbaae46f14467;hp=23d614ec71a612543c37270119e53f22c3861cbb;hpb=e3dcaae9073dea03bdcdb892814114bc638ea807;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 23d614e..d517b8c 100644 --- a/dali/internal/event/images/image-impl.h +++ b/dali/internal/event/images/image-impl.h @@ -1,21 +1,22 @@ #ifndef __DALI_INTERNAL_IMAGE_H__ #define __DALI_INTERNAL_IMAGE_H__ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.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://floralicense.org/license/ -// -// 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. -// +/* + * Copyright (c) 2014 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 @@ -24,29 +25,22 @@ #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; +const ReleasePolicy IMAGE_RELEASE_POLICY_DEFAULT = Dali::Image::NEVER; /** * Image represents an image resource that can be added to actors etc. @@ -55,42 +49,6 @@ 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 - */ - 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 Image* 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, cropping 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 Image* New(const std::string& filename, - const Dali::ImageAttributes& attributes=Dali::ImageAttributes::DEFAULT_ATTRIBUTES, - LoadPolicy loadPol=ImageLoadPolicyDefault, - ReleasePolicy releasePol=ImageReleasePolicyDefault); - - - public: /** @@ -98,23 +56,9 @@ public: * 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 Image* 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; } + static ImagePtr New( NativeImage& nativeImg ); /** * @copydoc Dali::Image::GetReleasePolicy() @@ -122,14 +66,9 @@ public: 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. @@ -150,16 +89,6 @@ 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) @@ -167,7 +96,7 @@ public: * 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. @@ -177,23 +106,13 @@ public: * 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 @@ -227,40 +146,44 @@ 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() {} -private: +protected: + + /** + * A reference counted object may only be deleted by calling Unreference() + */ + 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( ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT ); + + /** + * Second stage initialization + */ + void Initialize(); protected: - unsigned int mWidth; - unsigned int mHeight; - 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 - unsigned int mConnectionCount; ///< number of on-stage objects using this image - ImageFactory& mImageFactory; + ReleasePolicy mReleasePolicy : 2; ///< 2 bits is enough space 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