Merge branch 'master' into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / images / frame-buffer-image.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 // CLASS HEADER
18 #include <dali/public-api/images/frame-buffer-image.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/common/dali-common.h>
22 #include <dali/public-api/common/stage.h>
23 #include <dali/public-api/math/vector2.h>
24 #include <dali/internal/event/images/frame-buffer-image-impl.h>
25
26 namespace Dali
27 {
28
29 FrameBufferImage::FrameBufferImage()
30 {
31 }
32
33 FrameBufferImage::FrameBufferImage(Internal::FrameBufferImage* internal)
34   : Image(internal)
35 {
36 }
37
38 FrameBufferImage::~FrameBufferImage()
39 {
40 }
41
42 FrameBufferImage FrameBufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat)
43 {
44   Dali::Vector2 stageSize = Stage::GetCurrent().GetSize();
45   Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New(
46     (0 == width) ? stageSize.width : width,
47     (0 == height) ? stageSize.height : height,
48     pixelformat,
49     Dali::Image::Never);
50
51   return FrameBufferImage(internal.Get());
52 }
53
54 FrameBufferImage FrameBufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePolicy)
55 {
56   Dali::Vector2 stageSize = Stage::GetCurrent().GetSize();
57   Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New(
58     (0 == width) ? stageSize.width : width,
59     (0 == height) ? stageSize.height : height,
60     pixelformat,
61     releasePolicy);
62
63   return FrameBufferImage(internal.Get());
64 }
65
66 FrameBufferImage FrameBufferImage::New( NativeImage& image, ReleasePolicy releasePolicy )
67 {
68   Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New( image, releasePolicy );
69   return FrameBufferImage(internal.Get());
70 }
71
72 FrameBufferImage FrameBufferImage::New( NativeImage& image )
73 {
74   Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New( image );
75   return FrameBufferImage(internal.Get());
76 }
77
78 FrameBufferImage FrameBufferImage::DownCast( BaseHandle handle )
79 {
80   return FrameBufferImage( dynamic_cast<Dali::Internal::FrameBufferImage*>(handle.GetObjectPtr()) );
81 }
82
83 } // namespace Dali