Bug 1048916. Convert a bunch of layers from nsAutoPtr to UniquePtr. r=roc

This makes the ownership of LayerProperties more clear.

--HG--
extra : rebase_source : 5d786a246337353522fc1d6e2c252e98e673e936
This commit is contained in:
Jeff Muizelaar 2014-08-25 11:09:39 -04:00
Родитель 775a16fc82
Коммит ca08386811
8 изменённых файлов: 31 добавлений и 25 удалений

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

@ -31,7 +31,7 @@ namespace mozilla {
namespace layers {
struct LayerPropertiesBase;
LayerPropertiesBase* CloneLayerTreePropertiesInternal(Layer* aRoot);
UniquePtr<LayerPropertiesBase> CloneLayerTreePropertiesInternal(Layer* aRoot);
static nsIntRect
TransformRect(const nsIntRect& aRect, const Matrix4x4& aTransform)
@ -199,7 +199,7 @@ struct LayerPropertiesBase : public LayerProperties
}
nsRefPtr<Layer> mLayer;
nsAutoPtr<LayerPropertiesBase> mMaskLayer;
UniquePtr<LayerPropertiesBase> mMaskLayer;
nsIntRegion mVisibleRegion;
nsIntRegion mInvalidRegion;
Matrix4x4 mTransform;
@ -218,7 +218,7 @@ struct ContainerLayerProperties : public LayerPropertiesBase
, mPreYScale(aLayer->GetPreYScale())
{
for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) {
mChildren.AppendElement(CloneLayerTreePropertiesInternal(child));
mChildren.AppendElement(Move(CloneLayerTreePropertiesInternal(child)));
}
}
@ -315,7 +315,7 @@ struct ContainerLayerProperties : public LayerPropertiesBase
}
// The old list of children:
nsAutoTArray<nsAutoPtr<LayerPropertiesBase>,1> mChildren;
nsAutoTArray<UniquePtr<LayerPropertiesBase>,1> mChildren;
float mPreXScale;
float mPreYScale;
};
@ -383,29 +383,29 @@ struct ImageLayerProperties : public LayerPropertiesBase
ScaleMode mScaleMode;
};
LayerPropertiesBase*
UniquePtr<LayerPropertiesBase>
CloneLayerTreePropertiesInternal(Layer* aRoot)
{
if (!aRoot) {
return new LayerPropertiesBase();
return MakeUnique<LayerPropertiesBase>();
}
switch (aRoot->GetType()) {
case Layer::TYPE_CONTAINER:
case Layer::TYPE_REF:
return new ContainerLayerProperties(aRoot->AsContainerLayer());
return MakeUnique<ContainerLayerProperties>(aRoot->AsContainerLayer());
case Layer::TYPE_COLOR:
return new ColorLayerProperties(static_cast<ColorLayer*>(aRoot));
return MakeUnique<ColorLayerProperties>(static_cast<ColorLayer*>(aRoot));
case Layer::TYPE_IMAGE:
return new ImageLayerProperties(static_cast<ImageLayer*>(aRoot));
return MakeUnique<ImageLayerProperties>(static_cast<ImageLayer*>(aRoot));
default:
return new LayerPropertiesBase(aRoot);
return MakeUnique<LayerPropertiesBase>(aRoot);
}
return nullptr;
return UniquePtr<LayerPropertiesBase>(nullptr);
}
/* static */ LayerProperties*
/* static */ UniquePtr<LayerProperties>
LayerProperties::CloneFrom(Layer* aRoot)
{
return CloneLayerTreePropertiesInternal(aRoot);

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

@ -7,6 +7,7 @@
#define GFX_LAYER_TREE_INVALIDATION_H
#include "nsRegion.h" // for nsIntRegion
#include "mozilla/UniquePtr.h" // for UniquePtr
class nsPresContext;
struct nsIntPoint;
@ -42,7 +43,7 @@ struct LayerProperties
* @param Layer tree to copy, or nullptr if we have no
* initial layer tree.
*/
static LayerProperties* CloneFrom(Layer* aRoot);
static UniquePtr<LayerProperties> CloneFrom(Layer* aRoot);
/**
* Clear all invalidation status from this layer tree.

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

@ -23,7 +23,7 @@
#include "mozilla/layers/LayersTypes.h" // for etc
#include "mozilla/layers/TextureHost.h" // for TextureHost
#include "mozilla/mozalloc.h" // for operator delete
#include "nsAutoPtr.h" // for nsAutoPtr
#include "mozilla/UniquePtr.h" // for UniquePtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsDebug.h" // for NS_RUNTIMEABORT
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
@ -374,7 +374,7 @@ private:
nsIntPoint mBufferRotation;
};
nsTArray<nsAutoPtr<Request> > mUpdateList;
nsTArray<UniquePtr<Request> > mUpdateList;
// Specific to OGL to avoid exposing methods on TextureSource that only
// have one implementation.

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

@ -340,7 +340,7 @@ LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds)
if (drawFps) {
if (!mFPS) {
mFPS = new FPSState();
mFPS = MakeUnique<FPSState>();
}
float fillRatio = mCompositor->GetFillRatio();

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

@ -19,6 +19,7 @@
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/LayersTypes.h" // for LayersBackend, etc
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
#include "nsAString.h"
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
@ -277,7 +278,7 @@ private:
float aContrastEffect);
RefPtr<Compositor> mCompositor;
nsAutoPtr<LayerProperties> mClonedLayerTreeProperties;
UniquePtr<LayerProperties> mClonedLayerTreeProperties;
/**
* Context target, nullptr when drawing directly to our swap chain.
@ -287,7 +288,7 @@ private:
gfx::Matrix mWorldMatrix;
nsIntRegion mInvalidRegion;
nsAutoPtr<FPSState> mFPS;
UniquePtr<FPSState> mFPS;
bool mInTransaction;
bool mIsCompositorReady;

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

@ -3220,7 +3220,7 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayerData* aLayerData,
layerBuilder->DidBeginRetainedLayerTransaction(tempManager);
}
nsAutoPtr<LayerProperties> props(LayerProperties::CloneFrom(tempManager->GetRoot()));
UniquePtr<LayerProperties> props(LayerProperties::CloneFrom(tempManager->GetRoot()));
nsRefPtr<Layer> tmpLayer =
aItem->BuildLayer(mDisplayListBuilder, tempManager, ContainerLayerParameters());
// We have no easy way of detecting if this transaction will ever actually get finished.

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

@ -52,6 +52,7 @@
#include "mozilla/EventStates.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/Preferences.h"
#include "mozilla/UniquePtr.h"
#include "ActiveLayerTracker.h"
#include "nsContentUtils.h"
#include "nsPrintfCString.h"
@ -1258,9 +1259,10 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
(!layerManager->IsCompositingCheap() && layerManager->NeedsWidgetInvalidation())) &&
widgetTransaction;
nsAutoPtr<LayerProperties> props(computeInvalidRect ?
LayerProperties::CloneFrom(layerManager->GetRoot()) :
nullptr);
UniquePtr<LayerProperties> props;
if (computeInvalidRect) {
props = Move(LayerProperties::CloneFrom(layerManager->GetRoot()));
}
ContainerLayerParameters containerParameters
(presShell->GetXResolution(), presShell->GetYResolution());

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

@ -35,6 +35,7 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/UniquePtr.h"
#include <algorithm>
#ifdef XP_WIN
@ -6161,9 +6162,10 @@ PresShell::Paint(nsView* aViewToPaint,
bool computeInvalidRect = computeInvalidFunc ||
(layerManager->GetBackendType() == LayersBackend::LAYERS_BASIC);
nsAutoPtr<LayerProperties> props(computeInvalidRect ?
LayerProperties::CloneFrom(layerManager->GetRoot()) :
nullptr);
UniquePtr<LayerProperties> props;
if (computeInvalidRect) {
props = Move(LayerProperties::CloneFrom(layerManager->GetRoot()));
}
MaybeSetupTransactionIdAllocator(layerManager, aViewToPaint);