return mImpl->EnqueueBuffer(buffer);
}
+void NativeImageSourceQueue::FreeReleasedBuffers()
+{
+ mImpl->FreeReleasedBuffers();
+}
+
bool NativeImageSourceQueue::CreateResource()
{
return mImpl->CreateResource();
bool EnqueueBuffer(uint8_t* buffer);
/**
+ * @brief Free all released buffers.
+ */
+ void FreeReleasedBuffers();
+
+ /**
* @copydoc Dali::NativeImageInterface::GetTextureTarget()
*/
int GetTextureTarget() const override;
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
return false;
}
+void NativeImageSourceQueueAndroid::FreeReleasedBuffers()
+{
+}
+
bool NativeImageSourceQueueAndroid::CreateResource()
{
return true;
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_ANDROID_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
bool EnqueueBuffer(uint8_t* buffer) override;
/**
+ * @copydoc Dali::NativeImageSourceQueue::EnqueueBuffer
+ */
+ void FreeReleasedBuffers() override;
+
+ /**
* destructor
*/
~NativeImageSourceQueueAndroid() override;
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
virtual bool EnqueueBuffer(uint8_t* buffer) = 0;
/**
+ * @copydoc Dali::NativeImageSourceQueue::FreeReleasedBuffers
+ */
+ virtual void FreeReleasedBuffers() = 0;
+
+ /**
* destructor
*/
virtual ~NativeImageSourceQueue() = default;
mEglImageExtensions(NULL),
mOwnTbmQueue(false),
mBlendingRequired(false),
- mIsResized(false)
+ mIsResized(false),
+ mFreeRequest(false)
{
DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
return false;
}
+void NativeImageSourceQueueTizen::FreeReleasedBuffers()
+{
+ Dali::Mutex::ScopedLock lock(mMutex);
+ mFreeRequest = true;
+}
+
bool NativeImageSourceQueueTizen::CreateResource()
{
mEglImageExtensions = mEglGraphics->GetImageExtensions();
{
Dali::Mutex::ScopedLock lock(mMutex);
- tbm_surface_h oldSurface = mConsumeSurface;
+ bool updated = false;
- if(tbm_surface_queue_can_acquire(mTbmQueue, 0))
+ do
{
- if(tbm_surface_queue_acquire(mTbmQueue, &mConsumeSurface) != TBM_SURFACE_QUEUE_ERROR_NONE)
- {
- DALI_LOG_ERROR("Failed to aquire a tbm_surface\n");
- return;
- }
+ tbm_surface_h oldSurface = mConsumeSurface;
- if(oldSurface)
+ if(tbm_surface_queue_can_acquire(mTbmQueue, 0))
{
- if(tbm_surface_internal_is_valid(oldSurface))
+ if(tbm_surface_queue_acquire(mTbmQueue, &mConsumeSurface) != TBM_SURFACE_QUEUE_ERROR_NONE)
+ {
+ DALI_LOG_ERROR("Failed to aquire a tbm_surface\n");
+ return;
+ }
+
+ if(oldSurface)
{
- tbm_surface_queue_release(mTbmQueue, oldSurface);
+ if(tbm_surface_internal_is_valid(oldSurface))
+ {
+ tbm_surface_queue_release(mTbmQueue, oldSurface);
+ }
}
+ updated = true;
+ }
+ else
+ {
+ break;
}
+ } while(mFreeRequest); // Get the last one if buffer free was requested
+ if(updated)
+ {
if(mIsResized)
{
ResetEglImageList(false);
}
}
}
+
+ if(mFreeRequest)
+ {
+ auto iter = std::remove_if(mEglImages.begin(), mEglImages.end(), [&](EglImagePair& eglImage) {
+ if(mConsumeSurface == eglImage.first) return false;
+ mEglImageExtensions->DestroyImageKHR(eglImage.second);
+ tbm_surface_internal_unref(eglImage.first);
+ return true; });
+ mEglImages.erase(iter, mEglImages.end());
+
+ tbm_surface_queue_free_flush(mTbmQueue);
+ mFreeRequest = false;
+ }
}
bool NativeImageSourceQueueTizen::ApplyNativeFragmentShader(std::string& shader)
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
bool EnqueueBuffer(uint8_t* buffer) override;
/**
+ * @copydoc Dali::NativeImageSourceQueue::EnqueueBuffer
+ */
+ void FreeReleasedBuffers() override;
+
+ /**
* destructor
*/
~NativeImageSourceQueueTizen() override;
bool mOwnTbmQueue; ///< Whether we created tbm queue
bool mBlendingRequired; ///< Whether blending is required
bool mIsResized; ///< Whether the size has changed
+ bool mFreeRequest; ///< Whether it is requested to free the released buffers
};
} // namespace Adaptor
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
return false;
}
+void NativeImageSourceQueueX::FreeReleasedBuffers()
+{
+}
+
bool NativeImageSourceQueueX::CreateResource()
{
return true;
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
bool EnqueueBuffer(uint8_t* buffer) override;
/**
+ * @copydoc Dali::NativeImageSourceQueue::EnqueueBuffer
+ */
+ void FreeReleasedBuffers() override;
+
+ /**
* destructor
*/
~NativeImageSourceQueueX() override;
{
namespace Adaptor
{
-
NativeImageSourceQueueX* NativeImageSourceQueueX::New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorFormat colorFormat, Any nativeImageSourceQueue)
{
NativeImageSourceQueueX* image = new NativeImageSourceQueueX(width, height, colorFormat, nativeImageSourceQueue);
return false;
}
+void NativeImageSourceQueueX::FreeReleasedBuffers()
+{
+}
+
bool NativeImageSourceQueueX::CreateResource()
{
return true;
bool EnqueueBuffer(uint8_t* buffer) override;
/**
+ * @copydoc Dali::NativeImageSourceQueue::EnqueueBuffer
+ */
+ void FreeReleasedBuffers() override;
+
+ /**
* destructor
*/
~NativeImageSourceQueueX() override;