Merge remote-tracking branch 'origin/tizen' into new_text
[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) 2014 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 // INTERNAL INCLUDES
22 #include <dali/public-api/object/ref-object.h>
23
24 namespace Dali
25 {
26
27 /**
28  * @brief Abstract interface to provide platform-specific support for handling image data.
29  *
30  * For example, an implementation could use EGL extensions, etc.
31  */
32 class NativeImageInterface : public Dali::RefObject
33 {
34 public:
35
36   /**
37    * @brief Create the GL resource for the NativeImage.
38    *
39    * e.g. For the EglImageKHR extension, this corresponds to calling eglCreateImageKHR()
40    * @pre There is a GL context for the current thread.
41    * @return false If the initialization fails.
42    */
43   virtual bool GlExtensionCreate() = 0;
44
45   /**
46    * @brief Destroy the GL resource for the NativeImage.
47    *
48    * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
49    * @pre There is a GL context for the current thread.
50    */
51   virtual void GlExtensionDestroy() = 0;
52
53   /**
54    * @brief Use the NativeImage as a texture for rendering.
55    *
56    * @pre There is a GL context for the current thread.
57    * @return A GL error code
58    */
59   virtual unsigned int TargetTexture() = 0;
60
61   /**
62    * @brief Called in each NativeTexture::Bind() call to allow implementation specific operations.
63    *
64    * The correct texture sampler has already been bound before the function gets called.
65    * @pre glAbstraction is being used by context in current thread
66    */
67   virtual void PrepareTexture() = 0;
68
69   /**
70    * @brief Returns the width of the NativeImage.
71    *
72    * @return width
73    */
74   virtual unsigned int GetWidth() const = 0;
75
76   /**
77    * @brief Returns the height of the NativeImage.
78    *
79    * @return height
80    */
81   virtual unsigned int GetHeight() const = 0;
82
83  /**
84   * Query whether blending is required
85   */
86   virtual bool RequiresBlending() const = 0;
87
88 protected:
89
90   /**
91    * @brief A reference counted object may only be deleted by calling Unreference().
92    *
93    * The implementation should destroy the NativeImage resources.
94    */
95   virtual ~NativeImageInterface()
96   {
97   }
98
99 };
100
101 /**
102  * @brief Pointer to Dali::NativeImageInterface
103  */
104 typedef IntrusivePtr<NativeImageInterface>  NativeImageInterfacePtr;
105
106 } // namespace Dali
107
108 #endif // __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__