зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1239864 (part 8) - Use the new rect iterators in gfx/. r=nical.
--HG-- extra : rebase_source : 52187e5da197e961d533ef6eac2dc9dfe3c83827
This commit is contained in:
Родитель
ab52b9a0ea
Коммит
79bfbfd42b
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -377,10 +377,10 @@ struct RegionBitmap {
|
|||
|
||||
void set(nsRegion ®ion) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче