Bug 1239864 (part 8) - Use the new rect iterators in gfx/. r=nical.

--HG--
extra : rebase_source : 52187e5da197e961d533ef6eac2dc9dfe3c83827
This commit is contained in:
Nicholas Nethercote 2016-01-18 17:20:58 -08:00
parent ab52b9a0ea
commit 79bfbfd42b
4 changed files with 21 additions and 27 deletions

View File

@ -740,10 +740,8 @@ public:
nsRegion ToAppUnits (nscoord aAppUnitsPerPixel) const
{
nsRegion result;
OldRectIterator rgnIter(*this);
const Rect* currentRect;
while ((currentRect = rgnIter.Next())) {
nsRect appRect = ::ToAppUnits(*currentRect, aAppUnitsPerPixel);
for (auto iter = RectIter(); !iter.Done(); iter.Next()) {
nsRect appRect = ::ToAppUnits(iter.Get(), aAppUnitsPerPixel);
result.Or(result, appRect);
}
return result;

View File

@ -144,14 +144,12 @@ NS_IMETHODIMP nsScriptableRegion::GetRects(JSContext* aCx, JS::MutableHandle<JS:
aRects.setObject(*destArray);
uint32_t n = 0;
nsIntRegionRectIterator iter(mRegion);
const mozilla::gfx::IntRect *rect;
while ((rect = iter.Next())) {
if (!JS_DefineElement(aCx, destArray, n, rect->x, JSPROP_ENUMERATE) ||
!JS_DefineElement(aCx, destArray, n + 1, rect->y, JSPROP_ENUMERATE) ||
!JS_DefineElement(aCx, destArray, n + 2, rect->width, JSPROP_ENUMERATE) ||
!JS_DefineElement(aCx, destArray, n + 3, rect->height, JSPROP_ENUMERATE)) {
for (auto iter = mRegion.RectIter(); !iter.Done(); iter.Next()) {
const mozilla::gfx::IntRect& rect = iter.Get();
if (!JS_DefineElement(aCx, destArray, n, rect.x, JSPROP_ENUMERATE) ||
!JS_DefineElement(aCx, destArray, n + 1, rect.y, JSPROP_ENUMERATE) ||
!JS_DefineElement(aCx, destArray, n + 2, rect.width, JSPROP_ENUMERATE) ||
!JS_DefineElement(aCx, destArray, n + 3, rect.height, JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
}
n += 4;

View File

@ -377,10 +377,10 @@ struct RegionBitmap {
void set(nsRegion &region) {
clear();
nsRegionRectIterator iter(region);
for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
for (int y = r->y; y < r->YMost(); y++) {
for (int x = r->x; x < r->XMost(); x++) {
for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
const nsRect& r = iter.Get();
for (int y = r.y; y < r.YMost(); y++) {
for (int x = r.x; x < r.XMost(); x++) {
bitmap[x + y * width] = REGION_VALUE;
}
}

View File

@ -714,10 +714,9 @@ gfxUtils::ImageFormatToDepth(gfxImageFormat aFormat)
gfxUtils::ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion)
{
aContext->NewPath();
nsIntRegionRectIterator iter(aRegion);
const IntRect* r;
while ((r = iter.Next()) != nullptr) {
aContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
const IntRect& r = iter.Get();
aContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height));
}
aContext->Clip();
}
@ -732,14 +731,13 @@ gfxUtils::ClipToRegion(DrawTarget* aTarget, const nsIntRegion& aRegion)
}
RefPtr<PathBuilder> pb = aTarget->CreatePathBuilder();
nsIntRegionRectIterator iter(aRegion);
const IntRect* 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()));
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
const IntRect& r = iter.Get();
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();
}
RefPtr<Path> path = pb->Finish();