Merge branch 'devel/master' 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) 2021 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/internal/event/common/object-impl.h>     // Dali::Internal::Object
26 #include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
27 #include <dali/internal/event/rendering/shader-impl.h>  // Dali::Internal::Shader
28 #include <dali/internal/event/rendering/texture-impl.h> // Dali::Internal::Texture
29 #include <dali/public-api/common/dali-common.h>         // DALI_ASSERT_ALWAYS
30 #include <dali/public-api/common/intrusive-ptr.h>       // Dali::IntrusivePtr
31 #include <dali/public-api/rendering/texture-set.h>      // Dali::TextureSet
32
33 namespace Dali
34 {
35 namespace Internal
36 {
37 namespace SceneGraph
38 {
39 class TextureSet;
40 }
41
42 class TextureSet;
43 using TextureSetPtr = IntrusivePtr<TextureSet>;
44
45 /**
46  * TextureSet is an object that holds all the textures used by a renderer
47  */
48 class TextureSet : public BaseObject
49 {
50 public:
51   /**
52    * @copydoc Dali::TextureSet::New()
53    */
54   static TextureSetPtr New();
55
56   /**
57    * @copydoc Dali::TextureSet::SetTexture()
58    */
59   void SetTexture(uint32_t index, TexturePtr texture);
60
61   /**
62    * @copydoc Dali::TextureSet::GetTexture()
63    */
64   Texture* GetTexture(uint32_t index) const;
65
66   /**
67    * @copydoc Dali::TextureSet::SetSampler()
68    */
69   void SetSampler(uint32_t index, SamplerPtr sampler);
70
71   /**
72    * @copydoc Dali::TextureSet::GetSampler()
73    */
74   Sampler* GetSampler(uint32_t index) const;
75
76   /**
77    * @copydoc Dali::TextureSet::GetTextureCount()
78    */
79   uint32_t GetTextureCount() const;
80
81   /**
82    * @brief Get the TextureSet scene object
83    *
84    * @return the texture set scene object
85    */
86   const SceneGraph::TextureSet* GetTextureSetSceneObject() const;
87
88 private: // implementation
89   TextureSet();
90
91   /**
92    * Second stage initialization
93    */
94   void Initialize();
95
96 protected:
97   /**
98    * A reference counted object may only be deleted by calling Unreference()
99    */
100   ~TextureSet() override;
101
102 private: // unimplemented methods
103   TextureSet(const TextureSet&);
104   TextureSet& operator=(const TextureSet&);
105
106 private:                                        // Data
107   EventThreadServices&    mEventThreadServices; ///<Used to send messages to the update thread
108   SceneGraph::TextureSet* mSceneObject;
109   std::vector<SamplerPtr> mSamplers;
110   std::vector<TexturePtr> mTextures;
111 };
112
113 } // namespace Internal
114
115 // Helpers for public-api forwarding methods
116 inline Internal::TextureSet& GetImplementation(Dali::TextureSet& handle)
117 {
118   DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
119
120   BaseObject& object = handle.GetBaseObject();
121
122   return static_cast<Internal::TextureSet&>(object);
123 }
124
125 inline const Internal::TextureSet& GetImplementation(const Dali::TextureSet& handle)
126 {
127   DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
128
129   const BaseObject& object = handle.GetBaseObject();
130
131   return static_cast<const Internal::TextureSet&>(object);
132 }
133
134 } // namespace Dali
135
136 #endif // DALI_INTERNAL_TEXTURE_SET_H