Bug 1875430 part 3: Convert 'static UniquePtr' global vars to use StaticAutoPtr, in gfx. r=gfx-reviewers,jgilbert

Differential Revision: https://phabricator.services.mozilla.com/D199169
This commit is contained in:
Daniel Holbert 2024-01-23 19:00:49 +00:00
parent 570fa09edf
commit 6b6989bd75
3 changed files with 14 additions and 7 deletions

View file

@ -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<gfxConfig> sConfig;
static StaticAutoPtr<gfxConfig> 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<gfxConfig>(); }
void gfxConfig::Init() { sConfig = new gfxConfig(); }
/* static */
void gfxConfig::Shutdown() { sConfig = nullptr; }

View file

@ -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<GpuOverlayInfo> DCLayerTree::sGpuOverlayInfo;
StaticAutoPtr<GpuOverlayInfo> DCLayerTree::sGpuOverlayInfo;
/* static */
UniquePtr<DCLayerTree> 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<GpuOverlayInfo>();
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());

View file

@ -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<GpuOverlayInfo> sGpuOverlayInfo;
static StaticAutoPtr<GpuOverlayInfo> sGpuOverlayInfo;
};
/**