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>
38 typedef IntrusivePtr< ImageRenderer > ImageRendererPtr;
41 * The renderer which renders an image to the control's quad
43 * The following properties are optional
45 * | %Property Name | Type |
46 * |---------------------------|------------------|
47 * | image-url | STRING |
48 * | image-fitting-mode | STRING |
49 * | image-sampling-mode | STRING |
50 * | image-desired-width | INT |
51 * | image-desired-height | INT |
53 * where image-fitting-mode should be one of the following fitting modes:
60 * where image-sampling-mode should be one of the following sampling modes:
71 class ImageRenderer: public ControlRenderer
81 * @brief A reference counted object may only be deleted by calling Unreference().
85 public: // from ControlRenderer
88 * @copydoc ControlRenderer::Initialize
90 virtual void Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap );
93 * @copydoc ControlRenderer::SetSize
95 virtual void SetSize( const Vector2& size );
98 * @copydoc ControlRenderer::SetClipRect
100 virtual void SetClipRect( const Rect<int>& clipRect );
103 * @copydoc ControlRenderer::SetOffset
105 virtual void SetOffset( const Vector2& offset );
109 * @copydoc ControlRenderer::DoSetOnStage
111 virtual void DoSetOnStage( Actor& actor );
114 * @copydoc ControlRenderer::DoSetOffStage
116 virtual void DoSetOffStage( Actor& actor );
121 * Request the geometry and shader from the cache, if not available, create and save to the cache for sharing.
123 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
125 void Initialize( RendererFactoryCache& factoryCache );
128 * @brief Sets the image of this renderer to the resource at imageUrl
129 * The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
131 * @param[in] imageUrl The URL to to image resource to use
133 void SetImage( const std::string& imageUrl );
136 * @brief Sets the image of this renderer to the resource at imageUrl
137 * The renderer will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
139 * @param[in] imageUrl The URL to to image resource to use
140 * @param[in] desiredWidth The desired width of the resource to load
141 * @param[in] desiredHeight The desired height of the resource to load
142 * @param[in] fittingMode The FittingMode of the resource to load
143 * @param[in] samplingMode The SamplingMode of the resource to load
145 void SetImage( const std::string& imageUrl, int desiredWidth, int desiredHeight, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode );
148 * @brief Sets the image of this renderer to use
150 * @param[in] image The image to use
152 void SetImage( Image image );
155 * @brief Gets the image this renderer uses
157 * @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
159 Image GetImage() const;
164 * @brief Applies this renderer's image to the sampler to the material used for this renderer
166 void ApplyImageToSampler();
171 std::string mImageUrl;
172 Dali::ImageDimensions mDesiredSize;
173 Dali::FittingMode::Type mFittingMode;
174 Dali::SamplingMode::Type mSamplingMode;
178 } // namespace Internal
180 } // namespace Toolkit
184 #endif /* __DALI_TOOLKIT_INTERNAL_IMAGE_RENDERER_H__ */