X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fintegration-api%2Fadaptor-framework%2Fscene-holder-impl.cpp;h=18f45399475c0137517456342016da07232bf7e1;hb=a37586f11a29deb43055df859153282e26b54d10;hp=1a213a2668ec32d77709eb9676168890d955fefa;hpb=876381bc4dcb9933f72e095eea596c3136028436;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp b/dali/integration-api/adaptor-framework/scene-holder-impl.cpp index 1a213a2..18f4539 100644 --- a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp +++ b/dali/integration-api/adaptor-framework/scene-holder-impl.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -31,6 +32,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include @@ -47,7 +49,7 @@ namespace { #if defined(DEBUG_ENABLED) -Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH"); +Debug::Filter* gSceneHolderLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_SCENE_HOLDER" ); #endif // Copied from x server @@ -120,6 +122,8 @@ SceneHolder::SceneHolder() mId( mSceneHolderCounter++ ), mSurface( nullptr ), mAdaptor( nullptr ), + mDpi(), + mIsBeingDeleted( false ), mAdaptorStarted( false ), mVisible( true ) { @@ -184,26 +188,39 @@ Dali::Integration::Scene SceneHolder::GetScene() return mScene; } +Uint16Pair SceneHolder::GetDpi() const +{ + return mDpi; +} + void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface) { mSurface.reset( surface ); - mScene.SetSurface( *mSurface.get() ); + mScene.SurfaceReplaced(); - unsigned int dpiHorizontal, dpiVertical; - dpiHorizontal = dpiVertical = 0; + SurfaceResized( false ); - mSurface->GetDpi( dpiHorizontal, dpiVertical ); - mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + InitializeDpi(); mSurface->SetAdaptor( *mAdaptor ); + mSurface->SetScene( mScene ); OnSurfaceSet( surface ); } -void SceneHolder::SurfaceResized() +void SceneHolder::SurfaceResized( bool forceUpdate ) { - mScene.SurfaceResized(); + PositionSize surfacePositionSize = mSurface->GetPositionSize(); + int orientation = mSurface->GetOrientation(); + mScene.SurfaceResized( static_cast( surfacePositionSize.width ), static_cast( surfacePositionSize.height ), orientation, forceUpdate ); + + GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface(); + EglGraphics* eglGraphics = static_cast(&graphics); + if (eglGraphics) + { + eglGraphics->SetFullSwapNextFrame(); + } } Dali::RenderSurfaceInterface* SceneHolder::GetSurface() const @@ -216,6 +233,13 @@ void SceneHolder::SetBackgroundColor( const Vector4& color ) if( mScene ) { mScene.SetBackgroundColor( color ); + + GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface(); + EglGraphics* eglGraphics = static_cast(&graphics); + if (eglGraphics) + { + eglGraphics->SetFullSwapNextFrame(); + } } } @@ -232,10 +256,13 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor) return; } + DALI_ASSERT_DEBUG(mSurface && "Surface needs to be set before calling this method\n"); + mAdaptorStarted = true; // Create the scene - mScene = Dali::Integration::Scene::New( *mSurface ); + PositionSize surfacePositionSize = mSurface->GetPositionSize(); + mScene = Dali::Integration::Scene::New( Size(static_cast( surfacePositionSize.width ), static_cast( surfacePositionSize.height )) ); Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation( adaptor ); mAdaptor = &adaptorImpl; @@ -243,16 +270,10 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor) // Create an observer for the adaptor lifecycle mAdaptor->AddObserver( *mLifeCycleObserver ); - if ( mSurface ) - { - unsigned int dpiHorizontal, dpiVertical; - dpiHorizontal = dpiVertical = 0; - - mSurface->GetDpi( dpiHorizontal, dpiVertical ); - mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + InitializeDpi(); - mSurface->SetAdaptor( *mAdaptor ); - } + mSurface->SetAdaptor( *mAdaptor ); + mSurface->SetScene( mScene ); OnAdaptorSet( adaptor ); } @@ -285,7 +306,7 @@ void SceneHolder::FeedTouchPoint( Dali::Integration::Point& point, int timeStamp Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent); if( type != Integration::TouchEventCombiner::DispatchNone ) { - DALI_LOG_INFO( gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y ); + DALI_LOG_INFO( gSceneHolderLogFilter, Debug::Verbose, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y ); // Signals can be emitted while processing core events, and the scene holder could be deleted in the signal callback. // Keep the handle alive until the core events are processed. @@ -337,6 +358,20 @@ void SceneHolder::FeedKeyEvent( Dali::Integration::KeyEvent& keyEvent ) mAdaptor->ProcessCoreEvents(); } +void SceneHolder::AddFrameRenderedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId ) +{ + mScene.AddFrameRenderedCallback( std::move( callback ), frameId ); + + DALI_LOG_INFO( gSceneHolderLogFilter, Debug::General, "SceneHolder::AddFrameRenderedCallback:: Added [%d]\n", frameId ); +} + +void SceneHolder::AddFramePresentedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId ) +{ + mScene.AddFramePresentedCallback( std::move( callback ), frameId ); + + DALI_LOG_INFO( gSceneHolderLogFilter, Debug::General, "SceneHolder::AddFramePresentedCallback:: Added [%d]\n", frameId ); +} + Dali::Integration::SceneHolder SceneHolder::Get( Dali::Actor actor ) { SceneHolder* sceneHolderImpl = nullptr; @@ -367,6 +402,17 @@ void SceneHolder::Reset() mAdaptor->ProcessCoreEvents(); } +void SceneHolder::InitializeDpi() +{ + unsigned int dpiHorizontal, dpiVertical; + dpiHorizontal = dpiVertical = 0; + + mSurface->GetDpi( dpiHorizontal, dpiVertical ); + mScene.SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + + mDpi.SetX( dpiHorizontal ); + mDpi.SetY( dpiVertical ); +} }// Adaptor