X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frendering%2Fframe-buffer-impl.cpp;h=fd5f4bff6f79f49a46d1a9a8c09c5e1e1196f469;hb=d8944bba8449a3c5bce03041eccccf2eba4a7ae3;hp=c2cfc8081e0c013bdd53829e655d4f65e52d3ac8;hpb=b30bdab12215357d26d8b3aca47d225419eae5fd;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 c2cfc80..fd5f4bf 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) 2016 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,60 +20,89 @@ // INTERNAL INCLUDES #include -#include #include +#include +#include +#include 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; } +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, unsigned int attachments ) -: mEventThreadServices( *Stage::GetCurrent() ), +FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments ) +: mEventThreadServices( EventThreadServices::Get() ), mRenderObject( NULL ), mColor( NULL ), mWidth( width ), mHeight( height ), - mAttachments( attachments ) + mAttachments( attachments ), + mIsSurfaceBacked( false ) { } -void FrameBuffer::Initialize() +void FrameBuffer::Initialize( Integration::RenderSurface* renderSurface ) { - mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments ); + 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 ); + } + AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject ); } -void FrameBuffer::AttachColorTexture( TexturePtr texture, unsigned int mipmapLevel, unsigned int layer ) +void FrameBuffer::AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer ) { - if( (unsigned int)( texture->GetWidth() / ( 1 << mipmapLevel ) ) == mWidth && - (unsigned int)( texture->GetHeight() / ( 1 << mipmapLevel ) ) == mHeight ) + if ( mIsSurfaceBacked ) { - mColor = texture; - AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer ); + DALI_LOG_ERROR( "Attempted to attach color texture to a render surface backed FrameBuffer \n" ); } else { - DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" ); + 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 mColor.Get(); + return mIsSurfaceBacked ? nullptr : mColor.Get(); } FrameBuffer::~FrameBuffer()