Bug 1210560 - Part 6: Convert code to support non-operator OVER in nsCSSRendering to moz2d. r=roc

This commit is contained in:
Bas Schouten 2015-11-11 16:15:40 +01:00
parent ed29caea11
commit 5e37fd72e1
3 changed files with 41 additions and 22 deletions

View File

@ -5053,13 +5053,6 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
return DrawResult::TEMPORARY_ERROR;
}
gfxContext* ctx = aRenderingContext.ThebesContext();
CompositionOp op = ctx->CurrentOp();
if (op != CompositionOp::OP_OVER) {
ctx->PushGroup(gfxContentType::COLOR_ALPHA);
ctx->SetOp(CompositionOp::OP_OVER);
}
nsCOMPtr<imgIContainer> image(ImageOps::CreateFromDrawable(drawable));
DrawResult result =
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
@ -5067,11 +5060,6 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
filter, aDest, aFill, aAnchor, aDirtyRect,
ConvertImageRendererToDrawFlags(mFlags));
if (op != CompositionOp::OP_OVER) {
ctx->PopGroupToSource();
ctx->Paint();
}
return result;
}
case eStyleImageType_Null:

View File

@ -6396,6 +6396,8 @@ DrawImageInternal(gfxContext& aContext,
const SVGImageContext* aSVGContext,
uint32_t aImageFlags)
{
DrawResult result = DrawResult::SUCCESS;
if (aPresContext->Type() == nsPresContext::eContext_Print) {
// We want vector images to be passed on as vector commands, not a raster
// image.
@ -6413,21 +6415,48 @@ DrawImageInternal(gfxContext& aContext,
aGraphicsFilter, aImageFlags);
if (!params.shouldDraw) {
return DrawResult::SUCCESS;
return result;
}
gfxContextMatrixAutoSaveRestore contextMatrixRestorer(&aContext);
aContext.SetMatrix(params.imageSpaceToDeviceSpace);
{
gfxContextMatrixAutoSaveRestore contextMatrixRestorer(&aContext);
Maybe<SVGImageContext> svgContext = ToMaybe(aSVGContext);
if (!svgContext) {
// Use the default viewport.
svgContext = Some(SVGImageContext(params.svgViewportSize, Nothing()));
RefPtr<gfxContext> destCtx = &aContext;
IntRect tmpDTRect;
if (destCtx->CurrentOp() != CompositionOp::OP_OVER) {
Rect imageRect = ToRect(params.imageSpaceToDeviceSpace.TransformBounds(params.region.Rect()));
imageRect.ToIntRect(&tmpDTRect);
RefPtr<DrawTarget> tempDT = destCtx->GetDrawTarget()->CreateSimilarDrawTarget(tmpDTRect.Size(), SurfaceFormat::B8G8R8A8);
destCtx = new gfxContext(tempDT, imageRect.TopLeft());
}
destCtx->SetMatrix(params.imageSpaceToDeviceSpace);
Maybe<SVGImageContext> svgContext = ToMaybe(aSVGContext);
if (!svgContext) {
// Use the default viewport.
svgContext = Some(SVGImageContext(params.svgViewportSize, Nothing()));
}
result = aImage->Draw(destCtx, params.size, params.region,
imgIContainer::FRAME_CURRENT, aGraphicsFilter,
svgContext, aImageFlags);
if (!tmpDTRect.IsEmpty()) {
DrawTarget* dt = aContext.GetDrawTarget();
RefPtr<SourceSurface> surf = destCtx->GetDrawTarget()->Snapshot();
dt->SetTransform(Matrix::Translation(-aContext.GetDeviceOffset()));
dt->DrawSurface(surf, Rect(tmpDTRect.x, tmpDTRect.y, tmpDTRect.width, tmpDTRect.height),
Rect(0, 0, tmpDTRect.width, tmpDTRect.height),
DrawSurfaceOptions(Filter::POINT),
DrawOptions(1.0f, aContext.CurrentOp()));
}
}
return aImage->Draw(&aContext, params.size, params.region,
imgIContainer::FRAME_CURRENT, aGraphicsFilter,
svgContext, aImageFlags);
return result;
}
/* static */ DrawResult

View File

@ -4644,6 +4644,8 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
MOZ_ASSERT(aThebesContext->CurrentOp() == CompositionOp::OP_OVER);
aThebesContext->Clip();
nsDeviceContext* devCtx = mPresContext->DeviceContext();
gfxPoint offset(-nsPresContext::AppUnitsToFloatCSSPixels(aRect.x),