зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1034528
, part 2 - Remove the Thebes backed gfxContext propagating code from nsCanvasFrame. r=Bas
This commit is contained in:
Родитель
067c2b97b1
Коммит
24935e91e2
|
@ -249,16 +249,6 @@ nsDisplayCanvasBackgroundColor::WriteDebugInfo(nsACString& aTo)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void BlitSurface(gfxContext* aDest, const gfxRect& aRect, gfxASurface* aSource)
|
|
||||||
{
|
|
||||||
aDest->Translate(gfxPoint(aRect.x, aRect.y));
|
|
||||||
aDest->SetSource(aSource);
|
|
||||||
aDest->NewPath();
|
|
||||||
aDest->Rectangle(gfxRect(0, 0, aRect.width, aRect.height));
|
|
||||||
aDest->Fill();
|
|
||||||
aDest->Translate(-gfxPoint(aRect.x, aRect.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void BlitSurface(DrawTarget* aDest, const gfxRect& aRect, DrawTarget* aSource)
|
static void BlitSurface(DrawTarget* aDest, const gfxRect& aRect, DrawTarget* aSource)
|
||||||
{
|
{
|
||||||
RefPtr<SourceSurface> source = aSource->Snapshot();
|
RefPtr<SourceSurface> source = aSource->Snapshot();
|
||||||
|
@ -277,9 +267,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
|
|
||||||
nsRefPtr<nsRenderingContext> context;
|
nsRefPtr<nsRenderingContext> context;
|
||||||
nsRefPtr<gfxContext> dest = aCtx->ThebesContext();
|
nsRefPtr<gfxContext> dest = aCtx->ThebesContext();
|
||||||
nsRefPtr<gfxASurface> surf;
|
|
||||||
RefPtr<DrawTarget> dt;
|
RefPtr<DrawTarget> dt;
|
||||||
nsRefPtr<gfxContext> ctx;
|
|
||||||
gfxRect destRect;
|
gfxRect destRect;
|
||||||
#ifndef MOZ_GFX_OPTIMIZE_MOBILE
|
#ifndef MOZ_GFX_OPTIMIZE_MOBILE
|
||||||
if (IsSingleFixedPositionImage(aBuilder, bgClipRect, &destRect) &&
|
if (IsSingleFixedPositionImage(aBuilder, bgClipRect, &destRect) &&
|
||||||
|
@ -288,31 +276,15 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
// Snap image rectangle to nearest pixel boundaries. This is the right way
|
// Snap image rectangle to nearest pixel boundaries. This is the right way
|
||||||
// to snap for this context, because we checked HasNonIntegerTranslation above.
|
// to snap for this context, because we checked HasNonIntegerTranslation above.
|
||||||
destRect.Round();
|
destRect.Round();
|
||||||
if (dest->IsCairo()) {
|
dt = static_cast<DrawTarget*>(Frame()->Properties().Get(nsIFrame::CachedBackgroundImageDT()));
|
||||||
surf = static_cast<gfxASurface*>(Frame()->Properties().Get(nsIFrame::CachedBackgroundImage()));
|
DrawTarget* destDT = dest->GetDrawTarget();
|
||||||
nsRefPtr<gfxASurface> destSurf = dest->CurrentSurface();
|
if (dt) {
|
||||||
if (surf && surf->GetType() == destSurf->GetType()) {
|
BlitSurface(destDT, destRect, dt);
|
||||||
BlitSurface(dest, destRect, surf);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
surf = destSurf->CreateSimilarSurface(
|
|
||||||
gfxContentType::COLOR_ALPHA,
|
|
||||||
gfxIntSize(ceil(destRect.width), ceil(destRect.height)));
|
|
||||||
} else {
|
|
||||||
dt = static_cast<DrawTarget*>(Frame()->Properties().Get(nsIFrame::CachedBackgroundImageDT()));
|
|
||||||
DrawTarget* destDT = dest->GetDrawTarget();
|
|
||||||
if (dt) {
|
|
||||||
BlitSurface(destDT, destRect, dt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dt = destDT->CreateSimilarDrawTarget(IntSize(ceil(destRect.width), ceil(destRect.height)), SurfaceFormat::B8G8R8A8);
|
|
||||||
}
|
}
|
||||||
if (surf || dt) {
|
dt = destDT->CreateSimilarDrawTarget(IntSize(ceil(destRect.width), ceil(destRect.height)), SurfaceFormat::B8G8R8A8);
|
||||||
if (surf) {
|
if (dt) {
|
||||||
ctx = new gfxContext(surf);
|
nsRefPtr<gfxContext> ctx = new gfxContext(dt);
|
||||||
} else {
|
|
||||||
ctx = new gfxContext(dt);
|
|
||||||
}
|
|
||||||
ctx->Translate(-gfxPoint(destRect.x, destRect.y));
|
ctx->Translate(-gfxPoint(destRect.x, destRect.y));
|
||||||
context = new nsRenderingContext();
|
context = new nsRenderingContext();
|
||||||
context->Init(aCtx->DeviceContext(), ctx);
|
context->Init(aCtx->DeviceContext(), ctx);
|
||||||
|
@ -321,15 +293,10 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PaintInternal(aBuilder,
|
PaintInternal(aBuilder,
|
||||||
(surf || dt) ? context.get() : aCtx,
|
dt ? context.get() : aCtx,
|
||||||
(surf || dt) ? bgClipRect: mVisibleRect,
|
dt ? bgClipRect: mVisibleRect,
|
||||||
&bgClipRect);
|
&bgClipRect);
|
||||||
|
|
||||||
if (surf) {
|
|
||||||
BlitSurface(dest, destRect, surf);
|
|
||||||
frame->Properties().Set(nsIFrame::CachedBackgroundImage(),
|
|
||||||
surf.forget().take());
|
|
||||||
}
|
|
||||||
if (dt) {
|
if (dt) {
|
||||||
BlitSurface(dest->GetDrawTarget(), destRect, dt);
|
BlitSurface(dest->GetDrawTarget(), destRect, dt);
|
||||||
frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), dt.forget().drop());
|
frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), dt.forget().drop());
|
||||||
|
|
Загрузка…
Ссылка в новой задаче