Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-core.git] / dali / public-api / images / native-image-interface.h
1 #ifndef __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
2 #define __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <cstddef>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/ref-object.h>
26
27 namespace Dali
28 {
29
30 /**
31  * @brief Abstract interface to provide platform-specific support for handling image data.
32  *
33  * For example, an implementation could use EGL extensions, etc.
34  */
35 class NativeImageInterface : public Dali::RefObject
36 {
37 public:
38
39   class Extension; ///< Forward declare future extension interface
40
41   /**
42    * @brief Create the GL resource for the NativeImage.
43    *
44    * e.g. For the EglImageKHR extension, this corresponds to calling eglCreateImageKHR()
45    * @pre There is a GL context for the current thread.
46    * @return false If the initialization fails.
47    */
48   virtual bool GlExtensionCreate() = 0;
49
50   /**
51    * @brief Destroy the GL resource for the NativeImage.
52    *
53    * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
54    * @pre There is a GL context for the current thread.
55    */
56   virtual void GlExtensionDestroy() = 0;
57
58   /**
59    * @brief Use the NativeImage as a texture for rendering.
60    *
61    * @pre There is a GL context for the current thread.
62    * @return A GL error code
63    */
64   virtual unsigned int TargetTexture() = 0;
65
66   /**
67    * @brief Called in each NativeTexture::Bind() call to allow implementation specific operations.
68    *
69    * The correct texture sampler has already been bound before the function gets called.
70    * @pre glAbstraction is being used by context in current thread
71    */
72   virtual void PrepareTexture() = 0;
73
74   /**
75    * @brief Returns the width of the NativeImage.
76    *
77    * @return width
78    */
79   virtual unsigned int GetWidth() const = 0;
80
81   /**
82    * @brief Returns the height of the NativeImage.
83    *
84    * @return height
85    */
86   virtual unsigned int GetHeight() const = 0;
87
88  /**
89   * Query whether blending is required
90   */
91   virtual bool RequiresBlending() const = 0;
92
93   /**
94    * @brief Retrieve the extension for the interface.
95    *
96    * @return The extension if available, NULL otherwise
97    */
98   virtual Extension* GetExtension()
99   {
100     return NULL;
101   }
102
103 protected:
104
105   /**
106    * @brief A reference counted object may only be deleted by calling Unreference().
107    *
108    * The implementation should destroy the NativeImage resources.
109    */
110   virtual ~NativeImageInterface()
111   {
112   }
113
114 };
115
116 /**
117  * @brief Pointer to Dali::NativeImageInterface
118  */
119 typedef IntrusivePtr<NativeImageInterface>  NativeImageInterfacePtr;
120
121 } // namespace Dali
122
123 #endif // __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__