Bug 725209 - Mark TextureImage as valid when self copying, and correctly mark the region needing to be redrawn. r=joe

This commit is contained in:
Matt Woodrow 2012-02-15 16:03:05 -05:00
parent e03562cb0e
commit b01db32e07
2 changed files with 37 additions and 0 deletions

View File

@ -247,6 +247,12 @@ public:
EndUpdate();
}
/**
* Mark this texture as having valid contents. Call this after modifying
* the texture contents externally.
*/
virtual void MarkValid() {}
/**
* aSurf - the source surface to update from
* aRegion - the region in this image to update
@ -392,6 +398,8 @@ public:
virtual already_AddRefed<gfxASurface>
GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt);
virtual void MarkValid() { mTextureState = Valid; }
// Call when drawing into the update surface is complete.
// Returns true if textures should be upload with a relative
// offset - See UploadSurfaceToTexture.

View File

@ -591,15 +591,44 @@ BasicBufferOGL::BeginPaint(ContentType aContentType,
nsIntRect srcRect(overlap), dstRect(overlap);
srcRect.MoveBy(- mBufferRect.TopLeft() + mBufferRotation);
dstRect.MoveBy(- destBufferRect.TopLeft());
if (mBufferRotation != nsIntPoint(0, 0)) {
// If mBuffer is rotated, then BlitTextureImage will only be copying the bottom-right section
// of the buffer. We need to invalidate the remaining sections so that they get redrawn too.
// Alternatively we could teach BlitTextureImage to rearrange the rotated segments onto
// the new buffer.
// When the rotated buffer is reorganised, the bottom-right section will be drawn in the top left.
// Find the point where this content ends.
nsIntPoint rotationPoint(mBufferRect.x + mBufferRect.width - mBufferRotation.x,
mBufferRect.y + mBufferRect.height - mBufferRotation.y);
// Mark the remaining quadrants (bottom-left&right, top-right) as invalid.
nsIntRect bottom(mBufferRect.x, rotationPoint.y, mBufferRect.width, mBufferRotation.y);
nsIntRect topright(rotationPoint.x, mBufferRect.y, mBufferRotation.x, rotationPoint.y - mBufferRect.y);
if (!bottom.IsEmpty()) {
nsIntRegion temp;
temp.And(destBufferRect, bottom);
result.mRegionToDraw.Or(result.mRegionToDraw, temp);
}
if (!topright.IsEmpty()) {
nsIntRegion temp;
temp.And(destBufferRect, topright);
result.mRegionToDraw.Or(result.mRegionToDraw, temp);
}
}
destBuffer->Resize(destBufferRect.Size());
gl()->BlitTextureImage(mTexImage, srcRect,
destBuffer, dstRect);
destBuffer->MarkValid();
if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
destBufferOnWhite->Resize(destBufferRect.Size());
gl()->BlitTextureImage(mTexImageOnWhite, srcRect,
destBufferOnWhite, dstRect);
destBufferOnWhite->MarkValid();
}
} else {
// can't blit, just draw everything