mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 21:28:55 +00:00
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:
parent
2e30860493
commit
131b3ab55f
@ -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.
|
||||
|
@ -591,15 +591,59 @@ 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);
|
||||
|
||||
// The buffer looks like:
|
||||
// ______
|
||||
// |1 |2 | Where the center point is offset by mBufferRotation from the top-left corner.
|
||||
// |___|__|
|
||||
// |3 |4 |
|
||||
// |___|__|
|
||||
//
|
||||
// This is drawn to the screen as:
|
||||
// ______
|
||||
// |4 |3 | Where the center point is { width - mBufferRotation.x, height - mBufferRotation.y } from
|
||||
// |___|__| from the top left corner - rotationPoint. Since only quadrant 4 will actually be copied,
|
||||
// |2 |1 | we need to invalidate the others.
|
||||
// |___|__|
|
||||
//
|
||||
// Quadrants 2 and 1
|
||||
nsIntRect bottom(mBufferRect.x, rotationPoint.y, mBufferRect.width, mBufferRotation.y);
|
||||
// Quadrant 3
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user