X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frendering%2Fframe-buffer-impl.cpp;h=e26b0eea5a8bc8f7aa0ec6312dcdf7a7801f1af0;hb=79881246746f65474b24ea4fe14151ccef8df3f4;hp=20d09d3ccac2cd63f1517b5aa67266c45e9a3422;hpb=06fe515b4e32f42fe9ba3723df05a3628aa51ed1;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/rendering/frame-buffer-impl.cpp b/dali/internal/event/rendering/frame-buffer-impl.cpp index 20d09d3..e26b0ee 100644 --- a/dali/internal/event/rendering/frame-buffer-impl.cpp +++ b/dali/internal/event/rendering/frame-buffer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 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. @@ -20,7 +20,6 @@ // INTERNAL INCLUDES #include -#include #include namespace Dali @@ -28,52 +27,66 @@ namespace Dali namespace Internal { -FrameBufferPtr FrameBuffer::New( unsigned int width, unsigned int height, unsigned int attachments ) +FrameBufferPtr FrameBuffer::New( uint32_t width, uint32_t height, Mask attachments ) { FrameBufferPtr frameBuffer( new FrameBuffer( width, height, attachments ) ); frameBuffer->Initialize(); return frameBuffer; } - Render::FrameBuffer* FrameBuffer::GetRenderObject() const { return mRenderObject; } -FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments ) -: mEventThreadServices( *Stage::GetCurrent() ), +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 ) + mAttachments( attachments ), + mColorAttachmentCount( 0 ) { } void FrameBuffer::Initialize() { - mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments ); - AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject ); + mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments ); + + OwnerPointer< Render::FrameBuffer > transferOwnership( mRenderObject ); + AddFrameBuffer( mEventThreadServices.GetUpdateManager(), transferOwnership ); } -void FrameBuffer::AttachColorTexture( TexturePtr texture, unsigned int mipmapLevel, unsigned int layer ) +void FrameBuffer::AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer ) { - 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 ( index >= mColorAttachmentCount ) ? nullptr : mColor[index].Get(); +} + +void FrameBuffer::SetSize( uint32_t width, uint32_t height ) { - return mColor.Get(); + mWidth = width; + mHeight = height; } FrameBuffer::~FrameBuffer()