1 #ifndef __DALI_INTERNAL_IMAGE_H__
2 #define __DALI_INTERNAL_IMAGE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
37 typedef IntrusivePtr<Image> ImagePtr;
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.
44 class Image : public BaseObject
49 * @copydoc Dali::Image::UploadedSignal()
51 Dali::Image::ImageSignalType& UploadedSignal() { return mUploaded; }
54 * Connects a callback function with the object's signals.
55 * @param[in] object The object providing the signal.
56 * @param[in] tracker Used to disconnect the signal.
57 * @param[in] signalName The signal to connect to.
58 * @param[in] functor A newly allocated FunctorDelegate.
59 * @return True if the signal was connected.
60 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
62 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
65 * Get the width of the image.
66 * Only to be used after the image has finished loading.
67 * (Ticket's LoadingSucceeded callback was called)
68 * The returned value will reflect the true image dimensions once the asynchronous loading has finished.
69 * @pre image should be loaded
71 virtual unsigned int GetWidth() const;
74 * Get the height of the image.
75 * Only to be used after the image has finished loading.
76 * (Ticket's LoadingSucceeded callback was called)
77 * The returned value will reflect the true image dimensions once the asynchronous loading has finished.
78 * @pre image should be loaded
80 virtual unsigned int GetHeight() const;
83 * Return the natural size of the image.
84 * This is the size that the loaded image will take
86 virtual Vector2 GetNaturalSize() const;
89 * Returns a pointer to the internal texture used by the image
91 Texture* GetTexture() const
93 return mTexture.Get();
99 * Indicates that the image is used.
101 virtual void Connect() {}
104 * Indicates that the image is not used anymore.
106 virtual void Disconnect() {}
111 * A reference counted object may only be deleted by calling Unreference()
116 * Constructor, with default parameters
121 * Second stage initialization
127 TexturePtr mTexture; ///< smart pointer to the texture used by the image
129 unsigned int mWidth; ///< natural width of the image
130 unsigned int mHeight; ///< natural height of the image
132 unsigned int mConnectionCount; ///< number of on-stage objects using this image
136 Dali::Image::ImageSignalType mUploaded;
139 } // namespace Internal
142 * Helper methods for public API.
144 inline Internal::Image& GetImplementation(Dali::Image& image)
146 DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
148 BaseObject& handle = image.GetBaseObject();
150 return static_cast<Internal::Image&>(handle);
153 inline const Internal::Image& GetImplementation(const Dali::Image& image)
155 DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
157 const BaseObject& handle = image.GetBaseObject();
159 return static_cast<const Internal::Image&>(handle);
163 #endif // __DALI_INTERNAL_IMAGE_H__