1 #ifndef DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H
2 #define DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H
5 * Copyright (c) 2022 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.
21 #include <dali/internal/common/buffer-index.h>
22 #include <dali/internal/common/message.h>
23 #include <dali/internal/event/common/event-thread-services.h>
24 #include <dali/public-api/rendering/texture-set.h>
43 * Construct a new TextureSet.
45 static TextureSet* New();
48 * Destructor. Not virtual as not a base class and not inheriting anything
53 * Overriden delete operator
54 * Deletes the texture set from its global memory pool
56 void operator delete(void* ptr);
59 * Set the sampler to be used by the texture at position "index"
60 * @param[in] index The index of the texture
61 * @param[in] sampler The sampler to be used by the texture
63 void SetSampler(uint32_t index, Render::Sampler* sampler);
66 * Set the texture at position "index"
67 * @param[in] index The index of the texture
68 * @param[in] texture The texture
70 void SetTexture(uint32_t index, Render::Texture* texture);
73 * Return whether any texture in the texture set has an alpha channel
74 * @return true if at least one texture in the texture set has an alpha channel, false otherwise
76 bool HasAlpha() const;
79 * Accessor for textures (used by RenderDataProvider impl)
81 const Vector<Render::Texture*>& GetTextures()
87 * Accessor for samplers (used by RenderDataProvider impl)
89 const Vector<Render::Sampler*>& GetSamplers()
95 * Get the capacity of the memory pools
96 * @return the capacity of the memory pools
98 static uint32_t GetMemoryPoolCapacity();
102 * Protected constructor; See also TextureSet::New()
107 Vector<Render::Sampler*> mSamplers; ///< List of samplers used by each texture. Not owned
108 Vector<Render::Texture*> mTextures; ///< List of Textures. Not owned
109 bool mHasAlpha; ///< if any of the textures has an alpha channel
112 inline void SetTextureMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Texture* texture)
114 using LocalType = MessageValue2<TextureSet, uint32_t, Render::Texture*>;
116 // Reserve some memory inside the message queue
117 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
119 // Construct message in the message queue memory; note that delete should not be called on the return value
120 new(slot) LocalType(&textureSet, &TextureSet::SetTexture, index, texture);
123 inline void SetSamplerMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Sampler* sampler)
125 using LocalType = MessageValue2<TextureSet, uint32_t, Render::Sampler*>;
127 // Reserve some memory inside the message queue
128 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
130 // Construct message in the message queue memory; note that delete should not be called on the return value
131 new(slot) LocalType(&textureSet, &TextureSet::SetSampler, index, sampler);
134 } // namespace SceneGraph
136 } // namespace Internal
140 #endif // DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H