Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / texture-factory.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include "texture-factory.h"
18
19 #include <dali/integration-api/bitmap.h>
20 #include <dali/internal/render/gl-resources/texture.h>
21 #include <dali/internal/render/gl-resources/bitmap-texture.h>
22 #include <dali/internal/render/gl-resources/compressed-bitmap-texture.h>
23 #include <dali/internal/render/gl-resources/native-texture.h>
24 #include <dali/internal/render/gl-resources/frame-buffer-texture.h>
25 #include <dali/internal/render/gl-resources/native-frame-buffer-texture.h>
26 #include <dali/public-api/images/native-image.h>
27
28
29 namespace Dali
30 {
31 class NativeImage;
32
33 namespace Internal
34 {
35
36 namespace TextureFactory
37 {
38
39 Internal::Texture* NewBitmapTexture( Integration::Bitmap* const bitmap, Context& context )
40 {
41   DALI_ASSERT_DEBUG( bitmap );
42   Texture * texture = 0;
43   Integration::Bitmap::PackedPixelsProfile * const  packedPixelBitmapView = bitmap->GetPackedPixelsProfile();
44   if( packedPixelBitmapView )
45   {
46     texture = new BitmapTexture( bitmap, packedPixelBitmapView, context );
47   }
48   else
49   {
50     Internal::BitmapCompressed * const compressedBitmap = dynamic_cast<Dali::Internal::BitmapCompressed*>( bitmap );
51     if( compressedBitmap != 0 )
52     {
53       texture = new CompressedBitmapTexture( compressedBitmap, context );
54     }
55   }
56   if( texture )
57   {
58     if( !texture->Init() )
59     {
60       delete texture;
61       return NULL;
62     }
63   }
64   return texture;
65 }
66
67 Internal::Texture* NewBitmapTexture( unsigned int      width,
68                                      unsigned int      height,
69                                      Pixel::Format     pixelFormat,
70                                      bool              clearPixels,
71                                      Context&          context )
72 {
73   Texture *texture=new BitmapTexture(width, height, pixelFormat, clearPixels, context);
74
75   return texture;
76 }
77
78
79 Internal::Texture* NewNativeImageTexture( NativeImage& nativeImg, Context& context )
80 {
81   NativeTexture* texture = new NativeTexture(&nativeImg, context);
82   if (!texture->Init())
83   {
84     delete texture;
85     return NULL;
86   }
87   return texture;
88 }
89
90 Internal::Texture* NewFrameBufferTexture( unsigned int width,
91                                           unsigned int height,
92                                           Pixel::Format pixelFormat,
93                                           Context& context )
94 {
95   FrameBufferTexture* texture = new FrameBufferTexture(width, height, pixelFormat, context);
96   if (!texture->Init())
97   {
98     delete texture;
99     return NULL;
100   }
101   return texture;
102 }
103
104 Internal::Texture* NewFrameBufferTexture( NativeImagePtr nativeImage,
105                                           Context& context )
106 {
107   NativeFrameBufferTexture* texture = new NativeFrameBufferTexture(nativeImage, context);
108   if (!texture->Init())
109   {
110     delete texture;
111     return NULL;
112   }
113   return texture;
114 }
115
116
117
118 } // TextureFactory
119 } // Internal
120 } // Dali
121