1 #ifndef DALI_GRAPHICS_GLES_TEXTURE_H
2 #define DALI_GRAPHICS_GLES_TEXTURE_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.
22 #include <dali/graphics-api/graphics-command-buffer.h>
23 #include <dali/graphics-api/graphics-texture-create-info.h>
24 #include <dali/graphics-api/graphics-texture.h>
25 #include <dali/integration-api/gl-abstraction.h>
28 #include "gles-graphics-resource.h"
30 namespace Dali::Graphics::GLES
32 using TextureResource = Resource<Graphics::Texture, Graphics::TextureCreateInfo>;
35 * The Texture class represents a GPU texture object. It's slightly
36 * higher level than the Vulkan VkImage (more like combined image sampler).
38 class Texture : public TextureResource
43 * @param[in] createInfo valid TextureCreateInfo structure
44 * @param[in] controller Reference to the Controller
46 Texture(const Graphics::TextureCreateInfo& createInfo, Graphics::EglGraphicsController& controller);
51 ~Texture() override = default;
54 * @brief Called when GL resources are destroyed
56 void DestroyResource() override;
59 * @brief Returns the Gl texture
60 * @return GL texture id
62 [[nodiscard]] uint32_t GetGLTexture() const
68 * @brief Called when initializing the resource
70 * @return True on success
72 bool InitializeResource() override;
75 * @brief Called when UniquePtr<> on client-side dies
77 void DiscardResource() override;
79 void Bind(const TextureBinding& binding) const;
82 * @brief used to prepare native texture before drawing.
84 * Checks if native texture has changed size (e.g. if rotated)
85 * and updates as appropriate.
87 * Gives the callback a chance to draw to the backing texture.
92 * @brief Returns the GL Target
93 * @return the Gl target
95 [[nodiscard]] GLenum GetGlTarget() const
102 std::vector<char> mStagingBuffer;
103 uint32_t mTextureId{0u};
104 GLenum mGlTarget{0u};
105 void* mGLOwnerContext{nullptr};
106 bool InitializeNativeImage();
107 bool InitializeTexture();
109 } // namespace Dali::Graphics::GLES