mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1034528
, part 2 - Remove the Thebes backed gfxContext propagating code from nsCanvasFrame. r=Bas
This commit is contained in:
parent
067c2b97b1
commit
24935e91e2
@ -249,16 +249,6 @@ nsDisplayCanvasBackgroundColor::WriteDebugInfo(nsACString& aTo)
|
||||
}
|
||||
#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)
|
||||
{
|
||||
RefPtr<SourceSurface> source = aSource->Snapshot();
|
||||
@ -277,9 +267,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||
|
||||
nsRefPtr<nsRenderingContext> context;
|
||||
nsRefPtr<gfxContext> dest = aCtx->ThebesContext();
|
||||
nsRefPtr<gfxASurface> surf;
|
||||
RefPtr<DrawTarget> dt;
|
||||
nsRefPtr<gfxContext> ctx;
|
||||
gfxRect destRect;
|
||||
#ifndef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
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
|
||||
// to snap for this context, because we checked HasNonIntegerTranslation above.
|
||||
destRect.Round();
|
||||
if (dest->IsCairo()) {
|
||||
surf = static_cast<gfxASurface*>(Frame()->Properties().Get(nsIFrame::CachedBackgroundImage()));
|
||||
nsRefPtr<gfxASurface> destSurf = dest->CurrentSurface();
|
||||
if (surf && surf->GetType() == destSurf->GetType()) {
|
||||
BlitSurface(dest, destRect, surf);
|
||||
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);
|
||||
dt = static_cast<DrawTarget*>(Frame()->Properties().Get(nsIFrame::CachedBackgroundImageDT()));
|
||||
DrawTarget* destDT = dest->GetDrawTarget();
|
||||
if (dt) {
|
||||
BlitSurface(destDT, destRect, dt);
|
||||
return;
|
||||
}
|
||||
if (surf || dt) {
|
||||
if (surf) {
|
||||
ctx = new gfxContext(surf);
|
||||
} else {
|
||||
ctx = new gfxContext(dt);
|
||||
}
|
||||
dt = destDT->CreateSimilarDrawTarget(IntSize(ceil(destRect.width), ceil(destRect.height)), SurfaceFormat::B8G8R8A8);
|
||||
if (dt) {
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(dt);
|
||||
ctx->Translate(-gfxPoint(destRect.x, destRect.y));
|
||||
context = new nsRenderingContext();
|
||||
context->Init(aCtx->DeviceContext(), ctx);
|
||||
@ -321,15 +293,10 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||
#endif
|
||||
|
||||
PaintInternal(aBuilder,
|
||||
(surf || dt) ? context.get() : aCtx,
|
||||
(surf || dt) ? bgClipRect: mVisibleRect,
|
||||
dt ? context.get() : aCtx,
|
||||
dt ? bgClipRect: mVisibleRect,
|
||||
&bgClipRect);
|
||||
|
||||
if (surf) {
|
||||
BlitSurface(dest, destRect, surf);
|
||||
frame->Properties().Set(nsIFrame::CachedBackgroundImage(),
|
||||
surf.forget().take());
|
||||
}
|
||||
if (dt) {
|
||||
BlitSurface(dest->GetDrawTarget(), destRect, dt);
|
||||
frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), dt.forget().drop());
|
||||
|
Loading…
Reference in New Issue
Block a user