1 #ifndef __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__
5 * Copyright (c) 2015 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.
22 #include <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
25 #include <dali/public-api/images/image.h>
26 #include <dali/public-api/images/image-operations.h>
27 #include <dali/public-api/images/resource-image.h>
39 typedef IntrusivePtr< ImageRenderer > ImageRendererPtr;
42 * The renderer which renders an image to the control's quad
44 * The following properties are optional
46 * | %Property Name | Type |
47 * |-------------------------|------------------|
48 * | imageUrl | STRING |
49 * | imageFittingMode | STRING |
50 * | imageSamplingMode | STRING |
51 * | imageDesiredWidth | INT |
52 * | imageDesiredHeight | INT |
54 * where imageFittingMode should be one of the following fitting modes:
61 * where imageSamplingMode should be one of the following sampling modes:
72 class ImageRenderer: public ControlRenderer, public ConnectionTracker
79 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
81 ImageRenderer( RendererFactoryCache& factoryCache );
84 * @brief A reference counted object may only be deleted by calling Unreference().
88 public: // from ControlRenderer
91 * @copydoc ControlRenderer::SetSize
93 virtual void SetSize( const Vector2& size );
96 * @copydoc ControlRenderer::GetNaturalSize
98 virtual void GetNaturalSize( Vector2& naturalSize ) const;
101 * @copydoc ControlRenderer::SetClipRect
103 virtual void SetClipRect( const Rect<int>& clipRect );
106 * @copydoc ControlRenderer::SetOffset
108 virtual void SetOffset( const Vector2& offset );
111 * @copydoc ControlRenderer::CreatePropertyMap
113 virtual void DoCreatePropertyMap( Property::Map& map ) const;
117 * @copydoc ControlRenderer::DoInitialize
119 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
122 * @copydoc ControlRenderer::DoSetOnStage
124 virtual void DoSetOnStage( Actor& actor );
127 * @copydoc ControlRenderer::DoSetOffStage
129 virtual void DoSetOffStage( Actor& actor );
134 * @brief Sets the image of this renderer to the resource at imageUrl
135 * The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
137 * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
138 * @param[in] imageUrl The URL to to image resource to use
140 void SetImage( Actor& actor, const std::string& imageUrl );
143 * @brief Sets the image of this renderer to the resource at imageUrl
144 * The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
146 * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
147 * @param[in] imageUrl The URL to to image resource to use
148 * @param[in] desiredWidth The desired width of the resource to load
149 * @param[in] desiredHeight The desired height of the resource to load
150 * @param[in] fittingMode The FittingMode of the resource to load
151 * @param[in] samplingMode The SamplingMode of the resource to load
153 void SetImage( Actor& actor, const std::string& imageUrl, int desiredWidth, int desiredHeight, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode );
156 * @brief Sets the image of this renderer to use
158 * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
159 * @param[in] image The image to use
161 void SetImage( Actor& actor, const Image& image );
166 * @brief Applies the image to the material used for this renderer
168 * @param[in] image The Image to apply to the material used for this renderer
170 void ApplyImageToSampler( const Image& image );
173 * @brief Initializes the Dali::Renderer from an image url string
175 * @param[in] imageUrl The image url string to intialize this ImageRenderer from
177 void InitializeRenderer( const std::string& imageUrl );
180 * @brief Initializes the Dali::Renderer from an image handle
182 * @param[in] image The image handle to intialize this ImageRenderer from
184 void InitializeRenderer( const Image& image );
187 * @brief Creates the Dali::Renderer (potentially from the renderer cache), initializing it
189 * @return Returns the created Dali::Renderer
191 Renderer CreateRenderer() const;
194 * Callback function of image resource loading succeed
195 * @param[in] image The Image content that we attempted to load from mImageUrl
197 void OnImageLoaded( ResourceImage image );
202 std::string mImageUrl;
203 Dali::ImageDimensions mDesiredSize;
204 Dali::FittingMode::Type mFittingMode;
205 Dali::SamplingMode::Type mSamplingMode;
209 } // namespace Internal
211 } // namespace Toolkit
215 #endif /* __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__ */