/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/window-system/windows/platform-implement-win.h>
-#include <dali/devel-api/adaptor-framework/bitmap-saver.h>
-#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
using Dali::Integration::PixelBuffer;
-NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- NativeImageSourceWin* image = new NativeImageSourceWin( width, height, depth, nativeImageSource );
- DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
+ NativeImageSourceWin* image = new NativeImageSourceWin(width, height, depth, nativeImageSource);
+ DALI_ASSERT_DEBUG(image && "NativeImageSource allocation failed.");
// 2nd phase construction
if(image) //< Defensive in case we ever compile without exceptions.
return image;
}
-NativeImageSourceWin::NativeImageSourceWin( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-: mWidth( width ),
- mHeight( height ),
- mOwnPixmap( true ),
- mPixmap( 0 ),
- mBlendingRequired( false ),
- mColorDepth( depth ),
- mEglImageKHR( NULL ),
- mEglImageExtensions( NULL )
+NativeImageSourceWin::NativeImageSourceWin(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+: mWidth(width),
+ mHeight(height),
+ mOwnPixmap(true),
+ mPixmap(0),
+ mBlendingRequired(false),
+ mColorDepth(depth),
+ mEglImageKHR(NULL),
+ mEglImageExtensions(NULL)
{
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
- auto eglGraphics = static_cast<EglGraphics *>(graphics);
+ GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+ auto eglGraphics = static_cast<EglGraphics*>(graphics);
mEglImageExtensions = eglGraphics->GetImageExtensions();
- DALI_ASSERT_DEBUG( mEglImageExtensions );
+ DALI_ASSERT_DEBUG(mEglImageExtensions);
// assign the pixmap
mPixmap = GetPixmapFromAny(nativeImageSource);
void NativeImageSourceWin::Initialize()
{
// if pixmap has been created outside of Windows Image we can return
- if (mPixmap)
+ if(mPixmap)
{
// we don't own the pixmap
mOwnPixmap = false;
If depth = 8, Pixel::A8;
If depth = 16, Pixel::RGB565;
If depth = 32, Pixel::RGBA8888 */
- mBlendingRequired = ( depth == 32 || depth == 8 );
+ mBlendingRequired = (depth == 32 || depth == 8);
}
NativeImageSourceWin::~NativeImageSourceWin()
{
DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
bool success = false;
- width = mWidth;
- height = mHeight;
+ width = mWidth;
+ height = mHeight;
return success;
}
-bool NativeImageSourceWin::EncodeToFile(const std::string& filename) const
+void NativeImageSourceWin::SetSource(Any source)
{
- std::vector< uint8_t > pixbuf;
- uint32_t width(0), height(0);
- Pixel::Format pixelFormat;
+ mPixmap = GetPixmapFromAny(source);
- if(GetPixels(pixbuf, width, height, pixelFormat))
- {
- return Dali::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
- }
- return false;
-}
-
-void NativeImageSourceWin::SetSource( Any source )
-{
- mPixmap = GetPixmapFromAny( source );
-
- if (mPixmap)
+ if(mPixmap)
{
// we don't own the pixmap
mOwnPixmap = false;
}
}
-bool NativeImageSourceWin::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceWin::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth)
{
return true;
}
-bool NativeImageSourceWin::GlExtensionCreate()
+bool NativeImageSourceWin::CreateResource()
{
// if the image existed previously delete it.
- if (mEglImageKHR != NULL)
+ if(mEglImageKHR != NULL)
{
- GlExtensionDestroy();
+ DestroyResource();
}
// casting from an unsigned int to a void *, which should then be cast back
// to an unsigned int in the driver.
- EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer > (mPixmap);
+ EGLClientBuffer eglBuffer = reinterpret_cast<EGLClientBuffer>(mPixmap);
- mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
+ mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer);
return mEglImageKHR != NULL;
}
-void NativeImageSourceWin::GlExtensionDestroy()
+void NativeImageSourceWin::DestroyResource()
{
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
int NativeImageSourceWin::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
{
- switch (depth)
+ switch(depth)
{
case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
{
unsigned int NativeImageSourceWin::GetPixmapFromAny(Any pixmap) const
{
- if (pixmap.Empty())
+ if(pixmap.Empty())
{
return 0;
}
// see if it is of type Windows pixmap
- if (pixmap.GetType() == typeid ( unsigned int ))
+ if(pixmap.GetType() == typeid(unsigned int))
{
// get the Windows pixmap type
unsigned int xpixmap = AnyCast<unsigned int>(pixmap);
{
}
-uint8_t* NativeImageSourceWin::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride )
+const char* NativeImageSourceWin::GetCustomFragmentPrefix() const
{
- return NULL;
+ return nullptr;
+}
+
+const char* NativeImageSourceWin::GetCustomSamplerTypename() const
+{
+ return nullptr;
+}
+
+int NativeImageSourceWin::GetTextureTarget() const
+{
+ return GL_TEXTURE_2D;
+}
+
+Any NativeImageSourceWin::GetNativeImageHandle() const
+{
+ return mPixmap;
}
+bool NativeImageSourceWin::SourceChanged() const
+{
+ return false;
+}
+
+uint8_t* NativeImageSourceWin::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
+{
+ return NULL;
+}
bool NativeImageSourceWin::ReleaseBuffer()
{
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali