Bug 657780. Silence pldhash warnings by shrinking ThebesLayerItemsEntry. r=tnikkel

This commit is contained in:
Robert O'Callahan 2011-05-18 17:48:43 +12:00
Родитель e1f56dcf9c
Коммит 0852457d4b
2 изменённых файлов: 46 добавлений и 49 удалений

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

@ -715,28 +715,19 @@ FrameLayerBuilder::GetOldLayerFor(nsIFrame* aFrame, PRUint32 aDisplayItemKey)
/**
* Invalidate aRegion in aLayer. aLayer is in the coordinate system
* *after* aTransform has been applied, so we need to
* *after* aTranslation has been applied, so we need to
* apply the inverse of that transform before calling InvalidateRegion.
* Currently we assume that the transform is just an integer translation,
* since that's all we need for scrolling.
*/
static void
InvalidatePostTransformRegion(ThebesLayer* aLayer, const nsIntRegion& aRegion,
const gfx3DMatrix& aTransform)
const nsIntPoint& aTranslation)
{
gfxMatrix transform;
if (aTransform.Is2D(&transform)) {
NS_ASSERTION(!transform.HasNonIntegerTranslation(),
"Matrix not just an integer translation?");
// Convert the region from the coordinates of the container layer
// (relative to the snapped top-left of the display list reference frame)
// to the ThebesLayer's own coordinates
nsIntRegion rgn = aRegion;
rgn.MoveBy(-nsIntPoint(PRInt32(transform.x0), PRInt32(transform.y0)));
aLayer->InvalidateRegion(rgn);
} else {
NS_ERROR("Only 2D transformations currently supported");
}
// Convert the region from the coordinates of the container layer
// (relative to the snapped top-left of the display list reference frame)
// to the ThebesLayer's own coordinates
nsIntRegion rgn = aRegion;
rgn.MoveBy(-aTranslation);
aLayer->InvalidateRegion(rgn);
}
already_AddRefed<ColorLayer>
@ -783,6 +774,18 @@ ContainerState::CreateOrRecycleImageLayer()
return layer.forget();
}
static nsIntPoint
GetTranslationForThebesLayer(ThebesLayer* aLayer)
{
gfxMatrix transform;
if (!aLayer->GetTransform().Is2D(&transform) &&
transform.HasNonIntegerTranslation()) {
NS_ERROR("ThebesLayers should have integer translations only");
return nsIntPoint(0, 0);
}
return nsIntPoint(PRInt32(transform.x0), PRInt32(transform.y0));
}
already_AddRefed<ThebesLayer>
ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
{
@ -809,7 +812,7 @@ ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
layer->InvalidateRegion(invalidate);
} else {
InvalidatePostTransformRegion(layer, mInvalidThebesContent,
layer->GetTransform());
GetTranslationForThebesLayer(layer));
}
// We do not need to Invalidate these areas in the widget because we
// assume the caller of InvalidateThebesLayerContents has ensured
@ -824,7 +827,7 @@ ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
new ThebesDisplayItemLayerUserData());
}
mBuilder->LayerBuilder()->SaveLastPaintTransform(layer, layer->GetTransform());
mBuilder->LayerBuilder()->SaveLastPaintOffset(layer);
// Set up transform so that 0,0 in the Thebes layer corresponds to the
// (pixel-snapped) top-left of the aActiveScrolledRoot.
@ -1424,12 +1427,13 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, Layer* aNewLayer)
ThebesLayer* t = oldLayer->AsThebesLayer();
if (t) {
InvalidatePostTransformRegion(t, r,
mBuilder->LayerBuilder()->GetLastPaintTransform(t));
mBuilder->LayerBuilder()->GetLastPaintOffset(t));
}
if (aNewLayer) {
ThebesLayer* newLayer = aNewLayer->AsThebesLayer();
if (newLayer) {
InvalidatePostTransformRegion(newLayer, r, newLayer->GetTransform());
InvalidatePostTransformRegion(newLayer, r,
GetTranslationForThebesLayer(newLayer));
}
}
@ -1484,23 +1488,22 @@ FrameLayerBuilder::AddLayerDisplayItem(Layer* aLayer,
}
}
const gfx3DMatrix&
FrameLayerBuilder::GetLastPaintTransform(ThebesLayer* aLayer)
nsIntPoint
FrameLayerBuilder::GetLastPaintOffset(ThebesLayer* aLayer)
{
ThebesLayerItemsEntry* entry = mThebesLayerItems.PutEntry(aLayer);
if (entry && entry->mHasExplicitLastPaintTransform)
return entry->mLastPaintTransform;
return aLayer->GetTransform();
if (entry && entry->mHasExplicitLastPaintOffset)
return entry->mLastPaintOffset;
return GetTranslationForThebesLayer(aLayer);
}
void
FrameLayerBuilder::SaveLastPaintTransform(ThebesLayer* aLayer,
const gfx3DMatrix& aMatrix)
FrameLayerBuilder::SaveLastPaintOffset(ThebesLayer* aLayer)
{
ThebesLayerItemsEntry* entry = mThebesLayerItems.PutEntry(aLayer);
if (entry) {
entry->mLastPaintTransform = aMatrix;
entry->mHasExplicitLastPaintTransform = PR_TRUE;
entry->mLastPaintOffset = GetTranslationForThebesLayer(aLayer);
entry->mHasExplicitLastPaintOffset = PR_TRUE;
}
}
@ -1846,18 +1849,11 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
aContext->Fill();
}
gfxMatrix transform;
if (!aLayer->GetTransform().Is2D(&transform)) {
NS_ERROR("non-2D transform in our Thebes layer!");
return;
}
NS_ASSERTION(!transform.HasNonIntegerTranslation(),
"Matrix not just an integer translation?");
// make the origin of the context coincide with the origin of the
// ThebesLayer
gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
aContext->Translate(-gfxPoint(transform.x0, transform.y0));
nsIntPoint offset(PRInt32(transform.x0), PRInt32(transform.y0));
gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
nsIntPoint offset = GetTranslationForThebesLayer(aLayer);
aContext->Translate(-gfxPoint(offset.x, offset.y));
nsPresContext* presContext = containerLayerFrame->PresContext();
PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();

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

