Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / images / native-image-interface.h
index c2f9fb8..717e365 100644 (file)
@@ -1,8 +1,8 @@
-#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) 2015 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
@@ -35,96 +37,144 @@ namespace Dali
  * @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;
 
   /**
-   * @brief Retrieve the extension for the interface.
+   * @brief Get the texture target for binding native image as texture.
+   *
+   * @SINCE_1_9.23
+   * @return Texture target.
+   */
+  virtual int GetTextureTarget() const = 0;
+
+  /**
+   * @brief Get custom fragment prefix for rendering native image.
+   *
+   * @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 Extension* GetExtension()
   {
-    return NULL;
+    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
    */
-  virtual ~NativeImageInterface()
-  {
-  }
-
+  ~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