1 #ifndef DALI_GRAPHICS_GLES_PROGRAM_H
2 #define DALI_GRAPHICS_GLES_PROGRAM_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/graphics-api/graphics-program-create-info.h>
22 #include <dali/graphics-api/graphics-program.h>
25 #include "gles-graphics-resource.h"
27 namespace Dali::Graphics
33 * @brief Program implementation
35 * Program implementation is owned only by the PipelineCache
37 * Like pipeline, it's created and managed by the PipelineCache
45 * @param[in] createInfo Valid create info structure
46 * @param[in] controller Valid reference to the controller object
48 ProgramImpl(const Graphics::ProgramCreateInfo& createInfo, Graphics::EglGraphicsController& controller);
56 * @brief Destroys GL resources associated with the Program
58 * @return True on success
63 * @brief Creates GL resource for this Program
65 * @return True on success
70 * @brief Returns GL program id
72 * @return GL program id
74 [[nodiscard]] uint32_t GetGlProgram() const;
77 * @brief Increases ref count
79 * @return new refcount
84 * @brief Decreases ref count
86 * @return New refcount
91 * @brief Returns reflection
93 * @return Valid reflection associated with the Program
95 [[nodiscard]] const Graphics::Reflection& GetReflection() const;
98 * @brief Returns controller
100 * @return Valid Controller object
102 [[nodiscard]] EglGraphicsController& GetController() const;
105 * @brief Returns create info structure
107 * @return Reference to valid create info structure
109 [[nodiscard]] const ProgramCreateInfo& GetCreateInfo() const;
112 * @brief Returns parameter value specified by parameterId
114 * This function can be used as a backdoor into the implementation
115 * used to retrieve internal data.
117 * @param[in] parameterId Integer parameter id
118 * @param[out] out Pointer to write to
120 * @return True on success
122 bool GetParameter(uint32_t parameterId, void* out);
125 friend class Program;
128 std::unique_ptr<Impl> mImpl;
131 ///////////////////////////////////////////////////////////////
134 * @brief Wrapper for the pipeline implementation
136 * This object is returned back to the client-side
138 class Program : public Graphics::Program
144 * @param[in] impl Pointer to valid implementation
146 explicit Program(ProgramImpl* impl)
158 * @brief Returns reference to the Reflection object
162 [[nodiscard]] const Graphics::Reflection& GetReflection() const;
165 * @brief Retrieves internal program implementation
167 * @return Valid pointer to the ProgramImpl object
169 [[nodiscard]] ProgramImpl* GetImplementation() const
175 * @brief Returns controller
179 [[nodiscard]] EglGraphicsController& GetController() const;
182 * @brief Returns create info structure
184 * @return create info structure
186 [[nodiscard]] const ProgramCreateInfo& GetCreateInfo() const;
188 bool operator==(const GLES::Program& program) const
190 return (program.mProgram == mProgram);
193 bool operator==(const GLES::ProgramImpl* programImpl) const
195 return (programImpl == mProgram);
198 bool operator!=(const GLES::Program& program) const
200 return (program.mProgram != mProgram);
204 * @brief Run by UniquePtr to discard resource
206 void DiscardResource();
209 * @brief Destroying GL resources
211 * This function is kept for compatibility with Resource<> class
212 * so can the object can be use with templated functions.
214 void DestroyResource()
216 // nothing to do here
220 ProgramImpl* mProgram{nullptr};
223 } // namespace Dali::Graphics
225 #endif //DALI_GRAPHICS_PROGRAM_H