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