X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frendering%2Fframe-buffer-impl.cpp;h=fe94b5ba3da550054bf50ac4a0e311e3e4c7e092;hb=55827866fcb8c7ee47581ac4335a3390472090e8;hp=366a8cbf8e3766b86a3c093496c1a3edef546382;hpb=aab92d59f88deeb60464aa9af9031bb38fea891c;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 old mode 100644 new mode 100755 index 366a8cb..fe94b5b --- 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) 2019 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,62 +20,129 @@ // INTERNAL INCLUDES #include -#include #include +#include +#include +#include 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; } +FrameBufferPtr FrameBuffer::New( Dali::Integration::RenderSurface& renderSurface, Mask attachments ) +{ + Dali::PositionSize positionSize = renderSurface.GetPositionSize(); + FrameBufferPtr frameBuffer( new FrameBuffer( positionSize.width, positionSize.height, attachments ) ); + frameBuffer->Initialize( &renderSurface ); + 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( NULL ), mWidth( width ), mHeight( height ), - mFormat( format ) + mAttachments( attachments ), + mIsSurfaceBacked( false ) { } -void FrameBuffer::Initialize() +void FrameBuffer::Initialize( Integration::RenderSurface* renderSurface ) { - mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mFormat ); - AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject ); + mIsSurfaceBacked = ( renderSurface != nullptr ); + + // If render surface backed, create a different scene object + // Make Render::FrameBuffer as a base class, and implement Render::TextureFrameBuffer & Render::WindowFrameBuffer + if ( mIsSurfaceBacked ) + { + mRenderObject = new Render::SurfaceFrameBuffer( renderSurface ); + } + else + { + mRenderObject = new Render::TextureFrameBuffer( 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<GetRenderObject(), mipmapLevel, layer ); + if( ( texture->GetWidth() / ( 1u << mipmapLevel ) == mWidth ) && + ( texture->GetHeight() / ( 1u << mipmapLevel ) == mHeight ) ) + { + mColor = texture; + AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer ); + } + else + { + DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" ); + } + } +} + +Texture* FrameBuffer::GetColorTexture() +{ + return mIsSurfaceBacked ? nullptr : mColor.Get(); +} + +void FrameBuffer::SetSize( uint32_t width, uint32_t height ) +{ + mWidth = width; + mHeight = height; + + if( mRenderObject->IsSurfaceBacked() ) + { + SetFrameBufferSizeMessage( mEventThreadServices.GetUpdateManager(), static_cast( mRenderObject ), width, height ); + } +} + +void FrameBuffer::SetBackgroundColor( const Vector4& color ) +{ + if( mRenderObject->IsSurfaceBacked() ) + { + SetFrameBufferBackgroundColorMessage( mEventThreadServices.GetUpdateManager(), static_cast( mRenderObject ), color ); } } -NewTexture* FrameBuffer::GetColorTexture() +void FrameBuffer::MarkSurfaceAsInvalid() { - return mColor.Get(); + if ( mIsSurfaceBacked ) + { + Render::SurfaceFrameBuffer* renderObject = static_cast( mRenderObject ); + renderObject->MarkSurfaceAsInvalid(); + } +} + +void FrameBuffer::SetPartialUpdateEnabled( bool value ) +{ + if( mRenderObject->IsSurfaceBacked() ) + { + SetFrameBufferPartialUpdateMessage( mEventThreadServices.GetUpdateManager(), static_cast( mRenderObject ), value ); + } } + FrameBuffer::~FrameBuffer() { if( EventThreadServices::IsCoreRunning() && mRenderObject )