[dali_1.3.31] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / images / native-image.h
index 550489f..47dc0b7 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTEGRATION_NATIVE_IMAGE_H__
-#define __DALI_INTEGRATION_NATIVE_IMAGE_H__
+#ifndef __DALI_NATIVE_IMAGE_H__
+#define __DALI_NATIVE_IMAGE_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/images/native-image-interface.h>
 
 namespace Dali
 {
+/**
+ * @addtogroup dali_core_images
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+class NativeImage;
+}
 
 /**
- * @brief Abstract interface to provide platform-specific support for handling image data.
+ * @DEPRECATED_1_2.41
+ *
+ * @brief NativeImage represents a platform specific image resource.
  *
- * For example, an implementation could use EGL extensions, etc.
+ * Its data is provided by native resources, such as shared bitmap memory or pixmap.
+ * @SINCE_1_0.0
  */
-class NativeImage : public Dali::RefObject
+class DALI_CORE_API  NativeImage : public Image
 {
 public:
 
   /**
-   * @brief Create the GL resource for the NativeImage.
+   * @DEPRECATED_1_2.41
+   *
+   * @brief Constructor with creates an uninitialized NativeImage object.
    *
-   * 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.
+   * Use NativeImage::New(...) to create an initialised object.
+   * @SINCE_1_0.0
    */
-  virtual bool GlExtensionCreate() = 0;
+  NativeImage() DALI_DEPRECATED_API;
 
   /**
-   * @brief Destroy the GL resource for the NativeImage.
+   * @DEPRECATED_1_2.41
    *
-   * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
-   * @pre There is a GL context for the current thread.
+   * @brief Destructor.
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   * @SINCE_1_0.0
    */
-  virtual void GlExtensionDestroy() = 0;
+   ~NativeImage() DALI_DEPRECATED_API;
 
   /**
-   * @brief Use the NativeImage as a texture for rendering.
+   * @DEPRECATED_1_2.41
+   *
+   * @brief This copy constructor is required for (smart) pointer semantics.
    *
-   * @pre There is a GL context for the current thread.
-   * @return A GL error code
+   * @SINCE_1_0.0
+   * @param[in] handle A reference to the copied handle
    */
-  virtual unsigned int TargetTexture() = 0;
+  NativeImage( const NativeImage& handle ) DALI_DEPRECATED_API;
 
   /**
-   * @brief Called in each NativeTexture::Bind() call to allow implementation specific operations.
+   * @DEPRECATED_1_2.41
+   *
+   * @brief This assignment operator is required for (smart) pointer semantics.
    *
-   * 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
+   * @param[in] rhs A reference to the copied handle
+   * @return A reference to this
    */
-  virtual void PrepareTexture() = 0;
+  NativeImage& operator=( const NativeImage& rhs ) DALI_DEPRECATED_API;
 
   /**
-   * @brief Returns the width of the NativeImage.
+   * @DEPRECATED_1_2.41
+   *
+   * @brief Triggers asynchronous creation of backing GL texture immediately.
+   *
+   * The normal policy is for a GL texture to created lazily when needed.
+   * This function forces the allocation of a texture to happen at the earliest
+   * opportunity.
    *
-   * @return width
+   * @SINCE_1_0.0
+   * @note If the application loses its GL context, native images may lose their
+   * GL textures. This function can be called again after context regain to force
+   * the creation of the GL texture if still needed.
    */
-  virtual unsigned int GetWidth() const = 0;
+  void CreateGlTexture() DALI_DEPRECATED_API;
 
   /**
-   * @brief Returns the height of the NativeImage.
+   * @DEPRECATED_1_2.41
    *
-   * @return height
+   * @brief Creates a new NativeImage, which used native resources.
+   *
+   * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE
+   * @SINCE_1_0.0
+   * @param[in] nativeImageInterface An reference to the object of the interface implementation
+   * @return A handle to a newly allocated object
    */
-  virtual unsigned int GetHeight() const = 0;
+  static NativeImage New( NativeImageInterface& nativeImageInterface ) DALI_DEPRECATED_API;
 
   /**
-   * @brief Returns the internal pixel NativeImage::PixelFormat of the NativeImage.
+   * @DEPRECATED_1_2.41
+   *
+   * @brief Downcasts a handle to NativeImage handle.
    *
-   * @return pixel format
+   * If handle points to a NativeImage object, the downcast produces valid handle.
+   * If not, the returned handle is left uninitialized.
+   * @SINCE_1_0.0
+   * @param[in] handle Handle to an object
+   * @return handle to a NativeImage or an uninitialized handle
    */
-  virtual Pixel::Format GetPixelFormat() const = 0;
+  static NativeImage DownCast( BaseHandle handle ) DALI_DEPRECATED_API;
 
-protected:
+  /**
+   * @DEPRECATED_1_2.41
+   *
+   * @brief Gets custom fragment prefix for rendering a native image.
+   *
+   * @return String for custom fragment prefix
+   */
+  const char* GetCustomFragmentPreFix() DALI_DEPRECATED_API;
 
   /**
-   * @brief A reference counted object may only be deleted by calling Unreference().
+   * @DEPRECATED_1_2.41
+   *
+   * @brief Gets custom sampler type name for rendering a native image.
    *
-   * The implementation should destroy the NativeImage resources.
+   * @return String for custom sampler type name
    */
-  virtual ~NativeImage()
-  {
-  }
+  const char* GetCustomSamplerTypename() DALI_DEPRECATED_API;
+
+public: // Not intended for application developers
+
+  explicit DALI_INTERNAL NativeImage( Internal::NativeImage* ) DALI_DEPRECATED_API;
 
 };
 
 /**
- * @brief Pointer to Dali::NativeImage
+ * @}
  */
-typedef IntrusivePtr<NativeImage>  NativeImagePtr;
-
 } // namespace Dali
 
-#endif // __DALI_INTEGRATION_NATIVE_IMAGE_H__
+#endif // __DALI_NATIVE_IMAGE_H__