Fix MSVC warning.
[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   mSizeChanged( false ),
37   mIsSurfaceInvalid( false )
38 {
39 }
40
41 SurfaceFrameBuffer::~SurfaceFrameBuffer()
42 {}
43
44 void SurfaceFrameBuffer::Destroy( Context& context )
45 {
46   if ( IsSurfaceValid() )
47   {
48     mSurface->DestroySurface();
49     mSurface = nullptr;
50   }
51 }
52
53 void SurfaceFrameBuffer::GlContextDestroyed()
54 {
55   if ( mContext )
56   {
57     mContext->GlContextDestroyed();
58   }
59
60   if ( IsSurfaceValid() )
61   {
62     mSurface->DestroySurface();
63     mSurface = nullptr;
64   }
65 }
66
67 void SurfaceFrameBuffer::Initialize(Context& context)
68 {
69   mContext = &context;
70   mContext->GlContextCreated();
71
72   if ( IsSurfaceValid() )
73   {
74     mSurface->InitializeGraphics();
75   }
76 }
77
78 void SurfaceFrameBuffer::Bind( Context& context )
79 {
80   if ( IsSurfaceValid() )
81   {
82     mSurface->PreRender( mSizeChanged );
83
84     context.BindFramebuffer( GL_FRAMEBUFFER, 0u );
85   }
86 }
87
88 uint32_t SurfaceFrameBuffer::GetWidth() const
89 {
90   return mWidth;
91 }
92
93 uint32_t SurfaceFrameBuffer::GetHeight() const
94 {
95   return mHeight;
96 }
97
98 void SurfaceFrameBuffer::PostRender()
99 {
100   if ( IsSurfaceValid() )
101   {
102     mSurface->PostRender( false, false, mSizeChanged );
103   }
104
105   mSizeChanged = false;
106 }
107
108 Context* SurfaceFrameBuffer::GetContext()
109 {
110   return mContext;
111 }
112
113 void SurfaceFrameBuffer::MakeContextCurrent()
114 {
115   if ( IsSurfaceValid() )
116   {
117     mSurface->MakeContextCurrent();
118   }
119 }
120
121 void SurfaceFrameBuffer::SetSize( uint32_t width, uint32_t height )
122 {
123   mWidth = width;
124   mHeight = height;
125   mSizeChanged = true;
126 }
127
128 bool SurfaceFrameBuffer::IsSurfaceValid() const
129 {
130   return mSurface && !mIsSurfaceInvalid;
131 }
132
133 } //Render
134
135 } //Internal
136
137 } //Dali