1 #ifndef DALI_INTERNAL_TEXTURE_SET_H
2 #define DALI_INTERNAL_TEXTURE_SET_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/vector-wrapper.h> // std::vector
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
43 using TextureSetPtr = IntrusivePtr<TextureSet>;
46 * TextureSet is an object that holds all the textures used by a renderer
48 class TextureSet : public BaseObject
52 * @copydoc Dali::TextureSet::New()
54 static TextureSetPtr New();
57 * @copydoc Dali::TextureSet::SetTexture()
59 void SetTexture(uint32_t index, TexturePtr texture);
62 * @copydoc Dali::TextureSet::GetTexture()
64 Texture* GetTexture(uint32_t index) const;
67 * @copydoc Dali::TextureSet::SetSampler()
69 void SetSampler(uint32_t index, SamplerPtr sampler);
72 * @copydoc Dali::TextureSet::GetSampler()
74 Sampler* GetSampler(uint32_t index) const;
77 * @copydoc Dali::TextureSet::GetTextureCount()
79 uint32_t GetTextureCount() const;
82 * @brief Get the TextureSet scene object
84 * @return the texture set scene object
86 const SceneGraph::TextureSet* GetTextureSetSceneObject() const;
88 private: // implementation
92 * Second stage initialization
97 * @brief Change the count of texture and sampler. It will increase count automatically if we need more textures.
99 * @param[in] count The number of textures what this texture set want to hold
101 void SetTextureCount(uint32_t count);
104 * @brief Change the count of sampler. It will increase count automatically if we need more samplers.
106 * @param[in] count The number of samplers what this texture set want to hold
108 void SetSamplerCount(uint32_t count);
111 * @brief Remove empty textures and samplers at the back of container, and resize.
113 void TrimContainers();
117 * A reference counted object may only be deleted by calling Unreference()
119 ~TextureSet() override;
121 private: // unimplemented methods
122 TextureSet(const TextureSet&);
123 TextureSet& operator=(const TextureSet&);
126 EventThreadServices& mEventThreadServices; ///<Used to send messages to the update thread
127 SceneGraph::TextureSet* mSceneObject;
128 std::vector<SamplerPtr> mSamplers;
129 std::vector<TexturePtr> mTextures;
132 } // namespace Internal
134 // Helpers for public-api forwarding methods
135 inline Internal::TextureSet& GetImplementation(Dali::TextureSet& handle)
137 DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
139 BaseObject& object = handle.GetBaseObject();
141 return static_cast<Internal::TextureSet&>(object);
144 inline const Internal::TextureSet& GetImplementation(const Dali::TextureSet& handle)
146 DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
148 const BaseObject& object = handle.GetBaseObject();
150 return static_cast<const Internal::TextureSet&>(object);
155 #endif // DALI_INTERNAL_TEXTURE_SET_H