From 20728b4dbecd9e464fbef2131022cf1c27a68ff5 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Fri, 31 Jan 2014 16:36:42 +1300 Subject: [PATCH] Bug 700926. Change DrawPaintServer to DrawableFromPaintServer. r=roc --- layout/base/nsCSSRendering.cpp | 27 +++++++++++------ layout/svg/nsSVGIntegrationUtils.cpp | 43 +++++----------------------- layout/svg/nsSVGIntegrationUtils.h | 21 +++++++------- 3 files changed, 35 insertions(+), 56 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 46ea6b128afc..b328ccf99ef3 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -4508,21 +4508,30 @@ nsImageRenderer::Draw(nsPresContext* aPresContext, } case eStyleImageType_Element: { + nsRefPtr drawable; if (mPaintServerFrame) { - nsSVGIntegrationUtils::DrawPaintServer( - &aRenderingContext, mForFrame, mPaintServerFrame, graphicsFilter, - aDest, aFill, aDest.TopLeft(), aDirtyRect, mSize, - mFlags & FLAG_SYNC_DECODE_IMAGES ? - nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES : 0); + int32_t appUnitsPerDevPixel = mForFrame->PresContext()->AppUnitsPerDevPixel(); + nsRect destSize = aDest - aDest.TopLeft(); + nsIntSize roundedOut = destSize.ToOutsidePixels(appUnitsPerDevPixel).Size(); + gfxIntSize imageSize(roundedOut.width, roundedOut.height); + drawable = nsSVGIntegrationUtils::DrawableFromPaintServer( + mPaintServerFrame, mForFrame, mSize, imageSize, + aRenderingContext.ThebesContext()->CurrentMatrix(), + mFlags & FLAG_SYNC_DECODE_IMAGES + ? nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES + : 0); + + if (!drawable) { + return; + } } else { NS_ASSERTION(mImageElementSurface.mSourceSurface, "Surface should be ready."); - nsRefPtr surfaceDrawable = + drawable = new gfxSurfaceDrawable(mImageElementSurface.mSourceSurface, mImageElementSurface.mSize); - nsLayoutUtils::DrawPixelSnapped( - &aRenderingContext, surfaceDrawable, graphicsFilter, - aDest, aFill, aDest.TopLeft(), aDirtyRect); } + nsLayoutUtils::DrawPixelSnapped(&aRenderingContext, drawable, graphicsFilter, + aDest, aFill, aSrc.TopLeft(), aDirtyRect); return; } case eStyleImageType_Null: diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index c0c0a1638ec3..65475ccb45e5 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -662,13 +662,13 @@ PaintFrameCallback::operator()(gfxContext* aContext, return true; } -static already_AddRefed -DrawableFromPaintServer(nsIFrame* aFrame, - nsIFrame* aTarget, - const nsSize& aPaintServerSize, - const gfxIntSize& aRenderSize, - const gfxMatrix& aContextMatrix, - uint32_t aFlags) +/* static */ already_AddRefed +nsSVGIntegrationUtils::DrawableFromPaintServer(nsIFrame* aFrame, + nsIFrame* aTarget, + const nsSize& aPaintServerSize, + const gfxIntSize& aRenderSize, + const gfxMatrix& aContextMatrix, + uint32_t aFlags) { // aPaintServerSize is the size that would be filled when using // background-repeat:no-repeat and background-size:auto. For normal background @@ -714,32 +714,3 @@ DrawableFromPaintServer(nsIFrame* aFrame, nsRefPtr drawable = new gfxCallbackDrawable(cb, aRenderSize); return drawable.forget(); } - -/* static */ void -nsSVGIntegrationUtils::DrawPaintServer(nsRenderingContext* aRenderingContext, - nsIFrame* aTarget, - nsIFrame* aPaintServer, - GraphicsFilter aFilter, - const nsRect& aDest, - const nsRect& aFill, - const nsPoint& aAnchor, - const nsRect& aDirty, - const nsSize& aPaintServerSize, - uint32_t aFlags) -{ - if (aDest.IsEmpty() || aFill.IsEmpty()) - return; - - int32_t appUnitsPerDevPixel = aTarget->PresContext()->AppUnitsPerDevPixel(); - nsRect destSize = aDest - aDest.TopLeft(); - nsIntSize roundedOut = destSize.ToOutsidePixels(appUnitsPerDevPixel).Size(); - gfxIntSize imageSize(roundedOut.width, roundedOut.height); - nsRefPtr drawable = - DrawableFromPaintServer(aPaintServer, aTarget, aPaintServerSize, imageSize, - aRenderingContext->ThebesContext()->CurrentMatrix(), aFlags); - - if (drawable) { - nsLayoutUtils::DrawPixelSnapped(aRenderingContext, drawable, aFilter, - aDest, aFill, aAnchor, aDirty); - } -} diff --git a/layout/svg/nsSVGIntegrationUtils.h b/layout/svg/nsSVGIntegrationUtils.h index 9652d92d60c4..26433420463d 100644 --- a/layout/svg/nsSVGIntegrationUtils.h +++ b/layout/svg/nsSVGIntegrationUtils.h @@ -9,7 +9,9 @@ #include "gfxMatrix.h" #include "GraphicsFilter.h" #include "gfxRect.h" +#include "nsAutoPtr.h" +class gfxDrawable; class nsDisplayList; class nsDisplayListBuilder; class nsIFrame; @@ -184,17 +186,14 @@ public: enum { FLAG_SYNC_DECODE_IMAGES = 0x01, }; - static void - DrawPaintServer(nsRenderingContext* aRenderingContext, - nsIFrame* aTarget, - nsIFrame* aPaintServer, - GraphicsFilter aFilter, - const nsRect& aDest, - const nsRect& aFill, - const nsPoint& aAnchor, - const nsRect& aDirty, - const nsSize& aPaintServerSize, - uint32_t aFlags); + + static already_AddRefed + DrawableFromPaintServer(nsIFrame* aFrame, + nsIFrame* aTarget, + const nsSize& aPaintServerSize, + const gfxIntSize& aRenderSize, + const gfxMatrix& aContextMatrix, + uint32_t aFlags); }; #endif /*NSSVGINTEGRATIONUTILS_H_*/