diff --git a/gfx/config/gfxConfig.cpp b/gfx/config/gfxConfig.cpp index 6281ffbbb976..39ecd30da59f 100644 --- a/gfx/config/gfxConfig.cpp +++ b/gfx/config/gfxConfig.cpp @@ -3,8 +3,9 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + #include "gfxConfig.h" -#include "mozilla/UniquePtr.h" +#include "mozilla/StaticPtr.h" #include "mozilla/Unused.h" #include "mozilla/gfx/GPUParent.h" #include "mozilla/gfx/GraphicsMessages.h" @@ -13,7 +14,7 @@ namespace mozilla { namespace gfx { -static UniquePtr sConfig; +static StaticAutoPtr sConfig; /* static */ FeatureState& gfxConfig::GetFeature(Feature aFeature) { return sConfig->GetState(aFeature); @@ -277,7 +278,7 @@ void gfxConfig::ImportChange(Feature aFeature, } /* static */ -void gfxConfig::Init() { sConfig = mozilla::MakeUnique(); } +void gfxConfig::Init() { sConfig = new gfxConfig(); } /* static */ void gfxConfig::Shutdown() { sConfig = nullptr; } diff --git a/gfx/webrender_bindings/DCLayerTree.cpp b/gfx/webrender_bindings/DCLayerTree.cpp index 87748dd37f5d..fdaf8f6aab10 100644 --- a/gfx/webrender_bindings/DCLayerTree.cpp +++ b/gfx/webrender_bindings/DCLayerTree.cpp @@ -24,6 +24,7 @@ #include "mozilla/gfx/GPUParent.h" #include "mozilla/gfx/Matrix.h" #include "mozilla/StaticPrefs_gfx.h" +#include "mozilla/StaticPtr.h" #include "mozilla/webrender/RenderD3D11TextureHost.h" #include "mozilla/webrender/RenderDcompSurfaceTextureHost.h" #include "mozilla/webrender/RenderTextureHost.h" @@ -53,7 +54,7 @@ extern LazyLogModule gRenderThreadLog; MOZ_LOG(gDcompSurface, LogLevel::Debug, \ ("DCSurfaceHandle=%p, " msg, this, ##__VA_ARGS__)) -UniquePtr DCLayerTree::sGpuOverlayInfo; +StaticAutoPtr DCLayerTree::sGpuOverlayInfo; /* static */ UniquePtr DCLayerTree::Create(gl::GLContext* aGL, @@ -156,7 +157,7 @@ bool DCLayerTree::Initialize(HWND aHwnd, nsACString& aError) { } if (!sGpuOverlayInfo) { // Set default if sGpuOverlayInfo was not set. - sGpuOverlayInfo = MakeUnique(); + sGpuOverlayInfo = new GpuOverlayInfo(); } // Initialize SwapChainInfo @@ -290,7 +291,11 @@ bool DCLayerTree::InitializeVideoOverlaySupport() { info->mSupportsOverlays = info->mSupportsHardwareOverlays; - sGpuOverlayInfo = std::move(info); + // Note: "UniquePtr::release" here is saying "release your ownership stake + // on your pointer, so that our StaticAutoPtr can take over ownership". + // (StaticAutoPtr doesn't have a move constructor that could directly steal + // the contents of a UniquePtr via std::move().) + sGpuOverlayInfo = info.release(); if (auto* gpuParent = gfx::GPUParent::GetSingleton()) { gpuParent->NotifyOverlayInfo(GetOverlayInfo()); diff --git a/gfx/webrender_bindings/DCLayerTree.h b/gfx/webrender_bindings/DCLayerTree.h index d213f3490d52..7895bd61e5ee 100644 --- a/gfx/webrender_bindings/DCLayerTree.h +++ b/gfx/webrender_bindings/DCLayerTree.h @@ -18,6 +18,7 @@ #include "mozilla/layers/OverlayInfo.h" #include "mozilla/Maybe.h" #include "mozilla/RefPtr.h" +#include "mozilla/StaticPtr.h" #include "mozilla/UniquePtr.h" #include "mozilla/webrender/WebRenderTypes.h" @@ -259,7 +260,7 @@ class DCLayerTree { } protected: - static UniquePtr sGpuOverlayInfo; + static StaticAutoPtr sGpuOverlayInfo; }; /**