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 mBackgroundColor( 0.f, 0.f, 0.f, 1.f ),
37 mSizeChanged( false ),
38 mIsSurfaceInvalid( false )
42 SurfaceFrameBuffer::~SurfaceFrameBuffer()
45 void SurfaceFrameBuffer::Destroy( Context& context )
47 if ( IsSurfaceValid() )
49 mSurface->DestroySurface();
54 void SurfaceFrameBuffer::GlContextDestroyed()
58 mContext->GlContextDestroyed();
61 if ( IsSurfaceValid() )
63 mSurface->DestroySurface();
68 void SurfaceFrameBuffer::Initialize(Context& context)
71 mContext->GlContextCreated();
73 if ( IsSurfaceValid() )
75 mSurface->InitializeGraphics();
79 void SurfaceFrameBuffer::Bind( Context& context )
81 if ( IsSurfaceValid() )
83 mSurface->PreRender( mSizeChanged );
85 context.BindFramebuffer( GL_FRAMEBUFFER, 0u );
89 uint32_t SurfaceFrameBuffer::GetWidth() const
94 uint32_t SurfaceFrameBuffer::GetHeight() const
99 void SurfaceFrameBuffer::PostRender()
101 if ( IsSurfaceValid() )
103 mSurface->PostRender( false, false, mSizeChanged );
106 mSizeChanged = false;
109 Context* SurfaceFrameBuffer::GetContext()
114 void SurfaceFrameBuffer::MakeContextCurrent()
116 if ( IsSurfaceValid() )
118 mSurface->MakeContextCurrent();
122 Vector4 SurfaceFrameBuffer::GetBackgroundColor()
124 return mBackgroundColor;
127 void SurfaceFrameBuffer::SetSize( uint32_t width, uint32_t height )
134 void SurfaceFrameBuffer::SetBackgroundColor( const Vector4& color )
136 mBackgroundColor = color;
139 bool SurfaceFrameBuffer::IsSurfaceValid() const
141 return mSurface && !mIsSurfaceInvalid;