Fix FrameBuffer sync issue, etc.
[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   mWidth( mSurface->GetPositionSize().width ),
35   mHeight( mSurface->GetPositionSize().height ),
36   mBackgroundColor( 0.f, 0.f, 0.f, 1.f ),
37   mSizeChanged( false )
38 {
39 }
40
41 SurfaceFrameBuffer::~SurfaceFrameBuffer()
42 {}
43
44 void SurfaceFrameBuffer::Destroy( Context& context )
45 {
46 }
47
48 void SurfaceFrameBuffer::GlContextDestroyed()
49 {
50   if ( mContext )
51   {
52     mContext->GlContextDestroyed();
53   }
54 }
55
56 void SurfaceFrameBuffer::Initialize(Context& context)
57 {
58   mContext = &context;
59   mContext->GlContextCreated();
60   mSurface->InitializeGraphics();
61 }
62
63 void SurfaceFrameBuffer::Bind( Context& context )
64 {
65   mSurface->PreRender( mSizeChanged );
66
67   context.BindFramebuffer( GL_FRAMEBUFFER, 0u );
68 }
69
70 uint32_t SurfaceFrameBuffer::GetWidth() const
71 {
72   return mWidth;
73 }
74
75 uint32_t SurfaceFrameBuffer::GetHeight() const
76 {
77   return mHeight;
78 }
79
80 void SurfaceFrameBuffer::PostRender()
81 {
82   mSurface->PostRender( false, false, mSizeChanged );
83
84   mSizeChanged = false;
85 }
86
87 Context* SurfaceFrameBuffer::GetContext()
88 {
89   return mContext;
90 }
91
92 Integration::DepthBufferAvailable SurfaceFrameBuffer::GetDepthBufferRequired()
93 {
94   return mSurface->GetDepthBufferRequired();
95 }
96
97 Integration::StencilBufferAvailable SurfaceFrameBuffer::GetStencilBufferRequired()
98 {
99   return mSurface->GetStencilBufferRequired();
100 }
101
102 Vector4 SurfaceFrameBuffer::GetBackgroundColor()
103 {
104   return mBackgroundColor;
105 }
106
107 void SurfaceFrameBuffer::SetSize( uint32_t width, uint32_t height )
108 {
109   mWidth = width;
110   mHeight = height;
111   mSizeChanged = true;
112 }
113
114 void SurfaceFrameBuffer::SetBackgroundColor( const Vector4& color )
115 {
116   mBackgroundColor = color;
117 }
118
119 } //Render
120
121 } //Internal
122
123 } //Dali