зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1210560 - Part 6: Convert code to support non-operator OVER in nsCSSRendering to moz2d. r=roc
This commit is contained in:
Родитель
b8dfcb93d1
Коммит
0c86230a51
|
@ -5053,13 +5053,6 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
|
||||||
return DrawResult::TEMPORARY_ERROR;
|
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));
|
nsCOMPtr<imgIContainer> image(ImageOps::CreateFromDrawable(drawable));
|
||||||
DrawResult result =
|
DrawResult result =
|
||||||
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
|
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
|
||||||
|
@ -5067,11 +5060,6 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
|
||||||
filter, aDest, aFill, aAnchor, aDirtyRect,
|
filter, aDest, aFill, aAnchor, aDirtyRect,
|
||||||
ConvertImageRendererToDrawFlags(mFlags));
|
ConvertImageRendererToDrawFlags(mFlags));
|
||||||
|
|
||||||
if (op != CompositionOp::OP_OVER) {
|
|
||||||
ctx->PopGroupToSource();
|
|
||||||
ctx->Paint();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
case eStyleImageType_Null:
|
case eStyleImageType_Null:
|
||||||
|
|
|
@ -6396,6 +6396,8 @@ DrawImageInternal(gfxContext& aContext,
|
||||||
const SVGImageContext* aSVGContext,
|
const SVGImageContext* aSVGContext,
|
||||||
uint32_t aImageFlags)
|
uint32_t aImageFlags)
|
||||||
{
|
{
|
||||||
|
DrawResult result = DrawResult::SUCCESS;
|
||||||
|
|
||||||
if (aPresContext->Type() == nsPresContext::eContext_Print) {
|
if (aPresContext->Type() == nsPresContext::eContext_Print) {
|
||||||
// We want vector images to be passed on as vector commands, not a raster
|
// We want vector images to be passed on as vector commands, not a raster
|
||||||
// image.
|
// image.
|
||||||
|
@ -6413,21 +6415,48 @@ DrawImageInternal(gfxContext& aContext,
|
||||||
aGraphicsFilter, aImageFlags);
|
aGraphicsFilter, aImageFlags);
|
||||||
|
|
||||||
if (!params.shouldDraw) {
|
if (!params.shouldDraw) {
|
||||||
return DrawResult::SUCCESS;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxContextMatrixAutoSaveRestore contextMatrixRestorer(&aContext);
|
{
|
||||||
aContext.SetMatrix(params.imageSpaceToDeviceSpace);
|
gfxContextMatrixAutoSaveRestore contextMatrixRestorer(&aContext);
|
||||||
|
|
||||||
Maybe<SVGImageContext> svgContext = ToMaybe(aSVGContext);
|
RefPtr<gfxContext> destCtx = &aContext;
|
||||||
if (!svgContext) {
|
|
||||||
// Use the default viewport.
|
IntRect tmpDTRect;
|
||||||
svgContext = Some(SVGImageContext(params.svgViewportSize, Nothing()));
|
|
||||||
|
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,
|
return result;
|
||||||
imgIContainer::FRAME_CURRENT, aGraphicsFilter,
|
|
||||||
svgContext, aImageFlags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ DrawResult
|
/* static */ DrawResult
|
||||||
|
|
|
@ -4644,6 +4644,8 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
|
||||||
|
|
||||||
MOZ_ASSERT(aThebesContext->CurrentOp() == CompositionOp::OP_OVER);
|
MOZ_ASSERT(aThebesContext->CurrentOp() == CompositionOp::OP_OVER);
|
||||||
|
|
||||||
|
aThebesContext->Clip();
|
||||||
|
|
||||||
nsDeviceContext* devCtx = mPresContext->DeviceContext();
|
nsDeviceContext* devCtx = mPresContext->DeviceContext();
|
||||||
|
|
||||||
gfxPoint offset(-nsPresContext::AppUnitsToFloatCSSPixels(aRect.x),
|
gfxPoint offset(-nsPresContext::AppUnitsToFloatCSSPixels(aRect.x),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче