Bug 1239864 (part 10) - Use the new rect iterators in view/ and widget/. r=roc.

This commit is contained in:
Nicholas Nethercote 2016-01-18 17:20:59 -08:00
parent 47b71fd82c
commit a96ca0d9e4
8 changed files with 33 additions and 46 deletions

View File

@ -606,9 +606,8 @@ nsViewManager::InvalidateWidgetArea(nsView *aWidgetView,
leftOver.Sub(aDamagedRegion, children);
if (!leftOver.IsEmpty()) {
const nsRect* r;
for (nsRegionRectIterator iter(leftOver); (r = iter.Next());) {
LayoutDeviceIntRect bounds = ViewToWidget(aWidgetView, *r);
for (auto iter = leftOver.RectIter(); !iter.Done(); iter.Next()) {
LayoutDeviceIntRect bounds = ViewToWidget(aWidgetView, iter.Get());
widget->Invalidate(bounds);
}
}

View File

@ -32,9 +32,8 @@ using namespace mozilla::widget;
static void
InvalidateRegion(nsIWidget* aWidget, const LayoutDeviceIntRegion& aRegion)
{
LayoutDeviceIntRegion::OldRectIterator it(aRegion);
while(const LayoutDeviceIntRect* r = it.Next()) {
aWidget->Invalidate(*r);
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
aWidget->Invalidate(iter.Get());
}
}

View File

@ -28,12 +28,13 @@ VibrancyManager::UpdateVibrantRegion(VibrancyType aType,
vr.effectViews.SwapElements(viewsToRecycle);
// vr.effectViews is now empty.
LayoutDeviceIntRegion::OldRectIterator iter(aRegion);
const LayoutDeviceIntRect* iterRect = nullptr;
for (size_t i = 0; (iterRect = iter.Next()) || i < viewsToRecycle.Length(); ++i) {
if (iterRect) {
size_t i = 0;
for (auto iter = aRegion.RectIter();
!iter.Done() || i < viewsToRecycle.Length();
i++) {
if (!iter.Done()) {
NSView* view = nil;
NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(*iterRect);
NSRect rect = mCoordinateConverter.DevPixelsToCocoaPoints(iter.Get());
if (i < viewsToRecycle.Length()) {
view = viewsToRecycle[i];
[view setFrame:rect];
@ -47,6 +48,7 @@ VibrancyManager::UpdateVibrantRegion(VibrancyType aType,
[view release];
}
vr.effectViews.AppendElement(view);
iter.Next();
} else {
// Our new region is made of less rects than the old region, so we can
// remove this view. We only have a weak reference to it, so removing it
@ -71,9 +73,8 @@ VibrancyManager::ClearVibrantRegion(const VibrantRegion& aVibrantRegion) const
{
[[NSColor clearColor] set];
LayoutDeviceIntRegion::OldRectIterator iter(aVibrantRegion.region);
while (const LayoutDeviceIntRect* rect = iter.Next()) {
NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(*rect));
for (auto iter = aVibrantRegion.region.RectIter(); !iter.Done(); iter.Next()) {
NSRectFill(mCoordinateConverter.DevPixelsToCocoaPoints(iter.Get()));
}
}

View File

@ -3753,13 +3753,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
RefPtr<gfxContext> targetContext = new gfxContext(dt);
// Set up the clip region.
LayoutDeviceIntRegion::OldRectIterator iter(region);
targetContext->NewPath();
for (;;) {
const LayoutDeviceIntRect* r = iter.Next();
if (!r)
break;
targetContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
const LayoutDeviceIntRect& r = iter.Get();
targetContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height));
}
targetContext->Clip();
@ -4632,13 +4629,8 @@ NewCGSRegionFromRegion(const LayoutDeviceIntRegion& aRegion,
CGRect (^aRectConverter)(const LayoutDeviceIntRect&))
{
nsTArray<CGRect> rects;
LayoutDeviceIntRegion::OldRectIterator iter(aRegion);
for (;;) {
const LayoutDeviceIntRect* r = iter.Next();
if (!r) {
break;
}
rects.AppendElement(aRectConverter(*r));
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
rects.AppendElement(aRectConverter(iter.Get()));
}
CGSRegionObj region;

View File

@ -107,19 +107,19 @@ HwcUtils::PrepareVisibleRegion(const nsIntRegion& aVisible,
layerBufferTransform.TransformBounds(ThebesRect(aBufferRect));
gfxMatrix inverse = gfx::ThebesMatrix(aLayerBufferTransform);
inverse.Invert();
nsIntRegionRectIterator rect(aVisible);
aIsVisible = false;
while (const nsIntRect* visibleRect = rect.Next()) {
hwc_rect_t visibleRectScreen;
gfxRect screenRect;
screenRect = layerTransform.TransformBounds(ThebesRect(*visibleRect));
for (auto iter = aVisible.RectIter(); !iter.Done(); iter.Next()) {
gfxRect screenRect =
layerTransform.TransformBounds(ThebesRect(iter.Get()));
screenRect.IntersectRect(screenRect, bufferRect);
screenRect.IntersectRect(screenRect, ThebesRect(aClip));
screenRect.Round();
if (screenRect.IsEmpty()) {
continue;
}
hwc_rect_t visibleRectScreen;
visibleRectScreen.left = screenRect.x;
visibleRectScreen.top = screenRect.y;
visibleRectScreen.right = screenRect.XMost();

View File

@ -757,9 +757,8 @@ void
nsBaseWidget::ArrayFromRegion(const LayoutDeviceIntRegion& aRegion,
nsTArray<LayoutDeviceIntRect>& aRects)
{
const LayoutDeviceIntRect* r;
for (LayoutDeviceIntRegion::OldRectIterator iter(aRegion); (r = iter.Next()); ) {
aRects.AppendElement(*r);
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
aRects.AppendElement(iter.Get());
}
}

View File

@ -142,12 +142,12 @@ nsShmImage::Put(Display* aDisplay, Drawable aWindow,
LayoutDeviceIntRegion bounded;
bounded.And(aRegion,
LayoutDeviceIntRect(0, 0, mImage->width, mImage->height));
LayoutDeviceIntRegion::OldRectIterator iter(bounded);
for (const LayoutDeviceIntRect *r = iter.Next(); r; r = iter.Next()) {
for (auto iter = bounded.RectIter(); !iter.Done(); iter.Next()) {
const LayoutDeviceIntRect& r = iter.Get();
XShmPutImage(aDisplay, aWindow, gc, mImage,
r->x, r->y,
r->x, r->y,
r->width, r->height,
r.x, r.y,
r.x, r.y,
r.width, r.height,
False);
}

View File

@ -377,13 +377,10 @@ private:
}
// Set up the clip region.
LayoutDeviceIntRegion::OldRectIterator iter(region);
targetContext->NewPath();
for (;;) {
const LayoutDeviceIntRect* r = iter.Next();
if (!r)
break;
targetContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
const LayoutDeviceIntRect& r = iter.Get();
targetContext->Rectangle(gfxRect(r.x, r.y, r.width, r.height));
}
targetContext->Clip();