/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments )
: mEventThreadServices( EventThreadServices::Get() ),
mRenderObject( NULL ),
- mColor( NULL ),
+ mColor{ nullptr },
mWidth( width ),
mHeight( height ),
mAttachments( attachments ),
+ mColorAttachmentCount( 0 ),
mIsSurfaceBacked( false )
{
}
}
else
{
- if( ( texture->GetWidth() / ( 1u << mipmapLevel ) == mWidth ) &&
- ( texture->GetHeight() / ( 1u << mipmapLevel ) == mHeight ) )
+ if( ( texture->GetWidth() / ( 1u << mipmapLevel ) != mWidth ) ||
+ ( texture->GetHeight() / ( 1u << mipmapLevel ) != mHeight ) )
{
- mColor = texture;
- AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer );
+ DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" );
+ }
+ else if ( mColorAttachmentCount >= Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS )
+ {
+ DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Exceeded maximum supported color attachments.\n" );
}
else
{
- DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" );
+ mColor[mColorAttachmentCount] = texture;
+ ++mColorAttachmentCount;
+
+ AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer );
}
}
}
-Texture* FrameBuffer::GetColorTexture()
+Texture* FrameBuffer::GetColorTexture(uint8_t index) const
{
- return mIsSurfaceBacked ? nullptr : mColor.Get();
+ return ( mIsSurfaceBacked || index >= mColorAttachmentCount ) ? nullptr : mColor[index].Get();
}
void FrameBuffer::SetSize( uint32_t width, uint32_t height )
}
}
-void FrameBuffer::SetBackgroundColor( const Vector4& color )
+void FrameBuffer::MarkSurfaceAsInvalid()
{
- if( mRenderObject->IsSurfaceBacked() )
+ if ( mIsSurfaceBacked )
{
- SetFrameBufferBackgroundColorMessage( mEventThreadServices.GetUpdateManager(), static_cast<Render::SurfaceFrameBuffer*>( mRenderObject ), color );
+ Render::SurfaceFrameBuffer* renderObject = static_cast<Render::SurfaceFrameBuffer*>( mRenderObject );
+ renderObject->MarkSurfaceAsInvalid();
}
}
-void FrameBuffer::MarkSurfaceAsInvalid()
+void FrameBuffer::SetPartialUpdateEnabled( bool value )
{
- if ( mIsSurfaceBacked )
+ if( mRenderObject->IsSurfaceBacked() )
{
- Render::SurfaceFrameBuffer* renderObject = static_cast<Render::SurfaceFrameBuffer*>( mRenderObject );
- renderObject->MarkSurfaceAsInvalid();
+ SetFrameBufferPartialUpdateMessage( mEventThreadServices.GetUpdateManager(), static_cast<Render::SurfaceFrameBuffer*>( mRenderObject ), value );
}
}
+
FrameBuffer::~FrameBuffer()
{
if( EventThreadServices::IsCoreRunning() && mRenderObject )