Bug 900133 - Only draw the picture rect of a tiled image. r=nical

--HG--
extra : rebase_source : 836d60efd38040971f2bff9c2b24e66fb084d65d
This commit is contained in:
Matt Woodrow 2013-08-01 21:12:16 -04:00
parent 4f29474aaa
commit 314549b0d3

View File

@ -67,12 +67,28 @@ ImageHost::Composite(EffectChain& aEffectChain,
source,
aFilter);
aEffectChain.mPrimaryEffect = effect;
gfx::Rect pictureRect(0, 0,
mPictureRect.width,
mPictureRect.height);
//XXX: We might have multiple texture sources here (e.g. 3 YCbCr textures), and we're
// only iterating over the tiles of the first one. Are we assuming that the tiling
// will be identical? Can we ensure that somehow?
TileIterator* it = source->AsTileIterator();
if (it) {
it->BeginTileIteration();
do {
nsIntRect tileRect = it->GetTileRect();
gfx::Rect rect(tileRect.x, tileRect.y, tileRect.width, tileRect.height);
if (mHasPictureRect) {
rect = rect.Intersect(pictureRect);
effect->mTextureCoords = Rect(Float(rect.x - tileRect.x)/ tileRect.width,
Float(rect.y - tileRect.y) / tileRect.height,
Float(rect.width) / tileRect.width,
Float(rect.height) / tileRect.height);
} else {
effect->mTextureCoords = Rect(0, 0, 1, 1);
}
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
aOpacity, aTransform, aOffset);
GetCompositor()->DrawDiagnostics(gfx::Color(0.5,0.0,0.0,1.0),
@ -81,14 +97,13 @@ ImageHost::Composite(EffectChain& aEffectChain,
it->EndTileIteration();
} else {
IntSize textureSize = source->GetSize();
gfx::Rect rect(0, 0,
mPictureRect.width,
mPictureRect.height);
gfx::Rect rect;
if (mHasPictureRect) {
effect->mTextureCoords = Rect(Float(mPictureRect.x) / textureSize.width,
Float(mPictureRect.y) / textureSize.height,
Float(mPictureRect.width) / textureSize.width,
Float(mPictureRect.height) / textureSize.height);
rect = pictureRect;
} else {
effect->mTextureCoords = Rect(0, 0, 1, 1);
rect = gfx::Rect(0, 0, textureSize.width, textureSize.height);