/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
// INTERNAL INCLUDES
#include <dali/internal/graphics/common/egl-image-extensions.h>
-#include <dali/internal/graphics/gles20/egl-factory.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/integration-api/render-surface.h>
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
// Allow this to be encoded and saved:
#include <dali/devel-api/adaptor-framework/bitmap-saver.h>
using Dali::Integration::PixelBuffer;
-NativeImageSourceTizen* NativeImageSourceTizen::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceTizen* NativeImageSourceTizen::New( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
{
NativeImageSourceTizen* image = new NativeImageSourceTizen( width, height, depth, nativeImageSource );
DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
return image;
}
-NativeImageSourceTizen::NativeImageSourceTizen( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceTizen::NativeImageSourceTizen( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
: mWidth( width ),
mHeight( height ),
mOwnTbmSurface( false ),
mBlendingRequired( false ),
mColorDepth( depth ),
mEglImageKHR( NULL ),
+ mEglGraphics( NULL ),
mEglImageExtensions( NULL ),
- mSetSource( false )
+ mSetSource( false ),
+ mMutex()
{
DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
- EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
- mEglImageExtensions = eglFactory.GetImageExtensions();
- DALI_ASSERT_DEBUG( mEglImageExtensions );
+
+ GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
+ mEglGraphics = static_cast<EglGraphics *>(graphics);
mTbmSurface = GetSurfaceFromAny( nativeImageSource );
bool NativeImageSourceTizen::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
{
+ Dali::Mutex::ScopedLock lock( mMutex );
if( mTbmSurface != NULL )
{
tbm_surface_info_s surface_info;
void NativeImageSourceTizen::SetSource( Any source )
{
+ Dali::Mutex::ScopedLock lock( mMutex );
if( mOwnTbmSurface )
{
if( mTbmSurface != NULL && tbm_surface_destroy( mTbmSurface ) != TBM_SURFACE_ERROR_NONE )
// 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 >(mTbmSurface);
- if( !eglBuffer )
+ if( !eglBuffer || !tbm_surface_internal_is_valid( mTbmSurface ) )
{
return false;
}
+ mEglImageExtensions = mEglGraphics->GetImageExtensions();
+ DALI_ASSERT_DEBUG( mEglImageExtensions );
+
mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
return mEglImageKHR != NULL;
void NativeImageSourceTizen::GlExtensionDestroy()
{
+ Dali::Mutex::ScopedLock lock( mMutex );
if( mEglImageKHR )
{
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
}
}
-unsigned int NativeImageSourceTizen::TargetTexture()
+uint32_t NativeImageSourceTizen::TargetTexture()
{
mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
void NativeImageSourceTizen::PrepareTexture()
{
+ Dali::Mutex::ScopedLock lock( mMutex );
if( mSetSource )
{
void* eglImage = mEglImageKHR;