Don't reuse a back buffer after a swap if the content or surface changed (
bug 1399692 part 9, r=bas)
MozReview-Commit-ID: HGAxkeyESbc
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -497,20 +497,29 @@ ContentClient::CalculateBufferForPaint(P
// We need to validate the entire buffer, to make sure that only valid
// pixels are sampled.
neededRegion = destBufferRect;
}
// If we have an existing buffer, but the content type has changed or we
// have transitioned into/out of component alpha, then we need to recreate it.
bool needsComponentAlpha = (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA);
- bool changedSurfaceOrContent = frontBuffer &&
- (contentType != frontBuffer->GetContentType() ||
- needsComponentAlpha != frontBuffer->HaveBufferOnWhite());
- if (canKeepBufferContents && changedSurfaceOrContent) {
+ bool backBufferChangedSurface = mBuffer &&
+ (contentType != mBuffer->GetContentType() ||
+ needsComponentAlpha != mBuffer->HaveBufferOnWhite());
+ if (canKeepBufferContents && backBufferChangedSurface) {
+ // We cannot reuse the back buffer if the surface type or content type
+ // changed. We may have to also invalidate, but only if the front buffer
+ // also changed.
+ canReuseBuffer = false;
+ }
+ bool frontBufferChangedSurface = frontBuffer &&
+ (contentType != frontBuffer->GetContentType() ||
+ needsComponentAlpha != frontBuffer->HaveBufferOnWhite());
+ if (canKeepBufferContents && frontBufferChangedSurface) {
// Restart the decision process; we won't re-enter since we guard on
// being able to keep the buffer contents.
canReuseBuffer = false;
canKeepBufferContents = false;
validRegion.SetEmpty();
continue;
}