Bug 1210560 - Part 4: Remove code to support non operator-over in nsRenderDocument and move to CanvasRenderingContext2D::DrawWindow. r=roc
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4842,17 +4842,18 @@ CanvasRenderingContext2D::DrawWindow(nsG
return;
}
RefPtr<gfxContext> thebes;
RefPtr<DrawTarget> drawDT;
// Rendering directly is faster and can be done if mTarget supports Azure
// and does not need alpha blending.
if (gfxPlatform::GetPlatform()->SupportsAzureContentForDrawTarget(mTarget) &&
- GlobalAlpha() == 1.0f)
+ GlobalAlpha() == 1.0f &&
+ UsedOperation() == CompositionOp::OP_OVER)
{
thebes = new gfxContext(mTarget);
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
matrix._22, matrix._31, matrix._32));
} else {
drawDT =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(ceil(sw), ceil(sh)),
SurfaceFormat::B8G8R8A8);
@@ -4887,17 +4888,17 @@ CanvasRenderingContext2D::DrawWindow(nsG
error.Throw(NS_ERROR_FAILURE);
return;
}
gfx::Rect destRect(0, 0, w, h);
gfx::Rect sourceRect(0, 0, sw, sh);
mTarget->DrawSurface(source, destRect, sourceRect,
DrawSurfaceOptions(gfx::Filter::POINT),
- DrawOptions(GlobalAlpha(), CompositionOp::OP_OVER,
+ DrawOptions(GlobalAlpha(), UsedOperation(),
AntialiasMode::NONE));
mTarget->Flush();
} else {
mTarget->SetTransform(matrix);
}
// note that x and y are coordinates in the document that
// we're drawing; x and y are drawn to 0,0 in current user
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -4637,46 +4637,17 @@ PresShell::RenderDocument(const nsRect&
// Nothing to paint, just fill the rect
aThebesContext->SetColor(Color::FromABGR(aBackgroundColor));
aThebesContext->Fill();
return NS_OK;
}
gfxContextAutoSaveRestore save(aThebesContext);
- CompositionOp oldOp = aThebesContext->CurrentOp();
- if (oldOp == CompositionOp::OP_OVER) {
- // Clip to the destination rectangle before we push the group,
- // to limit the size of the temporary surface
- aThebesContext->Clip();
- }
-
- // we want the window to be composited as a single image using
- // whatever operator was set; set OP_OVER here, which is
- // either already the case, or overrides the operator in a group.
- // the original operator will be present when we PopGroup.
- // we can avoid using a temporary surface if we're using OP_OVER
- bool needsGroup = oldOp != CompositionOp::OP_OVER;
-
- if (needsGroup) {
- aThebesContext->PushGroup(NS_GET_A(aBackgroundColor) == 0xff ?
- gfxContentType::COLOR :
- gfxContentType::COLOR_ALPHA);
- aThebesContext->Save();
-
- if (oldOp != CompositionOp::OP_OVER) {
- // Clip now while we paint to the temporary surface. For
- // non-source-bounded operators (e.g., SOURCE), we need to do clip
- // here after we've pushed the group, so that eventually popping
- // the group and painting it will be able to clear the entire
- // destination surface.
- aThebesContext->Clip();
- aThebesContext->SetOp(CompositionOp::OP_OVER);
- }
- }
+ MOZ_ASSERT(aThebesContext->CurrentOp() == CompositionOp::OP_OVER);
nsDeviceContext* devCtx = mPresContext->DeviceContext();
gfxPoint offset(-nsPresContext::AppUnitsToFloatCSSPixels(aRect.x),
-nsPresContext::AppUnitsToFloatCSSPixels(aRect.y));
gfxFloat scale = gfxFloat(devCtx->AppUnitsPerDevPixel())/nsPresContext::AppUnitsPerCSSPixel();
// Since canvas APIs use floats to set up their matrices, we may have some
@@ -4738,23 +4709,16 @@ PresShell::RenderDocument(const nsRect&
// Don't let drawWindow blow away our retained layer tree
if ((flags & nsLayoutUtils::PAINT_WIDGET_LAYERS) && wouldFlushRetainedLayers) {
flags &= ~nsLayoutUtils::PAINT_WIDGET_LAYERS;
}
nsLayoutUtils::PaintFrame(&rc, rootFrame, nsRegion(aRect),
aBackgroundColor, flags);
- // if we had to use a group, paint it to the destination now
- if (needsGroup) {
- aThebesContext->Restore();
- aThebesContext->PopGroupToSource();
- aThebesContext->Paint();
- }
-
return NS_OK;
}
/*
* Clip the display list aList to a range. Returns the clipped
* rectangle surrounding the range.
*/
nsRect