[3.0] Fix for FrameBufferImage. 27/120127/3 accepted/tizen/3.0/common/20170324.142009 accepted/tizen/3.0/ivi/20170324.114425 accepted/tizen/3.0/mobile/20170324.114223 accepted/tizen/3.0/tv/20170324.114307 accepted/tizen/3.0/wearable/20170324.114347 submit/tizen_3.0/20170323.121626 submit/tizen_3.0/20170324.051322
authorVictor Cebollada <v.cebollada@samsung.com>
Fri, 17 Mar 2017 18:05:09 +0000 (18:05 +0000)
committerVíctor Cebollada <v.cebollada@samsung.com>
Tue, 21 Mar 2017 16:28:21 +0000 (09:28 -0700)
* The Connect() and Disconnect() methods are unnecessarily
  implementing a counter that tracks how many handlers are
  observing the frame buffer image. In case that the frame
  buffer image is not observed by any handler, the internal
  FBO is destroyed. A handler may observe again the frame
  buffer image but the FBO has already been destroyed.

  This caused an issue with the GaussianBlurView effect which
  was using a render task to blur an image and a frabe buffer
  image to write the blurred image.

Change-Id: I89a7de6f97ee52fb219f8b7641d4d2bbb42764d5
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali/internal/event/images/frame-buffer-image-impl.cpp
dali/internal/event/images/frame-buffer-image-impl.h
dali/internal/event/images/image-impl.cpp
dali/internal/event/images/image-impl.h
dali/internal/event/render-tasks/render-task-impl.cpp
dali/internal/update/render-tasks/scene-graph-render-task.cpp

index de3fe78..29a06a7 100644 (file)
@@ -56,32 +56,28 @@ FrameBufferImage::FrameBufferImage( unsigned int width,
                                     unsigned int height,
                                     Pixel::Format pixelFormat,
                                     RenderBuffer::Format bufferformat )
-: Image(),
+: Image( width, height ),
   mNativeImage(0),
   mPixelFormat( pixelFormat ),
   mBufferFormat( bufferformat ),
-  mIsNativeFbo( false )
+  mIsNativeFbo( false ),
+  mIsConnected( false )
 {
-  mWidth  = width;
-  mHeight = height;
 }
 
 FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage )
-: Image(),
+: Image( nativeImage.GetWidth(), nativeImage.GetHeight() ),
   mNativeImage( &nativeImage ),
   mPixelFormat( Pixel::FIRST_VALID_PIXEL_FORMAT ),
   mBufferFormat( RenderBuffer::COLOR ),
-  mIsNativeFbo( true )
+  mIsNativeFbo( true ),
+  mIsConnected( false )
 {
-  mWidth = nativeImage.GetWidth();
-  mHeight = nativeImage.GetHeight();
 }
 
 void FrameBufferImage::Connect()
 {
-  ++mConnectionCount;
-
-  if (mConnectionCount == 1)
+  if( !mIsConnected )
   {
     // ticket was thrown away when related actors went offstage
     if (!mTicket)
@@ -98,24 +94,13 @@ void FrameBufferImage::Connect()
         mTicket->AddObserver(*this);
       }
     }
+    mIsConnected = true;
   }
 }
 
 void FrameBufferImage::Disconnect()
 {
-  if(!mTicket)
-  {
-    return;
-  }
-
-  DALI_ASSERT_DEBUG(mConnectionCount > 0);
-  --mConnectionCount;
-  if (mConnectionCount == 0)
-  {
-    // release image memory when it's not visible anymore (decrease ref. count of texture)
-    mTicket->RemoveObserver(*this);
-    mTicket.Reset();
-  }
+  // Nothing to do.
 }
 
 bool FrameBufferImage::IsNativeFbo() const
index 42d5872..1316e3e 100644 (file)
@@ -85,7 +85,8 @@ private:
   NativeImageInterfacePtr mNativeImage;
   Pixel::Format mPixelFormat;
   RenderBuffer::Format mBufferFormat;
-  bool mIsNativeFbo;
+  bool mIsNativeFbo : 1;
+  bool mIsConnected : 1;
 }; // class FrameBufferImage
 
 } // namespace Internal
index e90ffeb..51ce7e2 100644 (file)
@@ -115,6 +115,13 @@ Image::Image()
 {
 }
 
+Image::Image( unsigned int width, unsigned int height )
+: mWidth( width ),
+  mHeight( height ),
+  mConnectionCount( 0 )
+{
+}
+
 Image::~Image()
 {
   if( mTicket )
index 15eeff2..357cca1 100644 (file)
@@ -135,6 +135,14 @@ protected:
   Image();
 
   /**
+   * Constructor, with width and height
+   *
+   * @param[in] width The width.
+   * @param[in] height The height.
+   */
+  Image( unsigned int width, unsigned int height );
+
+  /**
    * Second stage initialization
    */
   void Initialize();
index 09514c9..f80167d 100644 (file)
@@ -468,7 +468,7 @@ bool RenderTask::WorldToViewport(const Vector3 &position, float& viewportX, floa
   CameraActor* cam = GetCameraActor();
 
   Vector4 pos(position);
-  pos.w = 1.0;
+  pos.w = 1.f;
 
   Vector4 viewportPosition;
 
index 45de3d4..42dcba5 100644 (file)
@@ -368,7 +368,7 @@ bool RenderTask::IsWaitingToRender()
 bool RenderTask::HasRendered()
 {
   bool notify = false;
-  if( mNotifyTrigger == true )
+  if( mNotifyTrigger )
   {
     ++mRenderedOnceCounter;
     mState = RENDERED_ONCE_AND_NOTIFIED;