Merge "Added bezier curve control points to TransitionData" into devel/master
[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 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23
24 // INTERNAL HEADER
25 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
26 #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace Internal
33 {
34
35 class BatchImageVisual;
36 typedef IntrusivePtr< BatchImageVisual > BatchImageVisualPtr;
37
38 class BatchImageVisual: public Visual::Base, public ConnectionTracker
39 {
40 public:
41
42   /**
43    * @brief Create a new batch-image visual.
44    *
45    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
46    * @return A smart-pointer to the newly allocated visual.
47    */
48   static BatchImageVisualPtr New( VisualFactoryCache& factoryCache );
49
50 public:  // from Visual
51
52   /**
53    * @copydoc Visual::Base::SetSize
54    */
55   virtual void SetSize( const Vector2& size );
56
57   /**
58    * @copydoc Visual::Base::GetNaturalSize
59    */
60   virtual void GetNaturalSize( Vector2& naturalSize ) const;
61
62   /**
63    * @copydoc Visual::Base::CreatePropertyMap
64    */
65   virtual void DoCreatePropertyMap( Property::Map& map ) const;
66
67   /**
68    * @copydoc Visual::Base::DoSetProperty
69    */
70   virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
71
72   /**
73    * @copydoc Visual::Base::DoGetProperty
74    */
75   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
76
77 protected:
78
79   /**
80    * @brief Constructor.
81    *
82    * @param[in] factoryCache The VisualFactoryCache object
83    */
84   BatchImageVisual( VisualFactoryCache& factoryCache );
85
86   /**
87    * @brief A reference counted object may only be deleted by calling Unreference().
88    */
89   ~BatchImageVisual();
90
91   /**
92    * @copydoc Visua::Base::DoSetProperties
93    */
94   virtual void DoSetProperties( const Property::Map& propertyMap );
95
96   /**
97    * @copydoc Visual::Base::DoSetOnStage
98    */
99   virtual void DoSetOnStage( Actor& actor );
100
101   /**
102    * @copydoc Visual::Base::DoSetOffStage
103    */
104   virtual void DoSetOffStage( Actor& actor );
105
106 private:
107
108   /**
109    * Get the batch image rendering shader.
110    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
111    */
112   static Shader GetBatchShader( VisualFactoryCache& factoryCache );
113
114   /**
115    * @brief Initializes the Dali::Renderer from an image url string
116    *
117    * @param[in] imageUrl The image url string to intialize this ImageVisual from
118    */
119   void InitializeRenderer( const std::string& imageUrl );
120
121   /**
122    * Clean the Visual from cache, and remove the image from atlas if it is not used anymore
123    */
124   void CleanCache( const std::string& url );
125
126 private:
127
128   Vector4                 mAtlasRect;
129   std::string             mImageUrl;
130   Dali::ImageDimensions   mDesiredSize;
131 };
132
133 } // namespace Internal
134
135 } // namespace Toolkit
136
137 } // namespace Dali
138
139 #endif // DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H