License conversion from Flora to Apache 2.0
[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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
18 // CLASS HEADER
19 #include <dali/public-api/images/frame-buffer-image.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/common/stage.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/internal/event/images/frame-buffer-image-impl.h>
26
27 namespace Dali
28 {
29
30 FrameBufferImage::FrameBufferImage()
31 {
32 }
33
34 FrameBufferImage::FrameBufferImage(Internal::FrameBufferImage* internal)
35   : Image(internal)
36 {
37 }
38
39 FrameBufferImage::~FrameBufferImage()
40 {
41 }
42
43 FrameBufferImage FrameBufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat)
44 {
45   Dali::Vector2 stageSize = Stage::GetCurrent().GetSize();
46   return FrameBufferImage(new Internal::FrameBufferImage((0 == width) ? stageSize.width : width,
47                                                          (0 == height) ? stageSize.height : height,
48                                                          pixelformat,
49                                                          Dali::Image::Never));
50 }
51
52 FrameBufferImage FrameBufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePolicy)
53 {
54   Dali::Vector2 stageSize = Stage::GetCurrent().GetSize();
55   return FrameBufferImage(new Internal::FrameBufferImage((0 == width) ? stageSize.width : width,
56                                                          (0 == height) ? stageSize.height : height,
57                                                          pixelformat,
58                                                          releasePolicy));
59 }
60
61 FrameBufferImage FrameBufferImage::New( NativeImage& image, ReleasePolicy releasePolicy )
62 {
63   return FrameBufferImage(new Internal::FrameBufferImage( image, releasePolicy ));
64 }
65
66 FrameBufferImage FrameBufferImage::New( NativeImage& image )
67 {
68   return FrameBufferImage(new Internal::FrameBufferImage( image ));
69 }
70
71 FrameBufferImage FrameBufferImage::DownCast( BaseHandle handle )
72 {
73   return FrameBufferImage( dynamic_cast<Dali::Internal::FrameBufferImage*>(handle.GetObjectPtr()) );
74 }
75
76 } // namespace Dali