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 * 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
60 virtual unsigned int GetWidth() const;
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
69 virtual unsigned int GetHeight() const;
72 * Return the natural size of the image.
73 * This is the size that the loaded image will take
75 virtual Vector2 GetNaturalSize() const;
78 * Returns a pointer to the internal texture used by the image
80 Texture* GetTexture() const
82 return mTexture.Get();
88 * Indicates that the image is used.
90 virtual void Connect() {}
93 * Indicates that the image is not used anymore.
95 virtual void Disconnect() {}
100 * A reference counted object may only be deleted by calling Unreference()
105 * Constructor, with default parameters
110 * Second stage initialization
116 TexturePtr mTexture; ///< smart pointer to the texture used by the image
118 unsigned int mWidth; ///< natural width of the image
119 unsigned int mHeight; ///< natural height of the image
121 unsigned int mConnectionCount; ///< number of on-stage objects using this image
125 Dali::Image::ImageSignalType mUploaded;
128 } // namespace Internal
131 * Helper methods for public API.
133 inline Internal::Image& GetImplementation(Dali::Image& image)
135 DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
137 BaseObject& handle = image.GetBaseObject();
139 return static_cast<Internal::Image&>(handle);
142 inline const Internal::Image& GetImplementation(const Dali::Image& image)
144 DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
146 const BaseObject& handle = image.GetBaseObject();
148 return static_cast<const Internal::Image&>(handle);
152 #endif // __DALI_INTERNAL_IMAGE_H__