[3.0] Remove/move experimental features
[platform/core/uifw/dali-core.git] / dali / internal / event / images / frame-buffer-image-impl.cpp
index fbd88d4..de3fe78 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
@@ -19,6 +19,7 @@
 #include <dali/internal/event/images/frame-buffer-image-impl.h>
 
 // INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
 #include <dali/internal/event/common/thread-local-storage.h>
 #include <dali/internal/event/resources/resource-client.h>
 
@@ -28,31 +29,49 @@ namespace Dali
 namespace Internal
 {
 
-FrameBufferImage::~FrameBufferImage()
+namespace
+{
+TypeRegistration mType( typeid( Dali::FrameBufferImage ), typeid( Dali::Image ), NULL );
+} // unnamed namespace
+
+FrameBufferImagePtr FrameBufferImage::New( unsigned int width,
+                                           unsigned int height,
+                                           Pixel::Format pixelFormat,
+                                           RenderBuffer::Format bufferformat )
 {
+  FrameBufferImagePtr image = new FrameBufferImage( width, height, pixelFormat, bufferformat );
+  image->Initialize();
+  return image;
 }
 
-FrameBufferImage::FrameBufferImage(unsigned int width, unsigned int height, Pixel::Format pixelFormat, ReleasePolicy releasePolicy)
-: Image(Dali::Image::Immediate, releasePolicy),
-  mPixelFormat(pixelFormat)
+FrameBufferImagePtr FrameBufferImage::New( NativeImageInterface& nativeImage )
 {
-  mWidth  = width;
-  mHeight = height;
+  FrameBufferImagePtr image = new FrameBufferImage( nativeImage );
+  image->Initialize();
+  return image;
 }
 
-FrameBufferImage::FrameBufferImage( NativeImage& nativeImage )
-: Image(Dali::Image::Immediate),
-  mNativeImage(&nativeImage),
-  mPixelFormat(nativeImage.GetPixelFormat())
+
+FrameBufferImage::FrameBufferImage( unsigned int width,
+                                    unsigned int height,
+                                    Pixel::Format pixelFormat,
+                                    RenderBuffer::Format bufferformat )
+: Image(),
+  mNativeImage(0),
+  mPixelFormat( pixelFormat ),
+  mBufferFormat( bufferformat ),
+  mIsNativeFbo( false )
 {
-  mWidth = nativeImage.GetWidth();
-  mHeight = nativeImage.GetHeight();
+  mWidth  = width;
+  mHeight = height;
 }
 
-FrameBufferImage::FrameBufferImage( NativeImage& nativeImage, ReleasePolicy releasePolicy )
-: Image(Dali::Image::Immediate, releasePolicy),
-  mNativeImage(&nativeImage),
-  mPixelFormat(nativeImage.GetPixelFormat())
+FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage )
+: Image(),
+  mNativeImage( &nativeImage ),
+  mPixelFormat( Pixel::FIRST_VALID_PIXEL_FORMAT ),
+  mBufferFormat( RenderBuffer::COLOR ),
+  mIsNativeFbo( true )
 {
   mWidth = nativeImage.GetWidth();
   mHeight = nativeImage.GetHeight();
@@ -75,7 +94,7 @@ void FrameBufferImage::Connect()
       }
       else
       {
-        mTicket = resourceClient.AddFrameBufferImage(mWidth, mHeight, mPixelFormat);
+        mTicket = resourceClient.AddFrameBufferImage(mWidth, mHeight, mPixelFormat, mBufferFormat);
         mTicket->AddObserver(*this);
       }
     }
@@ -91,7 +110,7 @@ void FrameBufferImage::Disconnect()
 
   DALI_ASSERT_DEBUG(mConnectionCount > 0);
   --mConnectionCount;
-  if (mConnectionCount == 0 && mReleasePolicy == Dali::Image::Unused)
+  if (mConnectionCount == 0)
   {
     // release image memory when it's not visible anymore (decrease ref. count of texture)
     mTicket->RemoveObserver(*this);
@@ -99,6 +118,15 @@ void FrameBufferImage::Disconnect()
   }
 }
 
+bool FrameBufferImage::IsNativeFbo() const
+{
+  return mIsNativeFbo;
+}
+
+FrameBufferImage::~FrameBufferImage()
+{
+}
+
 } // namespace Internal
 
 } // namespace Dali