X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fadaptor-impl.cpp;h=a77acc2850251bb6da4fd282ef813826c98c5b0e;hb=0c1d27e964b7ef74d70c38f850af69869191afa5;hp=eedcbed0292c7b45b1d88085da4861906c167cee;hpb=34fa8d50606996e999726edf59ea96d6a9240942;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index eedcbed..a77acc2 100644 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -49,23 +50,24 @@ #include #include -#include // Temporary until Core is abstracted +#include #include #include -#include #include #include #include #include #include #include +#include #include #include // For Utils::MakeUnique #include #include #include +#include #include #include @@ -74,6 +76,7 @@ #include #include +#include #include #include @@ -91,6 +94,9 @@ namespace { thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get +DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false); + +const char* ENABLE_IMAGE_LOADER_PLUGIN_ENV = "DALI_ENABLE_IMAGE_LOADER_PLUGIN"; } // unnamed namespace Dali::Adaptor* Adaptor::New(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode) @@ -156,7 +162,7 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory) mEnvironmentOptions->CreateTraceManager(mPerformanceInterface); mEnvironmentOptions->InstallTraceFunction(); // install tracing for main thread - mCallbackManager = CallbackManager::New(); + mCallbackManager = Dali::Internal::Adaptor::GetSystemFactory()->CreateCallbackManager(); Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front(); @@ -175,6 +181,9 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory) mGraphics->GetStencilBufferRequired(), mGraphics->GetPartialUpdateRequired()); + // Create TextureUploadManager after mCore created + mTextureUploadManager = Dali::Devel::TextureUploadManager::Get(); + defaultWindow->SetAdaptor(Get()); Dali::Integration::SceneHolder defaultSceneHolder(defaultWindow); @@ -187,6 +196,14 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory) mObjectProfiler = new ObjectProfiler(mCore->GetObjectRegistry(), timeInterval); } + const uint32_t poolTimeInterval = mEnvironmentOptions->GetMemoryPoolInterval(); + if(0u < poolTimeInterval) + { + mMemoryPoolTimer = Dali::Timer::New(poolTimeInterval * 1000); + mMemoryPoolTimer.TickSignal().Connect(mMemoryPoolTimerSlotDelegate, &Adaptor::MemoryPoolTimeout); + mMemoryPoolTimer.Start(); + } + mNotificationTrigger = TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &Adaptor::ProcessCoreEvents), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER); mDisplayConnection = Dali::DisplayConnection::New(*mGraphics, defaultWindow->GetSurface()->GetSurfaceType()); @@ -308,24 +325,6 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory) mConfigurationManager = Utils::MakeUnique(systemCachePath, mGraphics.get(), mThreadController); } -void Adaptor::AccessibilityObserver::OnAccessibleKeyEvent(const Dali::KeyEvent& event) -{ - Accessibility::KeyEventType type; - if(event.GetState() == Dali::KeyEvent::DOWN) - { - type = Accessibility::KeyEventType::KEY_PRESSED; - } - else if(event.GetState() == Dali::KeyEvent::UP) - { - type = Accessibility::KeyEventType::KEY_RELEASED; - } - else - { - return; - } - Dali::Accessibility::Bridge::GetCurrentBridge()->Emit(type, event.GetKeyCode(), event.GetKeyName(), event.GetTime(), !event.GetKeyString().empty()); -} - Adaptor::~Adaptor() { Accessibility::Bridge::GetCurrentBridge()->Terminate(); @@ -351,7 +350,9 @@ Adaptor::~Adaptor() delete mDisplayConnection; delete mPlatformAbstraction; - delete mCallbackManager; + + mCallbackManager.reset(); + delete mPerformanceInterface; mGraphics->Destroy(); @@ -386,7 +387,6 @@ void Adaptor::Start() auto bridge = Accessibility::Bridge::GetCurrentBridge(); bridge->SetApplicationName(appName); bridge->Initialize(); - Dali::Stage::GetCurrent().KeyEventSignal().Connect(&mAccessibilityObserver, &AccessibilityObserver::OnAccessibleKeyEvent); Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front(); @@ -394,10 +394,7 @@ void Adaptor::Start() dpiHor = dpiVer = 0; defaultWindow->GetSurface()->GetDpi(dpiHor, dpiVer); - - // set the DPI value for font rendering - FontClient fontClient = FontClient::Get(); - fontClient.SetDpi(dpiHor, dpiVer); + Dali::Internal::Adaptor::WindowSystem::SetDpi(dpiHor, dpiVer); // Initialize the thread controller mThreadController->Initialize(); @@ -419,7 +416,12 @@ void Adaptor::Start() ProcessCoreEvents(); // Ensure any startup messages are processed. // Initialize the image loader plugin - Internal::Adaptor::ImageLoaderPluginProxy::Initialize(); + auto enablePluginString = Dali::EnvironmentVariable::GetEnvironmentVariable(ENABLE_IMAGE_LOADER_PLUGIN_ENV); + bool enablePlugin = enablePluginString ? std::atoi(enablePluginString) : false; + if(enablePlugin) + { + Internal::Adaptor::ImageLoaderPluginProxy::Initialize(); + } for(ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter) { @@ -538,7 +540,12 @@ void Adaptor::Stop() } // Destroy the image loader plugin - Internal::Adaptor::ImageLoaderPluginProxy::Destroy(); + auto enablePluginString = Dali::EnvironmentVariable::GetEnvironmentVariable(ENABLE_IMAGE_LOADER_PLUGIN_ENV); + bool enablePlugin = enablePluginString ? std::atoi(enablePluginString) : false; + if(enablePlugin) + { + Internal::Adaptor::ImageLoaderPluginProxy::Destroy(); + } delete mNotificationTrigger; mNotificationTrigger = NULL; @@ -547,6 +554,8 @@ void Adaptor::Stop() mState = STOPPED; + RemoveSystemInformation(); + DALI_LOG_RELEASE_INFO("Adaptor::Stop\n"); } } @@ -635,16 +644,22 @@ Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode) return mTtsPlayers[mode]; } -bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue, bool forceAdd) +bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue) { bool idleAdded(false); - // Only add an idle if the Adaptor is actually running - if(RUNNING == mState || READY == mState || forceAdd) + // We want to run the processes even when paused + if(STOPPED != mState) { idleAdded = mCallbackManager->AddIdleCallback(callback, hasReturnValue); } + if(!idleAdded) + { + // Delete callback + delete callback; + } + return idleAdded; } @@ -823,6 +838,11 @@ void Adaptor::GetWindowContainerInterface(WindowContainer& windows) windows = mWindows; } +Devel::TextureUploadManager& Adaptor::GetTextureUploadManager() +{ + return mTextureUploadManager; +} + void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode) { if(mTtsPlayers[mode]) @@ -903,25 +923,29 @@ void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event) } } +void Adaptor::FlushUpdateMessages() +{ + if(mCore) + { + DALI_TRACE_SCOPE(gTraceFilter, "DALI_FLUSH_UPDATE_MESSAGES"); + + mCore->ForceRelayout(); + } +} + void Adaptor::ProcessCoreEvents() { if(mCore) { + DALI_TRACE_SCOPE(gTraceFilter, "DALI_PROCESS_CORE_EVENTS"); + if(mPerformanceInterface) { mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_START); } -#if !defined(DALI_PROFILE_UBUNTU) && !defined(DALI_PROFILE_LIBUV_X11) && !defined(DALI_PROFILE_GLIB_X11) - DALI_LOG_RELEASE_INFO("Start ProcessEvents\n"); -#endif - mCore->ProcessEvents(); -#if !defined(DALI_PROFILE_UBUNTU) && !defined(DALI_PROFILE_LIBUV_X11) && !defined(DALI_PROFILE_GLIB_X11) - DALI_LOG_RELEASE_INFO("End ProcessEvents\n"); -#endif - if(mPerformanceInterface) { mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_END); @@ -929,7 +953,7 @@ void Adaptor::ProcessCoreEvents() } } -void Adaptor::RequestUpdate(bool forceUpdate) +void Adaptor::RequestUpdate() { switch(mState) { @@ -941,11 +965,8 @@ void Adaptor::RequestUpdate(bool forceUpdate) case PAUSED: case PAUSED_WHILE_HIDDEN: { - if(forceUpdate) - { - // Update (and resource upload) without rendering - mThreadController->RequestUpdateOnce(UpdateMode::SKIP_RENDER); - } + // Update (and resource upload) without rendering + mThreadController->RequestUpdateOnce(UpdateMode::SKIP_RENDER); break; } default: @@ -956,13 +977,22 @@ void Adaptor::RequestUpdate(bool forceUpdate) } } -void Adaptor::RequestProcessEventsOnIdle(bool forceProcess) +void Adaptor::RequestProcessEventsOnIdle() { - // Only request a notification if the Adaptor is actually running - // and we haven't installed the idle notification - if((!mNotificationOnIdleInstalled) && (RUNNING == mState || READY == mState || forceProcess)) + // We want to run the processes even when paused + if(STOPPED != mState) { - mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle), forceProcess); + if(!mNotificationOnIdleInstalled) + { + // If we haven't installed the idle notification, install it idle enterer. + mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle)); + } + else + { + // Request comes during ProcessCoreEventsFromIdle running. + // Mark as we need to call ProcessEvents in next idle events. + mRequiredIdleRepeat = true; + } } } @@ -1042,7 +1072,7 @@ void Adaptor::OnWindowHidden() void Adaptor::OnDamaged(const DamageArea& area) { // This is needed for the case where Dali window is partially obscured - RequestUpdate(false); + RequestUpdate(); } void Adaptor::SurfaceResizePrepare(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize) @@ -1060,6 +1090,15 @@ void Adaptor::SurfaceResizeComplete(Dali::RenderSurfaceInterface* surface, Surfa ProcessCoreEvents(); } +void Adaptor::IncreaseSurfaceResizeCounter() +{ + // Nofify surface resizing before flushing event queue + if(mThreadController) + { + mThreadController->ResizeSurface(); + } +} + void Adaptor::NotifySceneCreated() { GetCore().SceneCreated(); @@ -1112,6 +1151,13 @@ void Adaptor::RenderOnce() ProcessCoreEvents(); } + + // Force rendering + for(auto&& iter : mWindows) + { + iter->GetSurface()->SetFullSwapNextFrame(); + } + mThreadController->RequestUpdateOnce(updateMode); } } @@ -1121,6 +1167,11 @@ const LogFactoryInterface& Adaptor::GetLogFactory() return *mEnvironmentOptions; } +const TraceFactoryInterface& Adaptor::GetTraceFactory() +{ + return *mEnvironmentOptions; +} + void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor) { GetCore().RegisterProcessor(processor, postProcessor); @@ -1136,6 +1187,15 @@ bool Adaptor::IsMultipleWindowSupported() const return mConfigurationManager->IsMultipleWindowSupported(); } +int32_t Adaptor::GetRenderThreadId() const +{ + if(mThreadController) + { + return mThreadController->GetThreadId(); + } + return 0; +} + void Adaptor::RequestUpdateOnce() { if(mThreadController) @@ -1146,12 +1206,20 @@ void Adaptor::RequestUpdateOnce() bool Adaptor::ProcessCoreEventsFromIdle() { + // Reset repeat idler flag. + mRequiredIdleRepeat = false; ProcessCoreEvents(); - // the idle handle automatically un-installs itself - mNotificationOnIdleInstalled = false; + // If someone request ProcessCoreEvents during above ProcessCoreEvents call, we might need to run idle one more times. + // Else, the idle handle automatically un-installs itself + mNotificationOnIdleInstalled = mRequiredIdleRepeat; - return false; + if(mRequiredIdleRepeat) + { + DALI_LOG_DEBUG_INFO("Required ProcessCoreEvents one more times\n"); + } + + return mRequiredIdleRepeat; } Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow(Dali::Actor& actor) @@ -1223,6 +1291,7 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, mPlatformAbstraction(nullptr), mCallbackManager(nullptr), mNotificationOnIdleInstalled(false), + mRequiredIdleRepeat(false), mNotificationTrigger(nullptr), mDaliFeedbackPlugin(), mFeedbackController(nullptr), @@ -1232,7 +1301,9 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, mPerformanceInterface(nullptr), mKernelTracer(), mSystemTracer(), + mTextureUploadManager(), mObjectProfiler(nullptr), + mMemoryPoolTimerSlotDelegate(this), mSocketFactory(), mMutex(), mThreadMode(threadMode), @@ -1256,12 +1327,12 @@ void Adaptor::SetRootLayoutDirection(std::string locale) } } -bool Adaptor::AddIdleEnterer(CallbackBase* callback, bool forceAdd) +bool Adaptor::AddIdleEnterer(CallbackBase* callback) { bool idleAdded(false); - // Only add an idle if the Adaptor is actually running - if(RUNNING == mState || READY == mState || forceAdd) + // We want to run the processes even when paused + if(STOPPED != mState) { idleAdded = mCallbackManager->AddIdleEntererCallback(callback); } @@ -1280,6 +1351,12 @@ void Adaptor::RemoveIdleEnterer(CallbackBase* callback) mCallbackManager->RemoveIdleEntererCallback(callback); } +bool Adaptor::MemoryPoolTimeout() +{ + mCore->LogMemoryPools(); + return true; // Keep logging forever +} + } // namespace Adaptor } // namespace Internal