diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /gfx/webrender_bindings/RenderThread.cpp | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/webrender_bindings/RenderThread.cpp')
-rw-r--r-- | gfx/webrender_bindings/RenderThread.cpp | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/gfx/webrender_bindings/RenderThread.cpp b/gfx/webrender_bindings/RenderThread.cpp index 89fc339c03..e1a41ee225 100644 --- a/gfx/webrender_bindings/RenderThread.cpp +++ b/gfx/webrender_bindings/RenderThread.cpp @@ -70,12 +70,15 @@ static mozilla::BackgroundHangMonitor* sBackgroundHangMonitor; #ifdef DEBUG static bool sRenderThreadEverStarted = false; #endif +size_t RenderThread::sRendererCount = 0; +size_t RenderThread::sActiveRendererCount = 0; RenderThread::RenderThread(RefPtr<nsIThread> aThread) : mThread(std::move(aThread)), mThreadPool(false), mThreadPoolLP(true), mSingletonGLIsForHardwareWebRender(true), + mBatteryInfo("RenderThread.mBatteryInfo"), mWindowInfos("RenderThread.mWindowInfos"), mRenderTextureMapLock("RenderThread.mRenderTextureMapLock"), mHasShutdown(false), @@ -149,6 +152,11 @@ void RenderThread::Start(uint32_t aNamespace) { } sRenderThread = new RenderThread(thread); + CrashReporter::RegisterAnnotationUSize( + CrashReporter::Annotation::GraphicsNumRenderers, &sRendererCount); + CrashReporter::RegisterAnnotationUSize( + CrashReporter::Annotation::GraphicsNumActiveRenderers, + &sActiveRendererCount); #ifdef XP_WIN widget::WinCompositorWindowThread::Start(); #endif @@ -291,6 +299,26 @@ RefPtr<MemoryReportPromise> RenderThread::AccumulateMemoryReport( return p; } +void RenderThread::SetBatteryInfo(const hal::BatteryInformation& aBatteryInfo) { + MOZ_ASSERT(XRE_IsGPUProcess()); + + auto batteryInfo = mBatteryInfo.Lock(); + batteryInfo.ref() = Some(aBatteryInfo); +} + +bool RenderThread::GetPowerIsCharging() { + MOZ_ASSERT(XRE_IsGPUProcess()); + + auto batteryInfo = mBatteryInfo.Lock(); + if (batteryInfo.ref().isSome()) { + return batteryInfo.ref().ref().charging(); + } + + gfxCriticalNoteOnce << "BatteryInfo is not set"; + MOZ_ASSERT_UNREACHABLE("unexpected to be called"); + return false; +} + void RenderThread::AddRenderer(wr::WindowId aWindowId, UniquePtr<RendererOGL> aRenderer) { MOZ_ASSERT(IsInRenderThread()); @@ -301,9 +329,7 @@ void RenderThread::AddRenderer(wr::WindowId aWindowId, } mRenderers[aWindowId] = std::move(aRenderer); - CrashReporter::AnnotateCrashReport( - CrashReporter::Annotation::GraphicsNumRenderers, - (unsigned int)mRenderers.size()); + sRendererCount = mRenderers.size(); auto windows = mWindowInfos.Lock(); windows->emplace(AsUint64(aWindowId), new WindowInfo()); @@ -321,9 +347,7 @@ void RenderThread::RemoveRenderer(wr::WindowId aWindowId) { } mRenderers.erase(aWindowId); - CrashReporter::AnnotateCrashReport( - CrashReporter::Annotation::GraphicsNumRenderers, - (unsigned int)mRenderers.size()); + sRendererCount = mRenderers.size(); if (mRenderers.empty()) { if (mHandlingDeviceReset) { @@ -370,7 +394,7 @@ size_t RenderThread::RendererCount() const { return mRenderers.size(); } -size_t RenderThread::ActiveRendererCount() const { +void RenderThread::UpdateActiveRendererCount() { MOZ_ASSERT(IsInRenderThread()); size_t num_active = 0; for (const auto& it : mRenderers) { @@ -378,7 +402,7 @@ size_t RenderThread::ActiveRendererCount() const { num_active++; } } - return num_active; + sActiveRendererCount = num_active; } void RenderThread::WrNotifierEvent_WakeUp(WrWindowId aWindowId, @@ -842,9 +866,7 @@ void RenderThread::Pause(wr::WindowId aWindowId) { auto& renderer = it->second; renderer->Pause(); - CrashReporter::AnnotateCrashReport( - CrashReporter::Annotation::GraphicsNumActiveRenderers, - (unsigned int)ActiveRendererCount()); + UpdateActiveRendererCount(); } bool RenderThread::Resume(wr::WindowId aWindowId) { @@ -861,9 +883,7 @@ bool RenderThread::Resume(wr::WindowId aWindowId) { auto& renderer = it->second; bool resumed = renderer->Resume(); - CrashReporter::AnnotateCrashReport( - CrashReporter::Annotation::GraphicsNumActiveRenderers, - (unsigned int)ActiveRendererCount()); + UpdateActiveRendererCount(); return resumed; } @@ -1378,7 +1398,7 @@ RenderThread::GetProgramsForCompositorOGL() { } RefPtr<layers::SurfacePool> RenderThread::SharedSurfacePool() { -#if defined(XP_MACOSX) || defined(MOZ_WAYLAND) +#if defined(XP_DARWIN) || defined(MOZ_WAYLAND) if (!mSurfacePool) { size_t poolSizeLimit = StaticPrefs::gfx_webrender_compositor_surface_pool_size_AtStartup(); @@ -1555,7 +1575,7 @@ static already_AddRefed<gl::GLContext> CreateGLContextEGL() { } #endif -#ifdef XP_MACOSX +#ifdef XP_DARWIN static already_AddRefed<gl::GLContext> CreateGLContextCGL() { nsCString failureUnused; return gl::GLContextProvider::CreateHeadless( @@ -1578,7 +1598,7 @@ static already_AddRefed<gl::GLContext> CreateGLContext(nsACString& aError) { if (gfx::gfxVars::UseEGL()) { gl = CreateGLContextEGL(); } -#elif XP_MACOSX +#elif XP_DARWIN gl = CreateGLContextCGL(); #endif |