/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
#include <dali/internal/imaging/windows/native-image-source-impl-win.h>
// EXTERNAL INCLUDES
+#include <dali/devel-api/common/stage.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
{
using Dali::Integration::PixelBuffer;
-NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+NativeImageSourceWin* NativeImageSourceWin::New(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
NativeImageSourceWin* image = new NativeImageSourceWin(width, height, depth, nativeImageSource);
DALI_ASSERT_DEBUG(image && "NativeImageSource allocation failed.");
return image;
}
-NativeImageSourceWin::NativeImageSourceWin(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+NativeImageSourceWin::NativeImageSourceWin(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
: mWidth(width),
mHeight(height),
mOwnPixmap(true),
mBlendingRequired(false),
mColorDepth(depth),
mEglImageKHR(NULL),
- mEglImageExtensions(NULL)
+ mEglGraphics(NULL),
+ mEglImageExtensions(NULL),
+ mResourceDestructionCallback()
{
- DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
+ DALI_ASSERT_ALWAYS(Dali::Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
- GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
- auto eglGraphics = static_cast<EglGraphics*>(graphics);
-
- mEglImageExtensions = eglGraphics->GetImageExtensions();
-
- DALI_ASSERT_DEBUG(mEglImageExtensions);
+ auto graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+ mEglGraphics = static_cast<EglGraphics*>(graphics);
// assign the pixmap
mPixmap = GetPixmapFromAny(nativeImageSource);
return Any(mPixmap);
}
-bool NativeImageSourceWin::GetPixels(std::vector<uint8_t>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+bool NativeImageSourceWin::GetPixels(std::vector<uint8_t>& pixbuf, uint32_t& width, uint32_t& height, Pixel::Format& pixelFormat) const
{
- DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
+ DALI_ASSERT_DEBUG(sizeof(uint32_t) == 4);
bool success = false;
width = mWidth;
height = mHeight;
bool NativeImageSourceWin::CreateResource()
{
+ mEglImageExtensions = mEglGraphics->GetImageExtensions();
+ DALI_ASSERT_DEBUG(mEglImageExtensions);
+
// if the image existed previously delete it.
if(mEglImageKHR != NULL)
{
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
+
+ if(mResourceDestructionCallback)
+ {
+ mResourceDestructionCallback->Trigger();
+ }
}
-unsigned int NativeImageSourceWin::TargetTexture()
+uint32_t NativeImageSourceWin::TargetTexture()
{
mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
bool NativeImageSourceWin::SourceChanged() const
{
- return false;
+ return true;
}
-uint8_t* NativeImageSourceWin::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+uint8_t* NativeImageSourceWin::AcquireBuffer(uint32_t& width, uint32_t& height, uint32_t& stride)
{
return NULL;
}
-bool NativeImageSourceWin::ReleaseBuffer()
+bool NativeImageSourceWin::ReleaseBuffer(const Rect<uint32_t>& updatedArea)
{
return false;
}
+void NativeImageSourceWin::SetResourceDestructionCallback(EventThreadCallback* callback)
+{
+ mResourceDestructionCallback = std::unique_ptr<EventThreadCallback>(callback);
+}
+
+void NativeImageSourceWin::EnableBackBuffer(bool enable)
+{
+}
+
} // namespace Adaptor
} // namespace Internal