Bug 700926. Change DrawPaintServer to DrawableFromPaintServer. r=roc

This commit is contained in:
Nicholas Cameron 2014-01-31 16:36:42 +13:00
parent f364b549bd
commit 0d2cb8a2bc
3 changed files with 35 additions and 56 deletions

View File

@ -4508,21 +4508,30 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
}
case eStyleImageType_Element:
{
nsRefPtr<gfxDrawable> 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<gfxDrawable> 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:

View File

@ -662,13 +662,13 @@ PaintFrameCallback::operator()(gfxContext* aContext,
return true;
}
static already_AddRefed<gfxDrawable>
DrawableFromPaintServer(nsIFrame* aFrame,
nsIFrame* aTarget,
const nsSize& aPaintServerSize,
const gfxIntSize& aRenderSize,
const gfxMatrix& aContextMatrix,
uint32_t aFlags)
/* static */ already_AddRefed<gfxDrawable>
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<gfxDrawable> 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<gfxDrawable> drawable =
DrawableFromPaintServer(aPaintServer, aTarget, aPaintServerSize, imageSize,
aRenderingContext->ThebesContext()->CurrentMatrix(), aFlags);
if (drawable) {
nsLayoutUtils::DrawPixelSnapped(aRenderingContext, drawable, aFilter,
aDest, aFill, aAnchor, aDirty);
}
}

View File

@ -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<gfxDrawable>
DrawableFromPaintServer(nsIFrame* aFrame,
nsIFrame* aTarget,
const nsSize& aPaintServerSize,
const gfxIntSize& aRenderSize,
const gfxMatrix& aContextMatrix,
uint32_t aFlags);
};
#endif /*NSSVGINTEGRATIONUTILS_H_*/