1 #ifndef DALI_GRAPHICS_GLES_RESOURCE_H
2 #define DALI_GRAPHICS_GLES_RESOURCE_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.
21 namespace Dali::Graphics
23 class EglGraphicsController;
28 * @brief Base class for the Graphics resource.
30 template<class BASE, class CreateInfo>
31 class Resource : public BASE
36 * @param[in] createInfo CreateInfo structure for the resource
37 * @param[in] controller Reference to the controller
39 Resource(const CreateInfo& createInfo, Graphics::EglGraphicsController& controller)
40 : mCreateInfo(createInfo),
41 mController(controller)
46 * @brief Tries to recycle Graphics resource
48 * If False returned, the object must be initialized with use of constructor
50 * By default, all graphics resources are non-recyclable
52 * @param[in] createInfo CreateInfo structure of new object
53 * @param[in] controller Reference to the controller
54 * @return True on success, False otherwise
56 virtual bool TryRecycle(const CreateInfo& createInfo, Graphics::EglGraphicsController& controller)
64 ~Resource() override = default;
67 * @brief Retrieves create info structure
68 * @return Reference to the create info structure
70 [[nodiscard]] const CreateInfo& GetCreateInfo() const
76 * @brief Retrieves controller
77 * @return Reference to the controller object
79 [[nodiscard]] Graphics::EglGraphicsController& GetController() const
85 * @brief Destroys resource
87 * This function must be implemented by the derived class.
88 * It should perform final destruction of used GL resources.
90 virtual void DestroyResource() = 0;
93 * @brief Initializes resource
95 * This function must be implemented by the derived class.
96 * It should initialize all necessary GL resources.
98 * @return True on success
100 virtual bool InitializeResource() = 0;
103 * @brief Discards resource by adding it to the discard queue
105 virtual void DiscardResource() = 0;
108 * @brief returns pointer to base
117 CreateInfo mCreateInfo; ///< CreateInfo structure
118 Graphics::EglGraphicsController& mController; ///< Reference to the Controller object
121 } // namespace Dali::Graphics