Bug 486934 - video display should take account of image-rendering CSS property. r+sr=roc

This commit is contained in:
Robert Longson 2009-04-06 12:05:29 +01:00
parent f90ecec9a1
commit b2f8e75361
6 changed files with 17 additions and 7 deletions

View File

@ -3205,7 +3205,7 @@ nsCanvasRenderingContext2D::ThebesSurfaceFromElement(nsIDOMElement *imgElt,
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
video->Paint(ctx, gfxRect(0, 0, videoWidth, videoHeight));
video->Paint(ctx, gfxPattern::FILTER_GOOD, gfxRect(0, 0, videoWidth, videoHeight));
*aSurface = surf.forget().get();
*widthOut = videoWidth;

View File

@ -129,7 +129,9 @@ public:
// Draw the latest video data. See nsMediaDecoder for
// details.
void Paint(gfxContext* aContext, const gfxRect& aRect);
void Paint(gfxContext* aContext,
gfxPattern::GraphicsFilter aFilter,
const gfxRect& aRect);
// Dispatch events
nsresult DispatchSimpleEvent(const nsAString& aName);

View File

@ -1342,10 +1342,12 @@ void nsHTMLMediaElement::NotifyAutoplayDataReady()
}
}
void nsHTMLMediaElement::Paint(gfxContext* aContext, const gfxRect& aRect)
void nsHTMLMediaElement::Paint(gfxContext* aContext,
gfxPattern::GraphicsFilter aFilter,
const gfxRect& aRect)
{
if (mDecoder)
mDecoder->Paint(aContext, aRect);
mDecoder->Paint(aContext, aFilter, aRect);
}
nsresult nsHTMLMediaElement::DispatchSimpleEvent(const nsAString& aName)

View File

@ -120,7 +120,9 @@ class nsMediaDecoder : public nsIObserver
// RGB buffer doesn't have to be exposed publically.
// The current video frame is drawn to fill aRect.
// Called in the main thread only.
virtual void Paint(gfxContext* aContext, const gfxRect& aRect);
virtual void Paint(gfxContext* aContext,
gfxPattern::GraphicsFilter aFilter,
const gfxRect& aRect);
// Called when the video file has completed downloading.
virtual void ResourceLoaded() = 0;

View File

@ -211,7 +211,9 @@ void nsMediaDecoder::SetRGBData(PRInt32 aWidth, PRInt32 aHeight, float aFramerat
mRGB = aRGBBuffer;
}
void nsMediaDecoder::Paint(gfxContext* aContext, const gfxRect& aRect)
void nsMediaDecoder::Paint(gfxContext* aContext,
gfxPattern::GraphicsFilter aFilter,
const gfxRect& aRect)
{
nsAutoLock lock(mVideoUpdateLock);
@ -235,6 +237,8 @@ void nsMediaDecoder::Paint(gfxContext* aContext, const gfxRect& aRect)
// Make the source image fill the rectangle completely
pat->SetMatrix(gfxMatrix().Scale(mRGBWidth/aRect.Width(), mRGBHeight/aRect.Height()));
pat->SetFilter(aFilter);
// Set PAD mode so that when the video is being scaled, we do not sample
// outside the bounds of the video image.
gfxPattern::GraphicsExtend extend = gfxPattern::EXTEND_PAD;

View File

@ -145,7 +145,7 @@ nsVideoFrame::PaintVideo(nsIRenderingContext& aRenderingContext,
presContext->AppUnitsToGfxUnits(area.height));
r = CorrectForAspectRatio(r, videoSize);
element->Paint(ctx, r);
element->Paint(ctx, nsLayoutUtils::GetGraphicsFilterForFrame(this), r);
}
NS_IMETHODIMP