1 #ifndef DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H
2 #define DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H
5 * Copyright (c) 2021 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()
96 * Protected constructor; See also TextureSet::New()
101 Vector<Render::Sampler*> mSamplers; ///< List of samplers used by each texture. Not owned
102 Vector<Render::Texture*> mTextures; ///< List of Textures. Not owned
103 bool mHasAlpha; ///< if any of the textures has an alpha channel
106 inline void SetTextureMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Texture* texture)
108 using LocalType = MessageValue2<TextureSet, uint32_t, Render::Texture*>;
110 // Reserve some memory inside the message queue
111 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
113 // Construct message in the message queue memory; note that delete should not be called on the return value
114 new(slot) LocalType(&textureSet, &TextureSet::SetTexture, index, texture);
117 inline void SetSamplerMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Sampler* sampler)
119 using LocalType = MessageValue2<TextureSet, uint32_t, Render::Sampler*>;
121 // Reserve some memory inside the message queue
122 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
124 // Construct message in the message queue memory; note that delete should not be called on the return value
125 new(slot) LocalType(&textureSet, &TextureSet::SetSampler, index, sampler);
128 } // namespace SceneGraph
130 } // namespace Internal
134 #endif // DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H