1916e53d5323c5952242f1527a93b37fe99cf527
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / texture-set-impl.h
1 #ifndef DALI_INTERNAL_TEXTURE_SET_H
2 #define DALI_INTERNAL_TEXTURE_SET_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/vector-wrapper.h> // std::vector
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
26 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
27 #include <dali/public-api/rendering/texture-set.h> // Dali::TextureSet
28 #include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
29 #include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
30 #include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
31 #include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
32 #include <dali/internal/event/images/image-impl.h> // Dali::Internal::Image
33 #include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
34 #include <dali/internal/event/rendering/texture-impl.h> // Dali::Internal::Texture
35 #include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
36
37 namespace Dali
38 {
39 namespace Internal
40 {
41 namespace SceneGraph
42 {
43 class TextureSet;
44 }
45
46
47 class TextureSet;
48 typedef IntrusivePtr<TextureSet> TextureSetPtr;
49
50 /**
51  * TextureSet is an object that holds all the textures used by a renderer
52  */
53 class TextureSet : public BaseObject, public Connectable
54 {
55 public:
56
57   /**
58    * @copydoc Dali::TextureSet::New()
59    */
60   static TextureSetPtr New();
61
62   /**
63    * @copydoc Dali::TextureSet::SetImage()
64    */
65   void SetImage( size_t index, ImagePtr image );
66
67   /**
68    * @copydoc Dali::TextureSet::SetTexture()
69    */
70   void SetTexture( size_t index, NewTexturePtr texture );
71
72   /**
73    * @copydoc Dali::TextureSet::GetImage()
74    */
75   Image* GetImage( size_t index ) const;
76
77   /**
78    * @copydoc Dali::TextureSet::GetTexture()
79    */
80   NewTexture* GetTexture( size_t index ) const;
81
82   /**
83    * @copydoc Dali::TextureSet::SetSampler()
84    */
85   void SetSampler( size_t index, SamplerPtr sampler );
86
87   /**
88    * @copydoc Dali::TextureSet::GetSampler()
89    */
90   Sampler* GetSampler( size_t index ) const;
91
92   /**
93    * @copydoc Dali::TextureSet::GetTextureCount()
94    */
95   size_t GetTextureCount() const;
96
97  /**
98    * @brief Get the TextureSet scene object
99    *
100    * @return the texture set scene object
101    */
102   const SceneGraph::TextureSet* GetTextureSetSceneObject() const;
103
104 public: // Functions from Connectable
105   /**
106    * @copydoc Dali::Internal::Connectable::OnStage()
107    */
108   virtual bool OnStage() const;
109
110   /**
111    * @copydoc Dali::Internal::Connectable::Connect()
112    */
113   virtual void Connect();
114
115   /**
116    * @copydoc Dali::Internal::Connectable::Disconnect()
117    */
118   virtual void Disconnect();
119
120 private: // implementation
121
122   TextureSet();
123
124   /**
125    * Second stage initialization
126    */
127   void Initialize();
128
129 protected:
130   /**
131    * A reference counted object may only be deleted by calling Unreference()
132    */
133   virtual ~TextureSet();
134
135 private: // unimplemented methods
136   TextureSet( const TextureSet& );
137   TextureSet& operator=( const TextureSet& );
138
139 private: // Data
140   EventThreadServices& mEventThreadServices;    ///<Used to send messages to the update thread
141   SceneGraph::TextureSet* mSceneObject;
142   std::vector<ImagePtr> mImages;
143   std::vector<SamplerPtr> mSamplers;
144   std::vector<NewTexturePtr> mNewTextures;
145   bool mOnStage;
146
147 };
148
149 } // namespace Internal
150
151 // Helpers for public-api forwarding methods
152 inline Internal::TextureSet& GetImplementation( Dali::TextureSet& handle )
153 {
154   DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
155
156   BaseObject& object = handle.GetBaseObject();
157
158   return static_cast<Internal::TextureSet&>(object);
159 }
160
161 inline const Internal::TextureSet& GetImplementation( const Dali::TextureSet& handle )
162 {
163   DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
164
165   const BaseObject& object = handle.GetBaseObject();
166
167   return static_cast<const Internal::TextureSet&>(object);
168 }
169
170 } // namespace Dali
171
172 #endif // DALI_INTERNAL_TEXTURE_SET_H