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 * | image-url | STRING |
49 * | image-fitting-mode | STRING |
50 * | image-sampling-mode | STRING |
51 * | image-desired-width | INT |
52 * | image-desired-height | INT |
54 * where image-fitting-mode should be one of the following fitting modes:
61 * where image-sampling-mode 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( const Property::Map& propertyMap );
122 * @copydoc ControlRenderer::DoSetOnStage
124 virtual void DoSetOnStage( Actor& actor );
127 * @copydoc ControlRenderer::DoSetOffStage
129 virtual void DoSetOffStage( Actor& actor );
132 * @copydoc ControlRenderer::InitializeRenderer
134 virtual void InitializeRenderer( Renderer& renderer );
139 * @brief Sets the image of this renderer to the resource at imageUrl
140 * The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
142 * @param[in] imageUrl The URL to to image resource to use
144 void SetImage( const std::string& imageUrl );
147 * @brief Sets the image of this renderer to the resource at imageUrl
148 * The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
150 * @param[in] imageUrl The URL to to image resource to use
151 * @param[in] desiredWidth The desired width of the resource to load
152 * @param[in] desiredHeight The desired height of the resource to load
153 * @param[in] fittingMode The FittingMode of the resource to load
154 * @param[in] samplingMode The SamplingMode of the resource to load
156 void SetImage( const std::string& imageUrl, int desiredWidth, int desiredHeight, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode );
159 * @brief Sets the image of this renderer to use
161 * @param[in] image The image to use
163 void SetImage( Image image );
166 * @brief Gets the image this renderer uses
168 * @return The image this renderer uses, which may be null if the image is set from a URL string and the renderer is not set as onstage
170 Image GetImage() const;
175 * @brief Applies this renderer's image to the sampler to the material used for this renderer
177 void ApplyImageToSampler();
180 * Callback function of image resource loading succeed
181 * @param[in] image The Image content that we attempted to load from mImageUrl
183 void OnImageLoaded( ResourceImage image );
188 std::string mImageUrl;
189 Dali::ImageDimensions mDesiredSize;
190 Dali::FittingMode::Type mFittingMode;
191 Dali::SamplingMode::Type mSamplingMode;
195 } // namespace Internal
197 } // namespace Toolkit
201 #endif /* __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__ */