/*
- * Copyright (c) 2019 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.
#include <tbm_surface_internal.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/trigger-event.h>
-#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/integration-api/adaptor-framework/thread-synchronization-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/adaptor-internal-services.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/internal/system/common/trigger-event.h>
#include <dali/internal/window-system/common/display-connection.h>
#include <dali/internal/window-system/common/window-system.h>
-#include <dali/integration-api/thread-synchronization-interface.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/adaptor/common/adaptor-internal-services.h>
namespace Dali
{
} // unnamed namespace
-NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent )
-: mPosition( positionSize ),
+NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+: mSurfaceSize( surfaceSize ),
mRenderNotification( NULL ),
mGraphics( NULL ),
mEGL( nullptr ),
{
Dali::Internal::Adaptor::WindowSystem::Initialize();
- CreateNativeRenderable();
- setenv( "EGL_PLATFORM", "tbm", 1 );
+ if( surface.Empty() )
+ {
+ CreateNativeRenderable();
+ }
+ else
+ {
+ // check we have a valid type
+ DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (tbm_surface_queue_h) ) && "Surface type is invalid" );
+ mTbmQueue = AnyCast< tbm_surface_queue_h >( surface );
+ }
}
NativeRenderSurfaceEcoreWl::~NativeRenderSurfaceEcoreWl()
PositionSize NativeRenderSurfaceEcoreWl::GetPositionSize() const
{
- return mPosition;
+ return PositionSize( 0, 0, static_cast<int>( mSurfaceSize.GetWidth() ), static_cast<int>( mSurfaceSize.GetHeight() ) );
}
void NativeRenderSurfaceEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
void NativeRenderSurfaceEcoreWl::InitializeGraphics()
{
DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
- unsetenv( "EGL_PLATFORM" );
mGraphics = &mAdaptor->GetGraphicsInterface();
auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
DALI_LOG_ERROR( "Failed to resize tbm_surface_queue" );
}
- mPosition = positionSize;
+ mSurfaceSize.SetWidth( static_cast<uint16_t>( positionSize.width ) );
+ mSurfaceSize.SetHeight( static_cast<uint16_t>( positionSize.height ) );
}
void NativeRenderSurfaceEcoreWl::StartRender()
{
}
-bool NativeRenderSurfaceEcoreWl::PreRender( bool )
+bool NativeRenderSurfaceEcoreWl::PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect )
{
- // nothing to do for pixmaps
+ //TODO: Need to support partial update
return true;
}
-Rect<int32_t> NativeRenderSurfaceEcoreWl::SetDamagedRect( const Rect<int32_t>& damagedRect )
-{
- return damagedRect;
-}
-
-int32_t NativeRenderSurfaceEcoreWl::GetBufferAge()
-{
- return 0;
-}
-
-void NativeRenderSurfaceEcoreWl::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
+void NativeRenderSurfaceEcoreWl::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects )
{
auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
- if ( eglGraphics )
+ if (eglGraphics)
{
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-
- eglImpl.SwapBuffers( mEGLSurface );
+ eglImpl.SwapBuffers( mEGLSurface, damagedRects );
}
if( mThreadSynchronization )
mThreadSynchronization = &threadSynchronization;
}
-Integration::RenderSurface::Type NativeRenderSurfaceEcoreWl::GetSurfaceType()
+Dali::RenderSurfaceInterface::Type NativeRenderSurfaceEcoreWl::GetSurfaceType()
{
- return Integration::RenderSurface::NATIVE_RENDER_SURFACE;
+ return Dali::RenderSurfaceInterface::NATIVE_RENDER_SURFACE;
}
void NativeRenderSurfaceEcoreWl::MakeContextCurrent()
void NativeRenderSurfaceEcoreWl::CreateNativeRenderable()
{
+ int width = static_cast<int>( mSurfaceSize.GetWidth() );
+ int height = static_cast<int>( mSurfaceSize.GetHeight() );
+
// check we're creating one with a valid size
- DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "tbm_surface size is invalid" );
+ DALI_ASSERT_ALWAYS( width > 0 && height > 0 && "tbm_surface size is invalid" );
- mTbmQueue = tbm_surface_queue_create( 3, mPosition.width, mPosition.height, mTbmFormat, TBM_BO_DEFAULT );
+ mTbmQueue = tbm_surface_queue_create( 3, width, height, mTbmFormat, TBM_BO_DEFAULT );
if( mTbmQueue )
{