Remove TypeRegistration from deprecated Image classes
[platform/core/uifw/dali-core.git] / dali / internal / event / images / image-impl.h
1 #ifndef __DALI_INTERNAL_IMAGE_H__
2 #define __DALI_INTERNAL_IMAGE_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/image.h>
26 #include <dali/public-api/object/base-object.h>
27 #include <dali/internal/event/rendering/texture-impl.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 class Image;
36 class ImageFactory;
37 typedef IntrusivePtr<Image> ImagePtr;
38
39 /**
40  * Image represents an image resource that can be added to actors etc.
41  * When the Image object is created, resource loading will be attempted.
42  * Provided this is successful, the resource will exist until the Image is destroyed.
43  */
44 class Image : public BaseObject
45 {
46 public:
47
48   /**
49    * @copydoc Dali::Image::UploadedSignal()
50    */
51   Dali::Image::ImageSignalType& UploadedSignal() { return mUploaded; }
52
53   /**
54    * Get the width of the image.
55    * Only to be used after the image has finished loading.
56    * (Ticket's LoadingSucceeded callback was called)
57    * The returned value will reflect the true image dimensions once the asynchronous loading has finished.
58    * @pre image should be loaded
59    */
60   virtual unsigned int GetWidth() const;
61
62   /**
63    * Get the height of the image.
64    * Only to be used after the image has finished loading.
65    * (Ticket's LoadingSucceeded callback was called)
66    * The returned value will reflect the true image dimensions once the asynchronous loading has finished.
67    * @pre image should be loaded
68    */
69   virtual unsigned int GetHeight() const;
70
71   /**
72    * Return the natural size of the image.
73    * This is the size that the loaded image will take
74    */
75   virtual Vector2 GetNaturalSize() const;
76
77   /**
78    * Returns a pointer to the internal texture used by the image
79    */
80   Texture* GetTexture() const
81   {
82     return mTexture.Get();
83   }
84
85 public:
86
87   /**
88    * Indicates that the image is used.
89    */
90   virtual void Connect() {}
91
92   /**
93    * Indicates that the image is not used anymore.
94    */
95   virtual void Disconnect() {}
96
97 protected:
98
99   /**
100    * A reference counted object may only be deleted by calling Unreference()
101    */
102   virtual ~Image();
103
104   /**
105    * Constructor, with default parameters
106    */
107   Image();
108
109   /**
110    * Second stage initialization
111    */
112   void Initialize();
113
114 protected:
115
116   TexturePtr mTexture;  ///< smart pointer to the texture used by the image
117
118   unsigned int mWidth;     ///< natural width of the image
119   unsigned int mHeight;    ///< natural height of the image
120
121   unsigned int mConnectionCount; ///< number of on-stage objects using this image
122
123 private:
124
125   Dali::Image::ImageSignalType mUploaded;
126 };
127
128 } // namespace Internal
129
130 /**
131  * Helper methods for public API.
132  */
133 inline Internal::Image& GetImplementation(Dali::Image& image)
134 {
135   DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
136
137   BaseObject& handle = image.GetBaseObject();
138
139   return static_cast<Internal::Image&>(handle);
140 }
141
142 inline const Internal::Image& GetImplementation(const Dali::Image& image)
143 {
144   DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
145
146   const BaseObject& handle = image.GetBaseObject();
147
148   return static_cast<const Internal::Image&>(handle);
149 }
150
151 } // namespace Dali
152 #endif // __DALI_INTERNAL_IMAGE_H__