@ -297,15 +297,16 @@ public:
static PRBool HasRetainedLayerFor(nsIFrame* aFrame, PRUint32 aDisplayItemKey);
/**
* Save aMatrix as the transform that was in aLayer when we last painted.
* Save transform that was in aLayer when we last painted. It must be an integer
* translation.
*/
void SaveLastPaintTransform(ThebesLayer* aLayer, const gfx3DMatrix& aMatrix);
void SaveLastPaintOffset(ThebesLayer* aLayer);
/**
* Get the transform that was in aLayer when we last painted. It's either
* Get the translation transform that was in aLayer when we last painted. It's either
* the transform saved by SaveLastPaintTransform, or else the transform
* that's currently in the layer.
* that's currently in the layer (which must be an integer translation).
*/
const gfx3DMatrix& GetLastPaintTransform(ThebesLayer* aLayer);
nsIntPoint GetLastPaintOffset(ThebesLayer* aLayer);
/**
* Clip represents the intersection of an optional rectangle with a
@ -451,7 +452,7 @@ protected:
public:
ThebesLayerItemsEntry(const ThebesLayer *key) :
nsPtrHashKey<ThebesLayer>(key), mContainerLayerFrame(nsnull),
mHasExplicitLastPaintTransform(PR_FALSE) {}
mHasExplicitLastPaintOffset(PR_FALSE) {}
ThebesLayerItemsEntry(const ThebesLayerItemsEntry &toCopy) :
nsPtrHashKey<ThebesLayer>(toCopy.mKey), mItems(toCopy.mItems)
{
@ -460,10 +461,10 @@ protected:
nsTArray<ClippedDisplayItem> mItems;
nsIFrame* mContainerLayerFrame;
// The transform set on this ThebesLayer before we started updating the
// The translation set on this ThebesLayer before we started updating the
// layer tree.
gfx3DMatrix mLastPaintTransform;
PRPackedBool mHasExplicitLastPaintTransform;
nsIntPoint mLastPaintOffset;
PRPackedBool mHasExplicitLastPaintOffset;
enum { ALLOW_MEMMOVE = PR_TRUE };
};