Wrap Mode support for ImageVisual
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image / batch-image-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL HEADER
22 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
23 #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
24
25 // EXTERNAL INCLUDES
26 #include <dali/public-api/images/resource-image.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace Internal
33 {
34
35 class BatchImageVisual: public Visual::Base, public ConnectionTracker
36 {
37 public:
38
39   /**
40    * @brief Constructor.
41    *
42    * @param[in] factoryCache The VisualFactoryCache object
43    */
44   BatchImageVisual( VisualFactoryCache& factoryCache );
45
46   /**
47    * @brief A reference counted object may only be deleted by calling Unreference().
48    */
49   ~BatchImageVisual();
50
51 public:  // from Visual
52
53   /**
54    * @copydoc Visual::Base::SetSize
55    */
56   virtual void SetSize( const Vector2& size );
57
58   /**
59    * @copydoc Visual::Base::GetNaturalSize
60    */
61   virtual void GetNaturalSize( Vector2& naturalSize ) const;
62
63   /**
64    * @copydoc Visual::Base::SetClipRect
65    */
66   virtual void SetClipRect( const Rect<int>& clipRect );
67
68   /**
69    * @copydoc Visual::Base::CreatePropertyMap
70    */
71   virtual void DoCreatePropertyMap( Property::Map& map ) const;
72
73 protected:
74
75   /**
76    * @copydoc Visua::Base::DoInitialize
77    */
78   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
79
80   /**
81    * @copydoc Visual::Base::DoSetOnStage
82    */
83   virtual void DoSetOnStage( Actor& actor );
84
85   /**
86    * @copydoc Visual::Base::DoSetOffStage
87    */
88   virtual void DoSetOffStage( Actor& actor );
89
90 private:
91
92   /**
93    * Get the batch image rendering shader.
94    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
95    */
96   static Shader GetBatchShader( VisualFactoryCache& factoryCache );
97
98   /**
99    * @brief Initializes the Dali::Renderer from an image url string
100    *
101    * @param[in] imageUrl The image url string to intialize this ImageVisual from
102    */
103   void InitializeRenderer( const std::string& imageUrl );
104
105   /**
106    * Clean the Visual from cache, and remove the image from atlas if it is not used anymore
107    */
108   void CleanCache( const std::string& url );
109
110 private:
111
112   Vector4                 mAtlasRect;
113   std::string             mImageUrl;
114   Dali::ImageDimensions   mDesiredSize;
115 };
116
117 } // namespace Internal
118
119 } // namespace Toolkit
120
121 } // namespace Dali
122
123 #endif // DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H