mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Backed out changeset 318fa507832d (bug 1073086)
This commit is contained in:
parent
5e0dbe7d22
commit
fad1e475af
@ -229,7 +229,7 @@ RotatedContentBuffer::DrawTo(PaintedLayer* aLayer,
|
||||
// Bug 599189 if there is a non-integer-translation transform in aTarget,
|
||||
// we might sample pixels outside GetEffectiveVisibleRegion(), which is wrong
|
||||
// and may cause gray lines.
|
||||
gfxUtils::ClipToRegion(aTarget, aLayer->GetEffectiveVisibleRegion());
|
||||
gfxUtils::ClipToRegionSnapped(aTarget, aLayer->GetEffectiveVisibleRegion());
|
||||
clipped = true;
|
||||
}
|
||||
|
||||
|
@ -664,27 +664,50 @@ ClipToRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion,
|
||||
}
|
||||
|
||||
static TemporaryRef<Path>
|
||||
PathFromRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion)
|
||||
PathFromRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion,
|
||||
bool aSnap)
|
||||
{
|
||||
Matrix mat = aTarget->GetTransform();
|
||||
const gfxFloat epsilon = 0.000001;
|
||||
#define WITHIN_E(a,b) (fabs((a)-(b)) < epsilon)
|
||||
// We're essentially duplicating the logic in UserToDevicePixelSnapped here.
|
||||
bool shouldNotSnap = !aSnap || (WITHIN_E(mat._11,1.0) &&
|
||||
WITHIN_E(mat._22,1.0) &&
|
||||
WITHIN_E(mat._12,0.0) &&
|
||||
WITHIN_E(mat._21,0.0));
|
||||
#undef WITHIN_E
|
||||
|
||||
RefPtr<PathBuilder> pb = aTarget->CreatePathBuilder();
|
||||
nsIntRegionRectIterator iter(aRegion);
|
||||
|
||||
const nsIntRect* r;
|
||||
while ((r = iter.Next()) != nullptr) {
|
||||
pb->MoveTo(Point(r->x, r->y));
|
||||
pb->LineTo(Point(r->XMost(), r->y));
|
||||
pb->LineTo(Point(r->XMost(), r->YMost()));
|
||||
pb->LineTo(Point(r->x, r->YMost()));
|
||||
pb->Close();
|
||||
if (shouldNotSnap) {
|
||||
while ((r = iter.Next()) != nullptr) {
|
||||
pb->MoveTo(Point(r->x, r->y));
|
||||
pb->LineTo(Point(r->XMost(), r->y));
|
||||
pb->LineTo(Point(r->XMost(), r->YMost()));
|
||||
pb->LineTo(Point(r->x, r->YMost()));
|
||||
pb->Close();
|
||||
}
|
||||
} else {
|
||||
while ((r = iter.Next()) != nullptr) {
|
||||
Rect rect(r->x, r->y, r->width, r->height);
|
||||
|
||||
rect.Round();
|
||||
pb->MoveTo(rect.TopLeft());
|
||||
pb->LineTo(rect.TopRight());
|
||||
pb->LineTo(rect.BottomRight());
|
||||
pb->LineTo(rect.BottomLeft());
|
||||
pb->Close();
|
||||
}
|
||||
}
|
||||
RefPtr<Path> path = pb->Finish();
|
||||
return path;
|
||||
}
|
||||
|
||||
static void
|
||||
ClipToRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion)
|
||||
ClipToRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion,
|
||||
bool aSnap)
|
||||
{
|
||||
if (!aRegion.IsComplex()) {
|
||||
nsIntRect rect = aRegion.GetBounds();
|
||||
@ -692,7 +715,7 @@ ClipToRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion)
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<Path> path = PathFromRegionInternal(aTarget, aRegion);
|
||||
RefPtr<Path> path = PathFromRegionInternal(aTarget, aRegion, aSnap);
|
||||
aTarget->PushClip(path);
|
||||
}
|
||||
|
||||
@ -705,7 +728,7 @@ gfxUtils::ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion)
|
||||
/*static*/ void
|
||||
gfxUtils::ClipToRegion(DrawTarget* aTarget, const nsIntRegion& aRegion)
|
||||
{
|
||||
ClipToRegionInternal(aTarget, aRegion);
|
||||
ClipToRegionInternal(aTarget, aRegion, false);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
@ -714,6 +737,12 @@ gfxUtils::ClipToRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion)
|
||||
ClipToRegionInternal(aContext, aRegion, true);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
gfxUtils::ClipToRegionSnapped(DrawTarget* aTarget, const nsIntRegion& aRegion)
|
||||
{
|
||||
ClipToRegionInternal(aTarget, aRegion, true);
|
||||
}
|
||||
|
||||
/*static*/ gfxFloat
|
||||
gfxUtils::ClampToScaleFactor(gfxFloat aVal)
|
||||
{
|
||||
|
@ -99,6 +99,11 @@ public:
|
||||
*/
|
||||
static void ClipToRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion);
|
||||
|
||||
/**
|
||||
* Clip aTarget to the region aRegion, snapping the rectangles.
|
||||
*/
|
||||
static void ClipToRegionSnapped(mozilla::gfx::DrawTarget* aTarget, const nsIntRegion& aRegion);
|
||||
|
||||
/**
|
||||
* Create a path consisting of rectangles in |aRegion|.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user