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

This commit is contained in:
Nicholas Nethercote 2016-01-18 17:20:58 -08:00
parent fca30e032d
commit 110c0b0c35
5 changed files with 22 additions and 29 deletions

View File

@ -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,

View File

@ -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<class Units>
struct ParamTraits<mozilla::gfx::IntRegionTyped<Units>>
: RegionParamTraits<mozilla::gfx::IntRegionTyped<Units>,
mozilla::gfx::IntRectTyped<Units>,
typename mozilla::gfx::IntRegionTyped<Units>::OldRectIterator>
typename mozilla::gfx::IntRegionTyped<Units>::RectIterator>
{};
template<>
@ -666,7 +666,7 @@ struct ParamTraits<nsRect>
template<>
struct ParamTraits<nsRegion>
: RegionParamTraits<nsRegion, nsRect, nsRegionRectIterator>
: RegionParamTraits<nsRegion, nsRect, nsRegion::RectIterator>
{};
template <>

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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());
}
}