diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 3bfca2110388..359301b9279f 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -77,7 +77,6 @@ #endif #if defined(MOZ_WAYLAND) -# include "nsAutoPtr.h" # include "nsDataHashtable.h" # include diff --git a/gfx/layers/AnimationInfo.cpp b/gfx/layers/AnimationInfo.cpp index a546fbf98921..6b2f739c2c1b 100644 --- a/gfx/layers/AnimationInfo.cpp +++ b/gfx/layers/AnimationInfo.cpp @@ -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(); } mPendingAnimations->Clear(); diff --git a/gfx/layers/AnimationInfo.h b/gfx/layers/AnimationInfo.h index 60e4c7813e85..93fe140c1ed1 100644 --- a/gfx/layers/AnimationInfo.h +++ b/gfx/layers/AnimationInfo.h @@ -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 mPendingAnimations; + UniquePtr mPendingAnimations; uint64_t mCompositorAnimationsId; // The extracted data produced by AnimationHelper::ExtractAnimations(). diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 59f8e52e8fd0..7c86d4d7e4a2 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -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> + UniquePtr> mBackendData; void* mImplData; diff --git a/gfx/layers/ImageLayers.h b/gfx/layers/ImageLayers.h index 22e17a500f4a..90e59fc25b65 100644 --- a/gfx/layers/ImageLayers.h +++ b/gfx/layers/ImageLayers.h @@ -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 { diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 05c714f07a67..928046ec62aa 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -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(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 mPendingTransform; + UniquePtr mPendingTransform; gfx::Matrix4x4 mEffectiveTransform; AnimationInfo mAnimationInfo; Maybe mClipRect; diff --git a/gfx/layers/ReadbackLayer.h b/gfx/layers/ReadbackLayer.h index a26372eee17e..4ef8ef0dd492 100644 --- a/gfx/layers/ReadbackLayer.h +++ b/gfx/layers/ReadbackLayer.h @@ -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 mSink; + UniquePtr mSink; gfx::IntSize mSize; // This can refer to any (earlier) sibling PaintedLayer. That PaintedLayer diff --git a/gfx/layers/d3d11/ReadbackManagerD3D11.cpp b/gfx/layers/d3d11/ReadbackManagerD3D11.cpp index bf641449a5a7..bfe7c12af61a 100644 --- a/gfx/layers/d3d11/ReadbackManagerD3D11.cpp +++ b/gfx/layers/d3d11/ReadbackManagerD3D11.cpp @@ -36,7 +36,8 @@ class ReadbackResultWriterD3D11 final : public nsIRunnable { ~ReadbackResultWriterD3D11() {} NS_DECL_THREADSAFE_ISUPPORTS public: - explicit ReadbackResultWriterD3D11(ReadbackTask* aTask) : mTask(aTask) {} + explicit ReadbackResultWriterD3D11(UniquePtr&& aTask) + : mTask(std::move(aTask)) {} NS_IMETHOD Run() override { D3D10_TEXTURE2D_DESC desc; @@ -68,7 +69,7 @@ class ReadbackResultWriterD3D11 final : public nsIRunnable { } private: - nsAutoPtr mTask; + UniquePtr 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(); 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 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 thread = do_GetMainThread(); - thread->Dispatch(new ReadbackResultWriterD3D11(nextReadbackTask), + thread->Dispatch(new ReadbackResultWriterD3D11(std::move(nextReadbackTask)), nsIEventTarget::DISPATCH_NORMAL); } } diff --git a/gfx/layers/d3d11/ReadbackManagerD3D11.h b/gfx/layers/d3d11/ReadbackManagerD3D11.h index b3889991e6f0..00f5dfd467b6 100644 --- a/gfx/layers/d3d11/ReadbackManagerD3D11.h +++ b/gfx/layers/d3d11/ReadbackManagerD3D11.h @@ -10,8 +10,8 @@ #include #include +#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> mPendingReadbackTasks; + nsTArray> mPendingReadbackTasks; }; } // namespace layers diff --git a/gfx/layers/ipc/CompositorManagerParent.cpp b/gfx/layers/ipc/CompositorManagerParent.cpp index 28cfe719adf9..34e26746864d 100644 --- a/gfx/layers/ipc/CompositorManagerParent.cpp +++ b/gfx/layers/ipc/CompositorManagerParent.cpp @@ -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> actors; + UniquePtr> 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) { diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 2d35a024b3b5..1b15cac35ac6 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -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 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()); diff --git a/gfx/layers/wr/WebRenderUserData.h b/gfx/layers/wr/WebRenderUserData.h index 62b87a8b3f3d..c1c2b9f1224a 100644 --- a/gfx/layers/wr/WebRenderUserData.h +++ b/gfx/layers/wr/WebRenderUserData.h @@ -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> mExternalSurfaces; RefPtr mBasicLayerManager; - nsAutoPtr mGeometry; + UniquePtr mGeometry; nsRect mBounds; nsRect mBuildingRect; gfx::Size mScale;