Bug 1239864 (part 5) - 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 110c0b0c35
commit ea62acb917
6 changed files with 26 additions and 35 deletions

View File

@ -95,10 +95,9 @@ AppendToString(std::stringstream& aStream, const nsRegion& r,
{
aStream << pfx;
nsRegionRectIterator it(r);
aStream << "< ";
while (const nsRect* sr = it.Next()) {
AppendToString(aStream, *sr);
for (auto iter = r.RectIter(); !iter.Done(); iter.Next()) {
AppendToString(aStream, iter.Get());
aStream << "; ";
}
aStream << ">";
@ -112,10 +111,9 @@ AppendToString(std::stringstream& aStream, const nsIntRegion& r,
{
aStream << pfx;
nsIntRegionRectIterator it(r);
aStream << "< ";
while (const IntRect* sr = it.Next()) {
AppendToString(aStream, *sr);
for (auto iter = r.RectIter(); !iter.Done(); iter.Next()) {
AppendToString(aStream, iter.Get());
aStream << "; ";
}
aStream << ">";

View File

@ -98,14 +98,11 @@ void
AppendToString(std::stringstream& aStream, const mozilla::gfx::IntRegionTyped<units>& r,
const char* pfx="", const char* sfx="")
{
typedef mozilla::gfx::IntRegionTyped<units> RegionType;
aStream << pfx;
typename RegionType::OldRectIterator it(r);
aStream << "< ";
while (const typename RegionType::RectType* sr = it.Next()) {
AppendToString(aStream, *sr);
for (auto iter = r.RectIter(); !iter.Done(); iter.Next()) {
AppendToString(aStream, iter.Get());
aStream << "; ";
}
aStream << ">";

View File

@ -759,20 +759,18 @@ RotatedContentBuffer::BorrowDrawTargetForPainting(PaintState& aPaintState,
// requested.
return nullptr;
}
nsIntRegionRectIterator iter(*drawPtr);
const IntRect *iterRect;
while ((iterRect = iter.Next())) {
mDTBuffer->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
for (auto iter = drawPtr->RectIter(); !iter.Done(); iter.Next()) {
const IntRect& rect = iter.Get();
mDTBuffer->FillRect(Rect(rect.x, rect.y, rect.width, rect.height),
ColorPattern(Color(0.0, 0.0, 0.0, 1.0)));
mDTBufferOnWhite->FillRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height),
mDTBufferOnWhite->FillRect(Rect(rect.x, rect.y, rect.width, rect.height),
ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
}
} else if (aPaintState.mContentType == gfxContentType::COLOR_ALPHA && HaveBuffer()) {
// HaveBuffer() => we have an existing buffer that we must clear
nsIntRegionRectIterator iter(*drawPtr);
const IntRect *iterRect;
while ((iterRect = iter.Next())) {
result->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
for (auto iter = drawPtr->RectIter(); !iter.Done(); iter.Next()) {
const IntRect& rect = iter.Get();
result->ClearRect(Rect(rect.x, rect.y, rect.width, rect.height));
}
}

View File

@ -626,11 +626,11 @@ BasicCompositor::EndFrame()
// The source DrawTarget is clipped to the invalidation region, so we have
// to copy the individual rectangles in the region or else we'll draw blank
// pixels.
LayoutDeviceIntRegion::OldRectIterator iter(mInvalidRegion);
for (const LayoutDeviceIntRect *r = iter.Next(); r; r = iter.Next()) {
for (auto iter = mInvalidRegion.RectIter(); !iter.Done(); iter.Next()) {
const LayoutDeviceIntRect& r = iter.Get();
dest->CopySurface(source,
IntRect(r->x - mInvalidRect.x, r->y - mInvalidRect.y, r->width, r->height),
IntPoint(r->x - offset.x, r->y - offset.y));
IntRect(r.x - mInvalidRect.x, r.y - mInvalidRect.y, r.width, r.height),
IntPoint(r.x - offset.x, r.y - offset.y));
}
if (!mTarget) {
mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);

View File

@ -456,9 +456,8 @@ MarkLayersHidden(Layer* aLayer, const IntRect& aClipRect,
// content is opaque
if ((aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) &&
(newFlags & ALLOW_OPAQUE)) {
nsIntRegionRectIterator it(region);
while (const IntRect* sr = it.Next()) {
r = *sr;
for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
r = iter.Get();
TransformIntRect(r, transform, ToInsideIntRect);
r.IntersectRect(r, newClipRect);
@ -623,10 +622,9 @@ BasicLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback,
PaintLayer(mTarget, mRoot, aCallback, aCallbackData);
if (!mRegionToClear.IsEmpty()) {
nsIntRegionRectIterator iter(mRegionToClear);
const IntRect *r;
while ((r = iter.Next())) {
mTarget->GetDrawTarget()->ClearRect(Rect(r->x, r->y, r->width, r->height));
for (auto iter = mRegionToClear.RectIter(); !iter.Done(); iter.Next()) {
const IntRect& r = iter.Get();
mTarget->GetDrawTarget()->ClearRect(Rect(r.x, r.y, r.width, r.height));
}
}
if (mWidget) {

View File

@ -53,10 +53,10 @@ X11DataTextureSourceBasic::Update(gfx::DataSourceSurface* aSurface,
NS_ASSERTION(!aSrcOffset, "SrcOffset should not be used with linux OMTC basic");
if (aDestRegion) {
nsIntRegionRectIterator iter(*aDestRegion);
while (const IntRect* iterRect = iter.Next()) {
IntRect srcRect(iterRect->x, iterRect->y, iterRect->width, iterRect->height);
IntPoint dstPoint(iterRect->x, iterRect->y);
for (auto iter = aDestRegion->RectIter(); !iter.Done(); iter.Next()) {
const IntRect& rect = iter.Get();
IntRect srcRect(rect.x, rect.y, rect.width, rect.height);
IntPoint dstPoint(rect.x, rect.y);
// We're uploading regions to our buffer, so let's just copy contents over
mBufferDrawTarget->CopySurface(aSurface, srcRect, dstPoint);