Bug 681192. Part 0.2: Use FuzzyEqual to check whether we need to invalidate ThebesLayers when subpixel offsets have changed. r=mattwoodrow

--HG--
extra : rebase_source : d0f8464aea9a436214d394123b1399105ccd0f66
This commit is contained in:
Robert O'Callahan 2012-05-10 17:24:18 +12:00
parent ef89c4130b
commit 14f22692ee

View File

@ -934,6 +934,10 @@ GetTranslationForThebesLayer(ThebesLayer* aLayer)
return nsIntPoint(PRInt32(transform.x0), PRInt32(transform.y0));
}
static PRBool FuzzyEqual(gfxPoint aV1, gfxPoint aV2) {
return fabs(aV2.x - aV1.x) < 0.02 && fabs(aV2.y - aV1.y) < 0.02;
}
already_AddRefed<ThebesLayer>
ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
{
@ -1008,7 +1012,7 @@ ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
// If it has changed, then we need to invalidate the entire layer since the
// pixels in the layer buffer have the content at a (subpixel) offset
// from what we need.
if (activeScrolledRootTopLeft != data->mActiveScrolledRootPosition) {
if (!FuzzyEqual(activeScrolledRootTopLeft, data->mActiveScrolledRootPosition)) {
data->mActiveScrolledRootPosition = activeScrolledRootTopLeft;
nsIntRect invalidate = layer->GetValidRegion().GetBounds();
layer->InvalidateRegion(invalidate);