Remove TypeRegistration from deprecated Image classes
[platform/core/uifw/dali-core.git] / dali / internal / event / images / image-impl.h
index e870ccb..de6df50 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/public-api/images/image.h>
-#include <dali/public-api/images/native-image.h>
 #include <dali/public-api/object/base-object.h>
-#include <dali/internal/render/gl-resources/texture.h>
-#include <dali/internal/event/images/image-factory-cache.h>
-#include <dali/internal/event/resources/image-ticket.h>
-#include <dali/internal/event/resources/resource-client.h>
-#include <dali/internal/event/resources/resource-ticket-observer.h>
+#include <dali/internal/event/rendering/texture-impl.h>
 
 namespace Dali
 {
 
-class NativeImage;
-
 namespace Internal
 {
 
-typedef Dali::Image::LoadPolicy    LoadPolicy;
-typedef Dali::Image::ReleasePolicy ReleasePolicy;
-
 class Image;
 class ImageFactory;
 typedef IntrusivePtr<Image> 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.
  * Provided this is successful, the resource will exist until the Image is destroyed.
  */
-class Image : public BaseObject, public ResourceTicketObserver
+class Image : public BaseObject
 {
-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,
-                       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
-   * @return a pointer to a newly created object.
-   */
-  static ImagePtr New( NativeImage& nativeImg );
-
-  /**
-   * @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::ImageSignalType& LoadingFinishedSignal() { return mLoadingFinished; }
 
   /**
    * @copydoc Dali::Image::UploadedSignal()
@@ -125,153 +51,78 @@ 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 );
-
-  /**
-   * returns the Id used for lookups
-   * @note if LoadPolicy::OnDemand is used and Image is off Stage, this will return 0.
-   * @return the unique ID of the image data resource. This is actually also the same as Dali Texture id.
-   */
-  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();
-
-public: // From ResourceTicketObserver
-
-  /**
-   * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingFailed()
-   */
-  virtual void ResourceLoadingFailed(const ResourceTicket& ticket);
-
-  /**
-   * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingSucceeded()
-   */
-  virtual void ResourceLoadingSucceeded(const ResourceTicket& ticket);
+  virtual Vector2 GetNaturalSize() const;
 
   /**
-   * @copydoc Dali::Internal::ResourceTicketObserver::ResourceUploaded()
+   * Returns a pointer to the internal texture used by the image
    */
-  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 );
+  Texture* GetTexture() const
+  {
+    return mTexture.Get();
+  }
 
 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( const std::string& filename );
-
-protected: //@TODO these should not be protected
-
-  ImageFactory&  mImageFactory;
+  void Initialize();
 
-  ImageFactoryCache::RequestPtr mRequest; ///< contains the initially requested attributes for image. Request is reissued when memory was released.
-  ResourceTicketPtr mTicket;              ///< smart pointer to the ticket object that gets completed when load finishes
+protected:
 
-  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
+  TexturePtr mTexture;  ///< smart pointer to the texture used by the image
 
-  unsigned int   mConnectionCount; ///< number of on-stage objects using this image
+  unsigned int mWidth;     ///< natural width of the image
+  unsigned int mHeight;    ///< natural height of the image
 
-  LoadPolicy     mLoadPolicy:2;    ///< 2 bits is enough space
-  ReleasePolicy  mReleasePolicy:2; ///< 2 bits is enough space
+  unsigned int mConnectionCount; ///< number of on-stage objects using this image
 
 private:
 
-  Dali::Image::ImageSignalType mLoadingFinished;
   Dali::Image::ImageSignalType mUploaded;
-
-  // Changes scope, should be at end of class
-  DALI_LOG_OBJECT_STRING_DECLARATION;
 };
 
 } // namespace Internal