Support multiple window rendering
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-surface-frame-buffer.cpp
1 /*
2  * Copyright (c) 2019 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 // CLASS HEADER
18 #include <dali/internal/render/renderers/render-surface-frame-buffer.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/internal/render/renderers/render-texture.h>
22
23 namespace Dali
24 {
25 namespace Internal
26 {
27 namespace Render
28 {
29
30 SurfaceFrameBuffer::SurfaceFrameBuffer( Integration::RenderSurface* surface )
31 : FrameBuffer(),
32   mSurface( surface ),
33   mContext( nullptr )
34 {
35 }
36
37 SurfaceFrameBuffer::~SurfaceFrameBuffer()
38 {}
39
40 void SurfaceFrameBuffer::Destroy( Context& context )
41 {
42 }
43
44 void SurfaceFrameBuffer::GlContextDestroyed()
45 {
46   if ( mContext )
47   {
48     mContext->GlContextDestroyed();
49   }
50 }
51
52 void SurfaceFrameBuffer::Initialize(Context& context)
53 {
54   mContext = &context;
55   mContext->GlContextCreated();
56   mSurface->InitializeGraphics();
57 }
58
59 void SurfaceFrameBuffer::Bind( Context& context )
60 {
61   mSurface->PreRender( false );
62   context.BindFramebuffer( GL_FRAMEBUFFER, 0u );
63 }
64
65 uint32_t SurfaceFrameBuffer::GetWidth() const
66 {
67   return mSurface->GetPositionSize().width;
68 }
69
70 uint32_t SurfaceFrameBuffer::GetHeight() const
71 {
72   return mSurface->GetPositionSize().height;
73 }
74
75 void SurfaceFrameBuffer::PostRender()
76 {
77   mSurface->PostRender( false, false, false );
78 }
79
80 Context* SurfaceFrameBuffer::GetContext()
81 {
82   return mContext;
83 }
84
85 Integration::DepthBufferAvailable SurfaceFrameBuffer::GetDepthBufferRequired()
86 {
87   return mSurface->GetDepthBufferRequired();
88 }
89
90 Integration::StencilBufferAvailable SurfaceFrameBuffer::GetStencilBufferRequired()
91 {
92   return mSurface->GetStencilBufferRequired();
93 }
94
95 Vector4 SurfaceFrameBuffer::GetBackgroundColor()
96 {
97   return mSurface->GetBackgroundColor();
98 }
99
100 } //Render
101
102 } //Internal
103
104 } //Dali