Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / frame-buffer.cpp
1 /*
2  * Copyright (c) 2018 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/rendering/frame-buffer.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/rendering/frame-buffer-impl.h> // Dali::Internal::FrameBuffer
23
24
25 namespace Dali
26 {
27
28 FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height, uint32_t attachments )
29 {
30   Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New( width, height, attachments );
31   return FrameBuffer( frameBuffer.Get() );
32 }
33
34 FrameBuffer::FrameBuffer()
35 {
36 }
37
38 FrameBuffer::~FrameBuffer()
39 {
40 }
41
42 FrameBuffer::FrameBuffer( const FrameBuffer& handle )
43 : BaseHandle( handle )
44 {
45 }
46
47 FrameBuffer FrameBuffer::DownCast( BaseHandle handle )
48 {
49   return FrameBuffer( dynamic_cast<Dali::Internal::FrameBuffer*>(handle.GetObjectPtr()));
50 }
51
52 FrameBuffer& FrameBuffer::operator=( const FrameBuffer& handle )
53 {
54   BaseHandle::operator=( handle );
55   return *this;
56 }
57
58 FrameBuffer::FrameBuffer( Internal::FrameBuffer* pointer )
59 : BaseHandle( pointer )
60 {
61 }
62
63 void FrameBuffer::AttachColorTexture( Texture& texture )
64 {
65   AttachColorTexture( texture, 0u, 0u );
66 }
67
68 void FrameBuffer::AttachColorTexture( Texture& texture, uint32_t mipmapLevel, uint32_t layer )
69 {
70   if( texture )
71   {
72     Internal::TexturePtr texturePtr( &GetImplementation( texture ) );
73     GetImplementation(*this).AttachColorTexture( texturePtr, mipmapLevel, layer );
74   }
75 }
76
77 Texture FrameBuffer::GetColorTexture()
78 {
79   Internal::Texture* texturePtr = GetImplementation(*this).GetColorTexture();
80   return Dali::Texture( texturePtr );
81 }
82
83 } //namespace Dali