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=366a8cbf8e3766b86a3c093496c1a3edef546382;hpb=6a54569308b889703a8679e7013210ad19192f74;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 366a8cb..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) 2015 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, Format format ) +FrameBufferPtr FrameBuffer::New( uint32_t width, uint32_t height, Mask attachments ) { - FrameBufferPtr frameBuffer( new FrameBuffer( width, height, format ) ); + 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, Format format ) -: 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 ), - mFormat( format ) + mAttachments( attachments ), + mColorAttachmentCount( 0 ) { } void FrameBuffer::Initialize() { - mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mFormat ); - AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject ); + mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments ); + + OwnerPointer< Render::FrameBuffer > transferOwnership( mRenderObject ); + AddFrameBuffer( mEventThreadServices.GetUpdateManager(), transferOwnership ); } -void FrameBuffer::AttachColorTexture( NewTexturePtr texture, unsigned int mipmapLevel, unsigned int layer ) +void FrameBuffer::AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer ) { - if( (unsigned int)(texture->GetWidth() / (1<GetHeight() / (1<GetWidth() / ( 1u << mipmapLevel ) != mWidth ) || + ( texture->GetHeight() / ( 1u << mipmapLevel ) != mHeight ) ) { 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 { - mColor = texture; + mColor[mColorAttachmentCount] = texture; + ++mColorAttachmentCount; + AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer ); } } -NewTexture* 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()