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 ( mSurface && !mIsSurfaceInvalid )
49 mSurface->DestroySurface();
54 void SurfaceFrameBuffer::GlContextDestroyed()
58 mContext->GlContextDestroyed();
61 if ( mSurface && !mIsSurfaceInvalid )
63 mSurface->DestroySurface();
68 void SurfaceFrameBuffer::Initialize(Context& context)
71 mContext->GlContextCreated();
73 if ( mSurface && !mIsSurfaceInvalid )
75 mSurface->InitializeGraphics();
79 void SurfaceFrameBuffer::Bind( Context& context )
81 if ( mSurface && !mIsSurfaceInvalid )
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 ( mSurface && !mIsSurfaceInvalid )
103 mSurface->PostRender( false, false, mSizeChanged );
106 mSizeChanged = false;
109 Context* SurfaceFrameBuffer::GetContext()
114 void SurfaceFrameBuffer::MakeContextCurrent()
116 if ( mSurface && !mIsSurfaceInvalid )
118 mSurface->MakeContextCurrent();
122 Integration::DepthBufferAvailable SurfaceFrameBuffer::GetDepthBufferRequired()
124 return mSurface && !mIsSurfaceInvalid ? Integration::DepthBufferAvailable::FALSE : mSurface->GetDepthBufferRequired();
127 Integration::StencilBufferAvailable SurfaceFrameBuffer::GetStencilBufferRequired()
129 return mSurface && !mIsSurfaceInvalid ? Integration::StencilBufferAvailable::TRUE : mSurface->GetStencilBufferRequired();
132 Vector4 SurfaceFrameBuffer::GetBackgroundColor()
134 return mBackgroundColor;
137 void SurfaceFrameBuffer::SetSize( uint32_t width, uint32_t height )
144 void SurfaceFrameBuffer::SetBackgroundColor( const Vector4& color )
146 mBackgroundColor = color;