From bdbb3f2da1292e0252f39e9e8739e27f28f0fd83 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 20 Nov 2024 14:38:27 +0900 Subject: [PATCH] (CanvasRenderer) Let we use CanvasRenderer use queue size 2 as default + Cancel old buffer if dequeue failed Since we don't have good timing to free-release remained buffer, let we just use tbm_surface_queue_h has 2 + Let we ignore latest queued image if dequeue failed. In this case, we can ensure that success queued buffer is always latest buffer now. Change-Id: I8e49b6d56fc3b6b60cdae9647b998c7baea52dec Signed-off-by: Eunki, Hong --- .../tizen/canvas-renderer-impl-tizen.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dali/internal/canvas-renderer/tizen/canvas-renderer-impl-tizen.cpp b/dali/internal/canvas-renderer/tizen/canvas-renderer-impl-tizen.cpp index 67413dadd..d15942c0a 100644 --- a/dali/internal/canvas-renderer/tizen/canvas-renderer-impl-tizen.cpp +++ b/dali/internal/canvas-renderer/tizen/canvas-renderer-impl-tizen.cpp @@ -44,6 +44,11 @@ Dali::BaseHandle Create() Dali::TypeRegistration type(typeid(Dali::CanvasRenderer), typeid(Dali::BaseHandle), Create); +#ifdef THORVG_SUPPORT +constexpr uint32_t CANVAS_RENDERER_QUEUE_SIZE = 2u; ///< The number of buffers in native image queue. + ///< Let we use double-buffer as default. +#endif + } // unnamed namespace CanvasRendererTizen* CanvasRendererTizen::New(const Vector2& viewBox) @@ -324,8 +329,22 @@ bool CanvasRendererTizen::Rasterize() #ifdef THORVG_SUPPORT Mutex::ScopedLock lock(mMutex); - if(mNativeImageQueue && mNativeImageQueue->CanDequeueBuffer()) + if(mNativeImageQueue) { + bool canDequeue = mNativeImageQueue->CanDequeueBuffer(); + if(!canDequeue) + { + // Ignore the previous image which is inserted to the queue. + mNativeImageQueue->IgnoreSourceImage(); + + // Check again + canDequeue = mNativeImageQueue->CanDequeueBuffer(); + if(!canDequeue) + { + return false; + } + } + uint32_t width, height, stride; uint8_t* buffer = mNativeImageQueue->DequeueBuffer(width, height, stride); if(!buffer) @@ -448,7 +467,7 @@ void CanvasRendererTizen::MakeTargetBuffer(const Vector2& size) #ifdef THORVG_SUPPORT if(!mNativeImageQueue) { - mNativeImageQueue = Dali::NativeImageSourceQueue::New(size.width, size.height, Dali::NativeImageSourceQueue::ColorFormat::BGRA8888); + mNativeImageQueue = Dali::NativeImageSourceQueue::New(CANVAS_RENDERER_QUEUE_SIZE, size.width, size.height, Dali::NativeImageSourceQueue::ColorFormat::BGRA8888); } else { -- 2.34.1