Bug 1610388 - Remove nsAutoPtr usage from gfx/. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D60456

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eric Rahm 2020-01-21 01:25:28 +00:00
Родитель a172471711
Коммит cfd1cc461f
12 изменённых файлов: 51 добавлений и 55 удалений

Просмотреть файл

@ -77,7 +77,6 @@
#endif
#if defined(MOZ_WAYLAND)
# include "nsAutoPtr.h"
# include "nsDataHashtable.h"
# include <gtk/gtk.h>

Просмотреть файл

@ -72,7 +72,7 @@ void AnimationInfo::ClearAnimations() {
void AnimationInfo::ClearAnimationsForNextTransaction() {
// Ensure we have a non-null mPendingAnimations to mark a future clear.
if (!mPendingAnimations) {
mPendingAnimations = new AnimationArray;
mPendingAnimations = MakeUnique<AnimationArray>();
}
mPendingAnimations->Clear();

Просмотреть файл

@ -7,17 +7,17 @@
#ifndef GFX_ANIMATIONINFO_H
#define GFX_ANIMATIONINFO_H
#include "nsAutoPtr.h"
#include "nsCSSPropertyIDSet.h"
#include "nsDisplayItemTypes.h"
#include "mozilla/Array.h"
#include "mozilla/UniquePtr.h"
struct RawServoAnimationValue;
class nsIContent;
class nsIFrame;
namespace mozilla {
namespace gfx{
namespace gfx {
class Path;
} // namespace gfx
@ -110,7 +110,7 @@ class AnimationInfo final {
// readily use for sampling and then store it in mPropertyAnimationGroups
// (below) or CompositorAnimationStorage.mAnimations for WebRender.
AnimationArray mAnimations;
nsAutoPtr<AnimationArray> mPendingAnimations;
UniquePtr<AnimationArray> mPendingAnimations;
uint64_t mCompositorAnimationsId;
// The extracted data produced by AnimationHelper::ExtractAnimations().

Просмотреть файл

@ -20,7 +20,6 @@
#include "mozilla/layers/LayersTypes.h" // for LayersBackend, etc
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsAutoPtr.h" // for nsRefPtr, nsAutoArrayPtr, etc
#include "nsAutoRef.h" // for nsCountedRef
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_ASSERTION
@ -199,10 +198,10 @@ class Image {
}
ImageBackendData* GetBackendData(LayersBackend aBackend) {
return mBackendData[aBackend];
return mBackendData[aBackend].get();
}
void SetBackendData(LayersBackend aBackend, ImageBackendData* aData) {
mBackendData[aBackend] = aData;
mBackendData[aBackend] = mozilla::WrapUnique(aData);
}
int32_t GetSerial() const { return mSerial; }
@ -240,7 +239,7 @@ class Image {
mozilla::EnumeratedArray<mozilla::layers::LayersBackend,
mozilla::layers::LayersBackend::LAYERS_LAST,
nsAutoPtr<ImageBackendData>>
UniquePtr<ImageBackendData>>
mBackendData;
void* mImplData;

Просмотреть файл

@ -11,8 +11,7 @@
#include "mozilla/gfx/BaseSize.h" // for BaseSize
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/layers/LayersTypes.h"
#include "nsAutoPtr.h" // for nsRefPtr
#include "nscore.h" // for nsACString
#include "nscore.h" // for nsACString
namespace mozilla {
namespace layers {

Просмотреть файл

@ -41,7 +41,6 @@
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsAutoPtr.h" // for nsAutoPtr, nsRefPtr, etc
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsCSSPropertyID.h" // for nsCSSPropertyID
#include "nsDebug.h" // for NS_ASSERTION
@ -1201,7 +1200,7 @@ class Layer {
* the next transaction is opened.
*/
void SetBaseTransformForNextTransaction(const gfx::Matrix4x4& aMatrix) {
mPendingTransform = new gfx::Matrix4x4(aMatrix);
mPendingTransform = mozilla::MakeUnique<gfx::Matrix4x4>(aMatrix);
}
void SetPostScale(float aXScale, float aYScale) {
@ -1407,7 +1406,7 @@ class Layer {
}
bool IsScrollbarContainer() const;
Layer* GetMaskLayer() const { return mMaskLayer; }
bool HasPendingTransform() const { return mPendingTransform; }
bool HasPendingTransform() const { return !!mPendingTransform; }
void CheckCanary() const { mCanary.Check(); }
@ -1976,7 +1975,7 @@ class Layer {
// A mutation of |mTransform| that we've queued to be applied at the
// end of the next transaction (if nothing else overrides it in the
// meantime).
nsAutoPtr<gfx::Matrix4x4> mPendingTransform;
UniquePtr<gfx::Matrix4x4> mPendingTransform;
gfx::Matrix4x4 mEffectiveTransform;
AnimationInfo mAnimationInfo;
Maybe<ParentLayerIntRect> mClipRect;

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/gfx/Rect.h" // for gfxRect
#include "mozilla/gfx/Point.h" // for IntPoint
#include "mozilla/mozalloc.h" // for operator delete
#include "nsAutoPtr.h" // for nsAutoPtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_ASSERTION
#include "nsPoint.h" // for nsIntPoint
@ -110,9 +109,9 @@ class ReadbackLayer : public Layer {
*/
void SetSink(ReadbackSink* aSink) {
SetUnknown();
mSink = aSink;
mSink = mozilla::WrapUnique(aSink);
}
ReadbackSink* GetSink() { return mSink; }
ReadbackSink* GetSink() { return mSink.get(); }
/**
* CONSTRUCTION PHASE ONLY
@ -176,7 +175,7 @@ class ReadbackLayer : public Layer {
const void* aParent) override;
uint64_t mSequenceCounter;
nsAutoPtr<ReadbackSink> mSink;
UniquePtr<ReadbackSink> mSink;
gfx::IntSize mSize;
// This can refer to any (earlier) sibling PaintedLayer. That PaintedLayer

Просмотреть файл

@ -36,7 +36,8 @@ class ReadbackResultWriterD3D11 final : public nsIRunnable {
~ReadbackResultWriterD3D11() {}
NS_DECL_THREADSAFE_ISUPPORTS
public:
explicit ReadbackResultWriterD3D11(ReadbackTask* aTask) : mTask(aTask) {}
explicit ReadbackResultWriterD3D11(UniquePtr<ReadbackTask>&& aTask)
: mTask(std::move(aTask)) {}
NS_IMETHOD Run() override {
D3D10_TEXTURE2D_DESC desc;
@ -68,7 +69,7 @@ class ReadbackResultWriterD3D11 final : public nsIRunnable {
}
private:
nsAutoPtr<ReadbackTask> mTask;
UniquePtr<ReadbackTask> mTask;
};
NS_IMPL_ISUPPORTS(ReadbackResultWriterD3D11, nsIRunnable)
@ -104,12 +105,12 @@ ReadbackManagerD3D11::~ReadbackManagerD3D11() {
void ReadbackManagerD3D11::PostTask(ID3D10Texture2D* aTexture,
TextureReadbackSink* aSink) {
ReadbackTask* task = new ReadbackTask;
auto task = MakeUnique<ReadbackTask>();
task->mReadbackTexture = aTexture;
task->mSink = aSink;
::EnterCriticalSection(&mTaskMutex);
mPendingReadbackTasks.AppendElement(task);
mPendingReadbackTasks.AppendElement(std::move(task));
::LeaveCriticalSection(&mTaskMutex);
::ReleaseSemaphore(mTaskSemaphore, 1, nullptr);
@ -128,7 +129,8 @@ void ReadbackManagerD3D11::ProcessTasks() {
if (mPendingReadbackTasks.Length() == 0) {
MOZ_CRASH("Trying to read from an empty array, bad bad bad");
}
ReadbackTask* nextReadbackTask = mPendingReadbackTasks[0].forget();
UniquePtr<ReadbackTask> nextReadbackTask =
std::move(mPendingReadbackTasks[0]);
mPendingReadbackTasks.RemoveElementAt(0);
::LeaveCriticalSection(&mTaskMutex);
@ -142,7 +144,7 @@ void ReadbackManagerD3D11::ProcessTasks() {
// event there to do so. Ownership of the task is passed from
// mPendingReadbackTasks to ReadbackResultWriter here.
nsCOMPtr<nsIThread> thread = do_GetMainThread();
thread->Dispatch(new ReadbackResultWriterD3D11(nextReadbackTask),
thread->Dispatch(new ReadbackResultWriterD3D11(std::move(nextReadbackTask)),
nsIEventTarget::DISPATCH_NORMAL);
}
}

Просмотреть файл

@ -10,8 +10,8 @@
#include <windows.h>
#include <d3d10_1.h>
#include "mozilla/UniquePtr.h"
#include "nsTArray.h"
#include "nsAutoPtr.h"
namespace mozilla {
namespace layers {
@ -56,7 +56,7 @@ class ReadbackManagerD3D11 final {
// FiFo list of readback tasks that are to be executed. Access is synchronized
// by mTaskMutex.
CRITICAL_SECTION mTaskMutex;
nsTArray<nsAutoPtr<ReadbackTask>> mPendingReadbackTasks;
nsTArray<UniquePtr<ReadbackTask>> mPendingReadbackTasks;
};
} // namespace layers

Просмотреть файл

@ -11,8 +11,8 @@
#include "mozilla/layers/ContentCompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/SharedSurfacesParent.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Unused.h"
#include "nsAutoPtr.h"
#include "VsyncSource.h"
namespace mozilla {
@ -179,13 +179,13 @@ void CompositorManagerParent::DeferredDestroy() {
#ifdef COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
/* static */
void CompositorManagerParent::ShutdownInternal() {
nsAutoPtr<nsTArray<CompositorManagerParent*>> actors;
UniquePtr<nsTArray<CompositorManagerParent*>> actors;
// We move here because we may attempt to acquire the same lock during the
// destroy to remove the reference in sActiveActors.
{
StaticMutexAutoLock lock(sMutex);
actors = sActiveActors.forget();
actors = WrapUnique(sActiveActors.forget());
}
if (actors) {

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/gfx/Types.h"
@ -1416,7 +1417,6 @@ static mozilla::gfx::IntRect ScaleToNearestPixelsOffset(
return rect;
}
RenderRootStateManager* WebRenderCommandBuilder::GetRenderRootStateManager(
wr::RenderRoot aRenderRoot) {
return mManager->GetRenderRootStateManager(aRenderRoot);
@ -2171,11 +2171,10 @@ WebRenderCommandBuilder::GenerateFallbackData(
auto snappedTrans = LayerIntPoint::Floor(trans);
LayerPoint residualOffset = trans - snappedTrans;
nsRegion opaqueRegion =
aItem->GetOpaqueRegion(aDisplayListBuilder, &snap);
nsRegion opaqueRegion = aItem->GetOpaqueRegion(aDisplayListBuilder, &snap);
wr::OpacityType opacity = opaqueRegion.Contains(paintBounds)
? wr::OpacityType::Opaque
: wr::OpacityType::HasAlphaChannel;
? wr::OpacityType::Opaque
: wr::OpacityType::HasAlphaChannel;
LayerIntRect dtRect, visibleRect;
// If we think the item is opaque we round the bounds
@ -2187,24 +2186,24 @@ WebRenderCommandBuilder::GenerateFallbackData(
// just hope that we get it right.
if (opacity == wr::OpacityType::Opaque && snap) {
dtRect = LayerIntRect::FromUnknownRect(
ScaleToNearestPixelsOffset(paintBounds, scale.width, scale.height,
appUnitsPerDevPixel, residualOffset));
ScaleToNearestPixelsOffset(paintBounds, scale.width, scale.height,
appUnitsPerDevPixel, residualOffset));
visibleRect = LayerIntRect::FromUnknownRect(
ScaleToNearestPixelsOffset(
aItem->GetBuildingRect(), scale.width,
scale.height, appUnitsPerDevPixel, residualOffset))
.Intersect(dtRect);
ScaleToNearestPixelsOffset(
aItem->GetBuildingRect(), scale.width, scale.height,
appUnitsPerDevPixel, residualOffset))
.Intersect(dtRect);
} else {
dtRect = LayerIntRect::FromUnknownRect(
ScaleToOutsidePixelsOffset(paintBounds, scale.width, scale.height,
appUnitsPerDevPixel, residualOffset));
ScaleToOutsidePixelsOffset(paintBounds, scale.width, scale.height,
appUnitsPerDevPixel, residualOffset));
visibleRect = LayerIntRect::FromUnknownRect(
ScaleToOutsidePixelsOffset(
aItem->GetBuildingRect(), scale.width,
scale.height, appUnitsPerDevPixel, residualOffset))
.Intersect(dtRect);
ScaleToOutsidePixelsOffset(
aItem->GetBuildingRect(), scale.width, scale.height,
appUnitsPerDevPixel, residualOffset))
.Intersect(dtRect);
}
auto visibleSize = visibleRect.Size();
@ -2224,7 +2223,7 @@ WebRenderCommandBuilder::GenerateFallbackData(
// is needs to be adjusted by the display item bounds top left.
visibleRect -= dtRect.TopLeft();
nsDisplayItemGeometry* geometry = fallbackData->mGeometry;
nsDisplayItemGeometry* geometry = fallbackData->mGeometry.get();
bool needPaint = true;
@ -2257,15 +2256,14 @@ WebRenderCommandBuilder::GenerateFallbackData(
}
if (needPaint || !fallbackData->GetImageKey()) {
nsAutoPtr<nsDisplayItemGeometry> newGeometry;
newGeometry = aItem->AllocateGeometry(aDisplayListBuilder);
fallbackData->mGeometry = std::move(newGeometry);
fallbackData->mGeometry =
WrapUnique(aItem->AllocateGeometry(aDisplayListBuilder));
gfx::SurfaceFormat format = aItem->GetType() == DisplayItemType::TYPE_MASK
? gfx::SurfaceFormat::A8
: (opacity == wr::OpacityType::Opaque ?
gfx::SurfaceFormat::B8G8R8X8 :
gfx::SurfaceFormat::B8G8R8A8);
: (opacity == wr::OpacityType::Opaque
? gfx::SurfaceFormat::B8G8R8X8
: gfx::SurfaceFormat::B8G8R8A8);
if (useBlobImage) {
MOZ_ASSERT(!opaqueRegion.IsComplex());

Просмотреть файл

@ -14,6 +14,7 @@
#include "mozilla/layers/AnimationInfo.h"
#include "mozilla/layers/RenderRootBoundary.h"
#include "mozilla/dom/RemoteBrowser.h"
#include "mozilla/UniquePtr.h"
#include "nsIFrame.h"
#include "ImageTypes.h"
@ -203,7 +204,7 @@ class WebRenderFallbackData : public WebRenderUserData {
std::vector<RefPtr<gfx::SourceSurface>> mExternalSurfaces;
RefPtr<BasicLayerManager> mBasicLayerManager;
nsAutoPtr<nsDisplayItemGeometry> mGeometry;
UniquePtr<nsDisplayItemGeometry> mGeometry;
nsRect mBounds;
nsRect mBuildingRect;
gfx::Size mScale;