Cleaning up and optimizing scene-graph-material and scene-graph-renderer
[platform/core/uifw/dali-core.git] / dali / public-api / images / frame-buffer-image.cpp
1 /*
2  * Copyright (c) 2015 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( const FrameBufferImage& handle )
44 : Image(handle)
45 {
46 }
47
48 FrameBufferImage& FrameBufferImage::operator=( const FrameBufferImage& rhs )
49 {
50   BaseHandle::operator=(rhs);
51   return *this;
52 }
53
54 FrameBufferImage FrameBufferImage::New( unsigned int width, unsigned int height, Pixel::Format pixelformat, RenderBuffer::Format bufferformat )
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     bufferformat);
62
63   return FrameBufferImage(internal.Get());
64 }
65
66 FrameBufferImage FrameBufferImage::New( unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy /*releasePolicy*/, RenderBuffer::Format bufferformat )
67 {
68   Dali::Vector2 stageSize = Stage::GetCurrent().GetSize();
69   Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New(
70     (0 == width) ? stageSize.width : width,
71     (0 == height) ? stageSize.height : height,
72     pixelformat,
73     bufferformat);
74
75   return FrameBufferImage(internal.Get());
76 }
77
78 FrameBufferImage FrameBufferImage::New( NativeImageInterface& image, ReleasePolicy /*releasePolicy*/ )
79 {
80   Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New( image );
81   return FrameBufferImage(internal.Get());
82 }
83
84 FrameBufferImage FrameBufferImage::New( NativeImageInterface& image )
85 {
86   Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New( image );
87   return FrameBufferImage(internal.Get());
88 }
89
90 FrameBufferImage FrameBufferImage::DownCast( BaseHandle handle )
91 {
92   return FrameBufferImage( dynamic_cast<Dali::Internal::FrameBufferImage*>( handle.GetObjectPtr() ) );
93 }
94
95 } // namespace Dali