X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Frendering%2Fframe-buffer.cpp;h=4b45a9293f22dbf9b37b7a0884f404ebb9085860;hb=8a73b1bfdc359a52a3cf1b104b4e42902866705e;hp=607a79bc0788861615adf6ea93cd5a23cd5b8c7f;hpb=8d0e709881228a75a94d9e077087e9cc73363436;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/rendering/frame-buffer.cpp b/dali/public-api/rendering/frame-buffer.cpp index 607a79b..4b45a92 100644 --- a/dali/public-api/rendering/frame-buffer.cpp +++ b/dali/public-api/rendering/frame-buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -18,66 +18,84 @@ // CLASS HEADER #include +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES +#include // DALI_LOG_WARNING_NOFN #include // Dali::Internal::FrameBuffer - +#include // Dali::Internal::Texture namespace Dali { - -FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height, uint32_t attachments ) +namespace { - Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New( width, height, attachments ); - return FrameBuffer( frameBuffer.Get() ); -} - -FrameBuffer::FrameBuffer() +/// Bool operator for FrameBuffer::Attachment::Mask. +/// in cpp as only used in this file +bool operator&(FrameBuffer::Attachment::Mask lhs, FrameBuffer::Attachment::Mask rhs) { + using UnderlyingType = typename std::underlying_type::type; + return static_cast(static_cast(lhs) & static_cast(rhs)); } -FrameBuffer::~FrameBuffer() -{ -} +} // unnamed namespace -FrameBuffer::FrameBuffer( const FrameBuffer& handle ) -: BaseHandle( handle ) +FrameBuffer FrameBuffer::New(uint32_t width, uint32_t height) { + return New(width, height, FrameBuffer::Attachment::COLOR); } -FrameBuffer FrameBuffer::DownCast( BaseHandle handle ) +FrameBuffer FrameBuffer::New(uint32_t width, uint32_t height, Attachment::Mask attachments) { - return FrameBuffer( dynamic_cast(handle.GetObjectPtr())); + Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New(width, height, attachments); + if(attachments & FrameBuffer::Attachment::COLOR) + { + Internal::TexturePtr texture = Internal::Texture::New(Dali::TextureType::TEXTURE_2D, Pixel::RGB888, width, height); + frameBuffer->AttachColorTexture(texture, 0u, 0u); + } + return FrameBuffer(frameBuffer.Get()); } -FrameBuffer& FrameBuffer::operator=( const FrameBuffer& handle ) +FrameBuffer::FrameBuffer() = default; + +FrameBuffer::~FrameBuffer() = default; + +FrameBuffer::FrameBuffer(const FrameBuffer& handle) = default; + +FrameBuffer FrameBuffer::DownCast(BaseHandle handle) { - BaseHandle::operator=( handle ); - return *this; + return FrameBuffer(dynamic_cast(handle.GetObjectPtr())); } -FrameBuffer::FrameBuffer( Internal::FrameBuffer* pointer ) -: BaseHandle( pointer ) +FrameBuffer& FrameBuffer::operator=(const FrameBuffer& handle) = default; + +FrameBuffer::FrameBuffer(Internal::FrameBuffer* pointer) +: BaseHandle(pointer) { } -void FrameBuffer::AttachColorTexture( Texture& texture ) +FrameBuffer::FrameBuffer(FrameBuffer&& rhs) = default; + +FrameBuffer& FrameBuffer::operator=(FrameBuffer&& rhs) = default; + +void FrameBuffer::AttachColorTexture(Texture& texture) { - AttachColorTexture( texture, 0u, 0u ); + AttachColorTexture(texture, 0u, 0u); } -void FrameBuffer::AttachColorTexture( Texture& texture, uint32_t mipmapLevel, uint32_t layer ) +void FrameBuffer::AttachColorTexture(Texture& texture, uint32_t mipmapLevel, uint32_t layer) { - if( texture ) + if(texture) { - Internal::TexturePtr texturePtr( &GetImplementation( texture ) ); - GetImplementation(*this).AttachColorTexture( texturePtr, mipmapLevel, layer ); + Internal::TexturePtr texturePtr(&GetImplementation(texture)); + GetImplementation(*this).AttachColorTexture(texturePtr, mipmapLevel, layer); } } Texture FrameBuffer::GetColorTexture() { - Internal::Texture* texturePtr = GetImplementation(*this).GetColorTexture(); - return Dali::Texture( texturePtr ); + Internal::Texture* texturePtr = GetImplementation(*this).GetColorTexture(0); + return Dali::Texture(texturePtr); } } //namespace Dali