X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fimages%2Fframe-buffer-image-impl.cpp;h=15aa6a8ff4cf533456491fbb6c7304fa3edb61ca;hb=698c38bd1a76158dd449639aaf014d7046dd3ae4;hp=b7fda1904edd8b4a01df59f590315e07ddcfac3f;hpb=81b7e4a80108cf6f2c60fa3bc55f540640fb881d;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/images/frame-buffer-image-impl.cpp b/dali/internal/event/images/frame-buffer-image-impl.cpp index b7fda19..15aa6a8 100644 --- a/dali/internal/event/images/frame-buffer-image-impl.cpp +++ b/dali/internal/event/images/frame-buffer-image-impl.cpp @@ -21,7 +21,6 @@ // INTERNAL INCLUDES #include #include -#include namespace Dali { @@ -32,6 +31,13 @@ namespace Internal namespace { TypeRegistration mType( typeid( Dali::FrameBufferImage ), typeid( Dali::Image ), NULL ); + +const int RenderBufferFormatToFrameBufferAttachments[] = { Dali::FrameBuffer::Attachment::NONE, + Dali::FrameBuffer::Attachment::DEPTH, + Dali::FrameBuffer::Attachment::STENCIL, + Dali::FrameBuffer::Attachment::DEPTH_STENCIL + }; + } // unnamed namespace FrameBufferImagePtr FrameBufferImage::New( unsigned int width, @@ -39,8 +45,13 @@ FrameBufferImagePtr FrameBufferImage::New( unsigned int width, Pixel::Format pixelFormat, RenderBuffer::Format bufferformat ) { - FrameBufferImagePtr image = new FrameBufferImage( width, height, pixelFormat, bufferformat ); + FrameBufferImagePtr image = new FrameBufferImage( width, height ); image->Initialize(); + + image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelFormat, width, height ); + image->mFrameBufferObject = FrameBuffer::New( width, height, RenderBufferFormatToFrameBufferAttachments[bufferformat] ); + image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u ); + return image; } @@ -48,18 +59,17 @@ FrameBufferImagePtr FrameBufferImage::New( NativeImageInterface& nativeImage ) { FrameBufferImagePtr image = new FrameBufferImage( nativeImage ); image->Initialize(); + + image->mTexture = Texture::New( nativeImage ); + image->mFrameBufferObject = FrameBuffer::New( image->mTexture->GetWidth(), image->mTexture->GetHeight(), Dali::FrameBuffer::Attachment::NONE ); + image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u ); + return image; } - -FrameBufferImage::FrameBufferImage( unsigned int width, - unsigned int height, - Pixel::Format pixelFormat, - RenderBuffer::Format bufferformat ) +FrameBufferImage::FrameBufferImage( unsigned int width, unsigned int height) : Image(), mNativeImage(0), - mPixelFormat( pixelFormat ), - mBufferFormat( bufferformat ), mIsNativeFbo( false ) { mWidth = width; @@ -69,59 +79,18 @@ FrameBufferImage::FrameBufferImage( unsigned int width, FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage ) : Image(), mNativeImage( &nativeImage ), - mPixelFormat( Pixel::FIRST_VALID_PIXEL_FORMAT ), - mBufferFormat( RenderBuffer::COLOR ), mIsNativeFbo( true ) { mWidth = nativeImage.GetWidth(); mHeight = nativeImage.GetHeight(); } -void FrameBufferImage::Connect() -{ - ++mConnectionCount; - - if (mConnectionCount == 1) - { - // ticket was thrown away when related actors went offstage - if (!mTicket) - { - ResourceClient& resourceClient = ThreadLocalStorage::Get().GetResourceClient(); - if (mNativeImage) - { - mTicket = resourceClient.AddFrameBufferImage(*mNativeImage); - mTicket->AddObserver(*this); - } - else - { - mTicket = resourceClient.AddFrameBufferImage(mWidth, mHeight, mPixelFormat, mBufferFormat); - mTicket->AddObserver(*this); - } - } - } -} - -void FrameBufferImage::Disconnect() -{ - if(!mTicket) - { - return; - } - - DALI_ASSERT_DEBUG(mConnectionCount > 0); - --mConnectionCount; - if (mConnectionCount == 0 && mReleasePolicy == Dali::Image::UNUSED) - { - // release image memory when it's not visible anymore (decrease ref. count of texture) - mTicket->RemoveObserver(*this); - mTicket.Reset(); - } -} bool FrameBufferImage::IsNativeFbo() const { return mIsNativeFbo; } + FrameBufferImage::~FrameBufferImage() { }