1 #ifndef DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H
2 #define DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H
5 * Copyright (c) 2019 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.
23 #include <cstdint> // uint32_t
26 #include <dali/public-api/object/ref-object.h>
31 * @addtogroup dali_core_images
36 * @brief Abstract interface to provide platform-specific support for handling image data.
38 * For example, an implementation could use EGL extensions, etc.
41 class NativeImageInterface : public Dali::RefObject
45 class Extension; ///< Forward declare future extension interface
48 * @brief Creates the GL resource for the NativeImage.
50 * e.g. For the EglImageKHR extension, this corresponds to calling eglCreateImageKHR().
52 * @return false If the initialization fails
53 * @pre There is a GL context for the current thread.
55 virtual bool GlExtensionCreate() = 0;
58 * @brief Destroys the GL resource for the NativeImage.
60 * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR().
62 * @pre There is a GL context for the current thread.
64 virtual void GlExtensionDestroy() = 0;
67 * @brief Uses the NativeImage as a texture for rendering.
70 * @return A GL error code
71 * @pre There is a GL context for the current thread.
73 virtual uint32_t TargetTexture() = 0;
76 * @brief Called internally for each Bind call for this texture to allow implementation specific operations.
78 * The correct texture sampler has already been bound before the function gets called.
80 * @pre glAbstraction is being used by context in current thread
82 virtual void PrepareTexture() = 0;
85 * @brief Returns the width of the NativeImage.
90 virtual uint32_t GetWidth() const = 0;
93 * @brief Returns the height of the NativeImage.
98 virtual uint32_t GetHeight() const = 0;
101 * @brief Queries whether blending is required.
103 * @return True if blending is required
105 virtual bool RequiresBlending() const = 0;
108 * @brief Retrieves the extension for the interface.
111 * @return The extension if available, NULL otherwise
113 virtual Extension* GetExtension()
121 * @brief A reference counted object may only be deleted by calling Unreference().
123 * The implementation should destroy the NativeImage resources.
126 virtual ~NativeImageInterface()
133 * @brief Pointer to Dali::NativeImageInterface.
136 typedef Dali::IntrusivePtr<NativeImageInterface> NativeImageInterfacePtr;
143 #endif // DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H