Bug 732917 - Use tile iteration functions in DirectUpdate. r=ajuma

So that the tile iteration callback remains useful, use the public iteration
functions when iterating over tiles in TiledTextureImage::DirectUpdate.
This commit is contained in:
Chris Lord 2012-03-17 12:06:29 +00:00
parent 42c647aeae
commit 018b526b78

View File

@ -885,14 +885,19 @@ TiledTextureImage::DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion,
} }
bool result = true; bool result = true;
for (unsigned i = 0; i < mImages.Length(); i++) { int oldCurrentImage = mCurrentImage;
int xPos = (i % mColumns) * mTileSize; BeginTileIteration();
int yPos = (i / mColumns) * mTileSize; do {
nsIntRect tileRect = GetTileRect();
int xPos = tileRect.x;
int yPos = tileRect.y;
nsIntRegion tileRegion; nsIntRegion tileRegion;
nsIntRect tileRect = nsIntRect(nsIntPoint(xPos, yPos), mImages[i]->GetSize());
tileRegion.And(region, tileRect); // intersect with tile tileRegion.And(region, tileRect); // intersect with tile
if (tileRegion.IsEmpty()) if (tileRegion.IsEmpty())
continue; continue;
if (mGL->CanUploadSubTextures()) { if (mGL->CanUploadSubTextures()) {
tileRegion.MoveBy(-xPos, -yPos); // translate into tile local space tileRegion.MoveBy(-xPos, -yPos); // translate into tile local space
} else { } else {
@ -900,10 +905,17 @@ TiledTextureImage::DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion,
tileRect.x = tileRect.y = 0; tileRect.x = tileRect.y = 0;
tileRegion = nsIntRegion(tileRect); tileRegion = nsIntRegion(tileRect);
} }
result &= mImages[i]->DirectUpdate(aSurf,
tileRegion, result &= mImages[mCurrentImage]->
aFrom + nsIntPoint(xPos, yPos)); DirectUpdate(aSurf, tileRegion, aFrom + nsIntPoint(xPos, yPos));
}
// Override a callback cancelling iteration if the texture wasn't valid.
// We need to force the update in that situation, or we may end up
// showing invalid/out-of-date texture data.
} while (NextTile() ||
(mTextureState != Valid && mCurrentImage < mImages.Length()));
mCurrentImage = oldCurrentImage;
mShaderType = mImages[0]->GetShaderProgramType(); mShaderType = mImages[0]->GetShaderProgramType();
mTextureState = Valid; mTextureState = Valid;
return result; return result;
@ -1060,11 +1072,8 @@ bool TiledTextureImage::NextTile()
continueIteration = mIterationCallback(this, mCurrentImage, continueIteration = mIterationCallback(this, mCurrentImage,
mIterationCallbackData); mIterationCallbackData);
if (mCurrentImage + 1 < mImages.Length()) { mCurrentImage++;
mCurrentImage++; return continueIteration && (mCurrentImage < mImages.Length());
return continueIteration;
}
return false;
} }
void TiledTextureImage::SetIterationCallback(TileIterationCallback aCallback, void TiledTextureImage::SetIterationCallback(TileIterationCallback aCallback,