-#ifndef __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
-#define __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
+#ifndef DALI_NATIVE_IMAGE_INTERFACE_H
+#define DALI_NATIVE_IMAGE_INTERFACE_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+// EXTERNAL INCLUDES
+#include <cstddef>
+#include <cstdint> // uint32_t
+
// INTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
#include <dali/public-api/object/ref-object.h>
namespace Dali
{
+/**
+ * @addtogroup dali_core_images
+ * @{
+ */
/**
* @brief Abstract interface to provide platform-specific support for handling image data.
*
* For example, an implementation could use EGL extensions, etc.
+ * @SINCE_1_0.0
*/
class NativeImageInterface : public Dali::RefObject
{
public:
+ class Extension; ///< Forward declare future extension interface
/**
- * @brief Create the GL resource for the NativeImage.
+ * @brief Creates the resource for the NativeImage.
*
- * e.g. For the EglImageKHR extension, this corresponds to calling eglCreateImageKHR()
- * @pre There is a GL context for the current thread.
- * @return false If the initialization fails.
+ * e.g. For the EglImageKHR extension, this corresponds to calling eglCreateImageKHR().
+ * @SINCE_1_9.23
+ * @return false If the initialization fails
+ * @pre The graphics subsystem has been initialized
*/
- virtual bool GlExtensionCreate() = 0;
+ virtual bool CreateResource() = 0;
/**
- * @brief Destroy the GL resource for the NativeImage.
+ * @brief Destroys the resource for the NativeImage.
*
- * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
- * @pre There is a GL context for the current thread.
+ * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR().
+ * @SINCE_1_9.23
+ * @pre The graphics subsystem has been initialized
*/
- virtual void GlExtensionDestroy() = 0;
+ virtual void DestroyResource() = 0;
/**
- * @brief Use the NativeImage as a texture for rendering.
+ * @brief Uses the NativeImage as a texture for rendering.
*
- * @pre There is a GL context for the current thread.
- * @return A GL error code
+ * @SINCE_1_0.0
+ * @return An error code from the graphics subsystem.
+ * @pre The graphics subsystem has been initialized
*/
- virtual unsigned int TargetTexture() = 0;
+ virtual uint32_t TargetTexture() = 0;
/**
- * @brief Called in each NativeTexture::Bind() call to allow implementation specific operations.
+ * @brief Called internally when the texture is bound in the GPU
*
* The correct texture sampler has already been bound before the function gets called.
- * @pre glAbstraction is being used by context in current thread
+ * @SINCE_1_0.0
+ * @pre The graphics subsystem has been initialized
*/
virtual void PrepareTexture() = 0;
/**
* @brief Returns the width of the NativeImage.
*
- * @return width
+ * @SINCE_1_0.0
+ * @return Width
*/
- virtual unsigned int GetWidth() const = 0;
+ virtual uint32_t GetWidth() const = 0;
/**
* @brief Returns the height of the NativeImage.
*
- * @return height
+ * @SINCE_1_0.0
+ * @return Height
*/
- virtual unsigned int GetHeight() const = 0;
+ virtual uint32_t GetHeight() const = 0;
- /**
- * Query whether blending is required
+ /**
+ * @brief Queries whether blending is required.
+ * @SINCE_1_0.0
+ * @return True if blending is required
*/
virtual bool RequiresBlending() const = 0;
-protected:
+ /**
+ * @brief Get the texture target for binding native image as texture.
+ *
+ * @SINCE_1_9.23
+ * @return Texture target.
+ */
+ virtual int GetTextureTarget() const = 0;
/**
- * @brief A reference counted object may only be deleted by calling Unreference().
+ * @brief Get custom fragment prefix for rendering native image.
*
- * The implementation should destroy the NativeImage resources.
+ * @SINCE_1_9.23
+ * @return Custom fragment prefix code as string.
+ */
+ virtual const char* GetCustomFragmentPrefix() const = 0;
+
+ /**
+ * @brief Get custom sampler type name for rendering native image.
+ *
+ * @SINCE_1_9.23
+ * @return Custom sampler type name.
+ */
+ virtual const char* GetCustomSamplerTypename() const = 0;
+
+ /**
+ * @brief Retrieves the internal native image.
+ *
+ * @SINCE_1_9.23
+ * @return Any object containing the internal native image source
+ */
+ virtual Any GetNativeImageHandle() const = 0;
+
+ /**
+ * @brief Determine if the source for the native image has changed characteristics.
+ *
+ * @SINCE_1_9.23
+ * @return true if the source data has modified any characteristics of the
+ * native image, for example if the size of the buffer has changed.
+ */
+ virtual bool SourceChanged() const = 0;
+
+ /**
+ * @brief Retrieves the extension for the interface.
+ *
+ * @SINCE_1_0.0
+ * @return The extension if available, NULL otherwise
*/
- virtual ~NativeImageInterface()
+ virtual Extension* GetExtension()
{
+ return nullptr;
}
+protected:
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ *
+ * The implementation should destroy the NativeImage resources.
+ * @SINCE_1_0.0
+ */
+ ~NativeImageInterface() override = default;
};
/**
- * @brief Pointer to Dali::NativeImageInterface
+ * @brief Pointer to Dali::NativeImageInterface.
+ * @SINCE_1_0.0
*/
-typedef IntrusivePtr<NativeImageInterface> NativeImageInterfacePtr;
+using NativeImageInterfacePtr = Dali::IntrusivePtr<NativeImageInterface>;
+/**
+ * @}
+ */
} // namespace Dali
-#endif // __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
+#endif // DALI_NATIVE_IMAGE_INTERFACE_H