[3.0] Update doxygen comments
[platform/core/uifw/dali-core.git] / dali / public-api / images / native-image.h
index 550489f..3a28aff 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) 2015 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.
+ * @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_IMPORT_API  NativeImage : public Image
 {
 public:
 
   /**
-   * @brief Create the GL resource for the NativeImage.
+   * @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();
 
   /**
-   * @brief Destroy the GL resource for the NativeImage.
+   * @brief Destructor.
    *
-   * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
-   * @pre There is a GL context for the current thread.
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   * @SINCE_1_0.0
    */
-  virtual void GlExtensionDestroy() = 0;
+   ~NativeImage();
+
+   /**
+    * @brief This copy constructor is required for (smart) pointer semantics.
+    *
+    * @SINCE_1_0.0
+    * @param[in] handle A reference to the copied handle
+    */
+   NativeImage( const NativeImage& handle );
 
   /**
-   * @brief Use the NativeImage as a texture for rendering.
+   * @brief This assignment operator 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] rhs A reference to the copied handle
+   * @return A reference to this
    */
-  virtual unsigned int TargetTexture() = 0;
+  NativeImage& operator=( const NativeImage& rhs );
 
   /**
-   * @brief Called in each NativeTexture::Bind() call to allow implementation specific operations.
+   * @brief Triggers asynchronous creation of backing GL texture immediately.
    *
-   * The correct texture sampler has already been bound before the function gets called.
-   * @pre glAbstraction is being used by context in current thread
+   * 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.
+   *
+   * @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 void PrepareTexture() = 0;
+  void CreateGlTexture();
 
   /**
-   * @brief Returns the width of the NativeImage.
+   * @brief Creates a new NativeImage, which used native resources.
    *
-   * @return width
+   * 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 GetWidth() const = 0;
+  static NativeImage New( NativeImageInterface& nativeImageInterface );
 
   /**
-   * @brief Returns the height of the NativeImage.
+   * @brief Downcasts a handle to NativeImage handle.
    *
-   * @return height
+   * 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 unsigned int GetHeight() const = 0;
+  static NativeImage DownCast( BaseHandle handle );
 
   /**
-   * @brief Returns the internal pixel NativeImage::PixelFormat of the NativeImage.
+   * @brief Gets custom fragment prefix for rendering a native image.
    *
-   * @return pixel format
+   * @return String for custom fragment prefix
    */
-  virtual Pixel::Format GetPixelFormat() const = 0;
-
-protected:
+  const char* GetCustomFragmentPreFix();
 
   /**
-   * @brief A reference counted object may only be deleted by calling Unreference().
+   * @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();
+
+public: // Not intended for application developers
+
+  explicit DALI_INTERNAL NativeImage( Internal::NativeImage* );
 
 };
 
 /**
- * @brief Pointer to Dali::NativeImage
+ * @}
  */
-typedef IntrusivePtr<NativeImage>  NativeImagePtr;
-
 } // namespace Dali
 
-#endif // __DALI_INTEGRATION_NATIVE_IMAGE_H__
+#endif // __DALI_NATIVE_IMAGE_H__