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