2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali/internal/render/renderers/render-surface-frame-buffer.h>
21 #include <dali/internal/render/renderers/render-texture.h>
30 SurfaceFrameBuffer::SurfaceFrameBuffer( Integration::RenderSurface* surface )
34 mWidth( mSurface->GetPositionSize().width ),
35 mHeight( mSurface->GetPositionSize().height ),
36 mSizeChanged( false ),
37 mIsSurfaceInvalid( false )
41 SurfaceFrameBuffer::~SurfaceFrameBuffer()
44 void SurfaceFrameBuffer::Destroy( Context& context )
46 if ( IsSurfaceValid() )
48 mSurface->DestroySurface();
53 void SurfaceFrameBuffer::GlContextDestroyed()
57 mContext->GlContextDestroyed();
60 if ( IsSurfaceValid() )
62 mSurface->DestroySurface();
67 void SurfaceFrameBuffer::Initialize(Context& context)
70 mContext->GlContextCreated();
72 if ( IsSurfaceValid() )
74 mSurface->InitializeGraphics();
78 void SurfaceFrameBuffer::Bind( Context& context )
80 if ( IsSurfaceValid() )
82 mSurface->PreRender( mSizeChanged );
84 context.BindFramebuffer( GL_FRAMEBUFFER, 0u );
88 uint32_t SurfaceFrameBuffer::GetWidth() const
93 uint32_t SurfaceFrameBuffer::GetHeight() const
98 void SurfaceFrameBuffer::PostRender()
100 if ( IsSurfaceValid() )
102 mSurface->PostRender( false, false, mSizeChanged );
105 mSizeChanged = false;
108 Context* SurfaceFrameBuffer::GetContext()
113 void SurfaceFrameBuffer::MakeContextCurrent()
115 if ( IsSurfaceValid() )
117 mSurface->MakeContextCurrent();
121 void SurfaceFrameBuffer::SetSize( uint32_t width, uint32_t height )
128 bool SurfaceFrameBuffer::IsSurfaceValid() const
130 return mSurface && !mIsSurfaceInvalid;