Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / images / native-image-impl.h
1 #ifndef __DALI_INTERNAL_NATIVE_IMAGE_H__
2 #define __DALI_INTERNAL_NATIVE_IMAGE_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 <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/native-image.h>
26 #include <dali/internal/event/images/image-impl.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 class NativeImage;
35 typedef IntrusivePtr<NativeImage> NativeImagePtr;
36
37 /**
38  * @copydoc Dali::NativeImage
39  */
40 class NativeImage : public Image
41 {
42 public:
43
44   /**
45    * Creates object by using native resources
46    * the maximum size of the image is limited by GL_MAX_TEXTURE_SIZE
47    * @param [in] nativeImageInterface An reference to the object of the interface implementation.
48    * @return a pointer to a newly created object.
49    */
50   static NativeImagePtr New( NativeImageInterface& nativeImageInterface );
51
52   /**
53    * @copydoc Dali::NativeImage::CreateGlTexture
54    */
55   void CreateGlTexture();
56
57 protected:
58
59   /**
60    * Constructor
61    */
62   NativeImage( NativeImageInterface& nativeImageInterface );
63
64   /**
65    * A reference counted object may only be deleted by calling Unreference()
66    */
67   virtual ~NativeImage();
68
69 public:
70
71   /**
72    * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
73    */
74   const char* GetCustomFragmentPreFix();
75
76   /**
77    * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
78    */
79   const char* GetCustomSamplerTypename();
80
81 private:
82   std::string mCustomFragmentPreFix;
83   std::string mCustomSamplerTypename;
84 };
85
86 } // namespace Internal
87
88 /**
89  * Helper methods for public API.
90  */
91 inline Internal::NativeImage& GetImplementation(Dali::NativeImage& image)
92 {
93   DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
94
95   BaseObject& handle = image.GetBaseObject();
96
97   return static_cast<Internal::NativeImage&>(handle);
98 }
99
100 inline const Internal::NativeImage& GetImplementation(const Dali::NativeImage& image)
101 {
102   DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
103
104   const BaseObject& handle = image.GetBaseObject();
105
106   return static_cast<const Internal::NativeImage&>(handle);
107 }
108
109 } // namespace Dali
110 #endif // __DALI_INTERNAL_NATIVE_IMAGE_H__