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