1 #ifndef DALI_GRAPHICS_GLES_SHADER_H
2 #define DALI_GRAPHICS_GLES_SHADER_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/graphics-api/graphics-shader-create-info.h>
23 #include <dali/graphics-api/graphics-shader.h>
26 #include "gles-graphics-resource.h"
28 namespace Dali::Graphics::GLES
35 * @param[in] createInfo Valid createInfo structure
36 * @param[in] controller Reference to the controller
38 ShaderImpl(const Graphics::ShaderCreateInfo& createInfo, Graphics::EglGraphicsController& controller);
45 [[nodiscard]] uint32_t GetRefCount() const;
48 * Whilst unreferenced, increase the flush count and return it
50 * @return The new flush count
52 [[nodiscard]] uint32_t IncreaseFlushCount();
55 * Get the flush count whilst unreferenced
57 * @return the flush count
59 [[nodiscard]] uint32_t GetFlushCount() const;
62 * @brief Compiles shader
64 * @return True on success
66 [[nodiscard]] bool Compile() const;
69 * @brief Destroys GL shader
73 uint32_t GetGLShader() const;
75 [[nodiscard]] const ShaderCreateInfo& GetCreateInfo() const;
77 [[nodiscard]] EglGraphicsController& GetController() const;
82 std::unique_ptr<Impl> mImpl{nullptr};
85 class Shader : public Graphics::Shader
91 * @param[in] impl Pointer to valid implementation
93 explicit Shader(ShaderImpl* impl)
104 [[nodiscard]] ShaderImpl* GetImplementation() const
109 [[nodiscard]] const ShaderCreateInfo& GetCreateInfo() const;
111 bool operator==(const GLES::Shader& shader) const
113 return (shader.mShader == mShader);
116 bool operator==(const GLES::ShaderImpl* shaderImpl) const
118 return (shaderImpl == mShader);
121 bool operator!=(const GLES::Shader& shader) const
123 return (shader.mShader != mShader);
127 * @brief Called when UniquePtr<> on client-side dies.
129 void DiscardResource();
132 * @brief Destroying GL resources
134 * This function is kept for compatibility with Resource<> class
135 * so can the object can be use with templated functions.
137 void DestroyResource()
139 // nothing to do here
143 ShaderImpl* mShader{nullptr};
146 } // namespace Dali::Graphics::GLES