From 110c0b0c3539058c548a0c93fb7afaba2461dcc8 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Jan 2016 17:20:58 -0800 Subject: [PATCH] Bug 1239864 (part 4) - Use the new rect iterators in gfx/. r=nical. --- gfx/gl/GLUploadHelpers.cpp | 21 ++++++++++----------- gfx/ipc/GfxMessageUtils.h | 12 ++++++------ gfx/layers/Compositor.cpp | 7 ++----- gfx/layers/LayerTreeInvalidation.cpp | 6 ++---- gfx/layers/Layers.cpp | 5 ++--- 5 files changed, 22 insertions(+), 29 deletions(-) diff --git a/gfx/gl/GLUploadHelpers.cpp b/gfx/gl/GLUploadHelpers.cpp index 0a650419844..b92c47a61d9 100644 --- a/gfx/gl/GLUploadHelpers.cpp +++ b/gfx/gl/GLUploadHelpers.cpp @@ -501,30 +501,29 @@ UploadImageDataToTexture(GLContext* gl, NS_ASSERTION(false, "Unhandled image surface format!"); } - nsIntRegionRectIterator iter(paintRegion); - const IntRect *iterRect; // Top left point of the region's bounding rectangle. IntPoint topLeft = paintRegion.GetBounds().TopLeft(); - while ((iterRect = iter.Next())) { + for (auto iter = paintRegion.RectIter(); !iter.Done(); iter.Next()) { + const IntRect& rect = iter.Get(); // The inital data pointer is at the top left point of the region's // bounding rectangle. We need to find the offset of this rect // within the region and adjust the data pointer accordingly. unsigned char *rectData = - aData + DataOffset(iterRect->TopLeft() - topLeft, aStride, aFormat); + aData + DataOffset(rect.TopLeft() - topLeft, aStride, aFormat); - NS_ASSERTION(textureInited || (iterRect->x == 0 && iterRect->y == 0), + NS_ASSERTION(textureInited || (rect.x == 0 && rect.y == 0), "Must be uploading to the origin when we don't have an existing texture"); if (textureInited && CanUploadSubTextures(gl)) { TexSubImage2DHelper(gl, aTextureTarget, 0, - iterRect->x, - iterRect->y, - iterRect->width, - iterRect->height, + rect.x, + rect.y, + rect.width, + rect.height, aStride, pixelSize, format, @@ -535,8 +534,8 @@ UploadImageDataToTexture(GLContext* gl, aTextureTarget, 0, internalFormat, - iterRect->width, - iterRect->height, + rect.width, + rect.height, aStride, pixelSize, 0, diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index e4bc6162fc4..f19948145f2 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -367,10 +367,10 @@ struct RegionParamTraits static void Write(Message* msg, const paramType& param) { - Iter it(param); - while (const Rect* r = it.Next()) { - MOZ_RELEASE_ASSERT(!r->IsEmpty()); - WriteParam(msg, *r); + for (auto iter = param.RectIter(); !iter.Done(); iter.Next()) { + const Rect& r = iter.Get(); + MOZ_RELEASE_ASSERT(!r.IsEmpty()); + WriteParam(msg, r); } // empty rects are sentinel values because nsRegions will never // contain them @@ -393,7 +393,7 @@ template struct ParamTraits> : RegionParamTraits, mozilla::gfx::IntRectTyped, - typename mozilla::gfx::IntRegionTyped::OldRectIterator> + typename mozilla::gfx::IntRegionTyped::RectIterator> {}; template<> @@ -666,7 +666,7 @@ struct ParamTraits template<> struct ParamTraits - : RegionParamTraits + : RegionParamTraits {}; template <> diff --git a/gfx/layers/Compositor.cpp b/gfx/layers/Compositor.cpp index 457cb0d6873..43c3ebf6651 100644 --- a/gfx/layers/Compositor.cpp +++ b/gfx/layers/Compositor.cpp @@ -58,12 +58,9 @@ Compositor::DrawDiagnostics(DiagnosticFlags aFlags, } if (aVisibleRegion.GetNumRects() > 1) { - nsIntRegionRectIterator screenIter(aVisibleRegion); - - while (const gfx::IntRect* rect = screenIter.Next()) - { + for (auto iter = aVisibleRegion.RectIter(); !iter.Done(); iter.Next()) { DrawDiagnostics(aFlags | DiagnosticFlags::REGION_RECT, - IntRectToRect(*rect), aClipRect, aTransform, + IntRectToRect(iter.Get()), aClipRect, aTransform, aFlashCounter); } } diff --git a/gfx/layers/LayerTreeInvalidation.cpp b/gfx/layers/LayerTreeInvalidation.cpp index 146ff820b2f..941d7c7ad6b 100644 --- a/gfx/layers/LayerTreeInvalidation.cpp +++ b/gfx/layers/LayerTreeInvalidation.cpp @@ -83,10 +83,8 @@ TransformRect(const IntRect& aRect, const Matrix4x4& aTransform) static void AddTransformedRegion(nsIntRegion& aDest, const nsIntRegion& aSource, const Matrix4x4& aTransform) { - nsIntRegionRectIterator iter(aSource); - const IntRect *r; - while ((r = iter.Next())) { - aDest.Or(aDest, TransformRect(*r, aTransform)); + for (auto iter = aSource.RectIter(); !iter.Done(); iter.Next()) { + aDest.Or(aDest, TransformRect(iter.Get(), aTransform)); } aDest.SimplifyOutward(20); } diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 2d2075e8fff..079bb3a679e 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1997,9 +1997,8 @@ DumpRect(layerscope::LayersPacket::Layer::Rect* aLayerRect, static void DumpRegion(layerscope::LayersPacket::Layer::Region* aLayerRegion, const nsIntRegion& aRegion) { - nsIntRegionRectIterator it(aRegion); - while (const IntRect* sr = it.Next()) { - DumpRect(aLayerRegion->add_r(), *sr); + for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) { + DumpRect(aLayerRegion->add_r(), iter.Get()); } }