mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1091323 - Convert the nsLayoutUtils helpers that paint images and take an nsRenderingContext to take a gfxContext instead. r=seth
This commit is contained in:
parent
fe119fa9c8
commit
df99c4ebbf
@ -4915,7 +4915,8 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
|
||||
{
|
||||
nsIntSize imageSize(nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
|
||||
nsPresContext::AppUnitsToIntCSSPixels(mSize.height));
|
||||
nsLayoutUtils::DrawBackgroundImage(&aRenderingContext, aPresContext,
|
||||
nsLayoutUtils::DrawBackgroundImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext,
|
||||
mImageContainer, imageSize, filter,
|
||||
aDest, aFill, aAnchor, aDirtyRect,
|
||||
ConvertImageRendererToDrawFlags(mFlags));
|
||||
@ -4945,7 +4946,8 @@ nsImageRenderer::Draw(nsPresContext* aPresContext,
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIContainer> image(ImageOps::CreateFromDrawable(drawable));
|
||||
nsLayoutUtils::DrawImage(&aRenderingContext, aPresContext, image,
|
||||
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext, image,
|
||||
filter, aDest, aFill, aAnchor, aDirtyRect,
|
||||
ConvertImageRendererToDrawFlags(mFlags));
|
||||
|
||||
@ -5139,7 +5141,7 @@ nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(mForFrame);
|
||||
|
||||
if (!RequiresScaling(aFill, aHFill, aVFill, aUnitSize)) {
|
||||
nsLayoutUtils::DrawSingleImage(&aRenderingContext,
|
||||
nsLayoutUtils::DrawSingleImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext,
|
||||
subImage,
|
||||
graphicsFilter,
|
||||
@ -5150,7 +5152,7 @@ nsImageRenderer::DrawBorderImageComponent(nsPresContext* aPresContext,
|
||||
}
|
||||
|
||||
nsRect tile = ComputeTile(aFill, aHFill, aVFill, aUnitSize);
|
||||
nsLayoutUtils::DrawImage(&aRenderingContext,
|
||||
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext,
|
||||
subImage,
|
||||
graphicsFilter,
|
||||
|
@ -5375,7 +5375,7 @@ ComputeSnappedImageDrawingParameters(gfxContext* aCtx,
|
||||
|
||||
|
||||
static nsresult
|
||||
DrawImageInternal(nsRenderingContext* aRenderingContext,
|
||||
DrawImageInternal(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
GraphicsFilter aGraphicsFilter,
|
||||
@ -5396,27 +5396,26 @@ DrawImageInternal(nsRenderingContext* aRenderingContext,
|
||||
}
|
||||
int32_t appUnitsPerDevPixel =
|
||||
aPresContext->AppUnitsPerDevPixel();
|
||||
gfxContext* ctx = aRenderingContext->ThebesContext();
|
||||
|
||||
SnappedImageDrawingParameters params =
|
||||
ComputeSnappedImageDrawingParameters(ctx, appUnitsPerDevPixel, aDest,
|
||||
ComputeSnappedImageDrawingParameters(&aContext, appUnitsPerDevPixel, aDest,
|
||||
aFill, aAnchor, aDirty, aImage,
|
||||
aGraphicsFilter, aImageFlags);
|
||||
|
||||
if (!params.shouldDraw)
|
||||
return NS_OK;
|
||||
|
||||
gfxContextMatrixAutoSaveRestore contextMatrixRestorer(ctx);
|
||||
ctx->SetMatrix(params.imageSpaceToDeviceSpace);
|
||||
gfxContextMatrixAutoSaveRestore contextMatrixRestorer(&aContext);
|
||||
aContext.SetMatrix(params.imageSpaceToDeviceSpace);
|
||||
|
||||
aImage->Draw(ctx, params.size, params.region, imgIContainer::FRAME_CURRENT,
|
||||
aImage->Draw(&aContext, params.size, params.region, imgIContainer::FRAME_CURRENT,
|
||||
aGraphicsFilter, ToMaybe(aSVGContext), aImageFlags);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsLayoutUtils::DrawSingleUnscaledImage(nsRenderingContext* aRenderingContext,
|
||||
nsLayoutUtils::DrawSingleUnscaledImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
GraphicsFilter aGraphicsFilter,
|
||||
@ -5447,14 +5446,14 @@ nsLayoutUtils::DrawSingleUnscaledImage(nsRenderingContext* aRenderingContext,
|
||||
// outside the image bounds, we want to honor the aSourceArea-to-aDest
|
||||
// translation but we don't want to actually tile the image.
|
||||
fill.IntersectRect(fill, dest);
|
||||
return DrawImageInternal(aRenderingContext, aPresContext,
|
||||
return DrawImageInternal(aContext, aPresContext,
|
||||
aImage, aGraphicsFilter,
|
||||
dest, fill, aDest, aDirty ? *aDirty : dest,
|
||||
nullptr, aImageFlags);
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsLayoutUtils::DrawSingleImage(nsRenderingContext* aRenderingContext,
|
||||
nsLayoutUtils::DrawSingleImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
GraphicsFilter aGraphicsFilter,
|
||||
@ -5496,7 +5495,7 @@ nsLayoutUtils::DrawSingleImage(nsRenderingContext* aRenderingContext,
|
||||
// transform but we don't want to actually tile the image.
|
||||
nsRect fill;
|
||||
fill.IntersectRect(aDest, dest);
|
||||
return DrawImageInternal(aRenderingContext, aPresContext, image,
|
||||
return DrawImageInternal(aContext, aPresContext, image,
|
||||
aGraphicsFilter, dest, fill, fill.TopLeft(),
|
||||
aDirty, aSVGContext, aImageFlags);
|
||||
}
|
||||
@ -5565,7 +5564,7 @@ nsLayoutUtils::ComputeSizeForDrawingWithFallback(imgIContainer* aImage,
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsLayoutUtils::DrawBackgroundImage(nsRenderingContext* aRenderingContext,
|
||||
nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
const nsIntSize& aImageSize,
|
||||
@ -5585,13 +5584,13 @@ nsLayoutUtils::DrawBackgroundImage(nsRenderingContext* aRenderingContext,
|
||||
|
||||
SVGImageContext svgContext(aImageSize, Nothing());
|
||||
|
||||
return DrawImageInternal(aRenderingContext, aPresContext, aImage,
|
||||
return DrawImageInternal(aContext, aPresContext, aImage,
|
||||
aGraphicsFilter, aDest, aFill, aAnchor,
|
||||
aDirty, &svgContext, aImageFlags);
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsLayoutUtils::DrawImage(nsRenderingContext* aRenderingContext,
|
||||
nsLayoutUtils::DrawImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
GraphicsFilter aGraphicsFilter,
|
||||
@ -5601,7 +5600,7 @@ nsLayoutUtils::DrawImage(nsRenderingContext* aRenderingContext,
|
||||
const nsRect& aDirty,
|
||||
uint32_t aImageFlags)
|
||||
{
|
||||
return DrawImageInternal(aRenderingContext, aPresContext, aImage,
|
||||
return DrawImageInternal(aContext, aPresContext, aImage,
|
||||
aGraphicsFilter, aDest, aFill, aAnchor,
|
||||
aDirty, nullptr, aImageFlags);
|
||||
}
|
||||
|
@ -1491,7 +1491,7 @@ public:
|
||||
* @param aDirty Pixels outside this area may be skipped.
|
||||
* @param aImageFlags Image flags of the imgIContainer::FLAG_* variety
|
||||
*/
|
||||
static nsresult DrawBackgroundImage(nsRenderingContext* aRenderingContext,
|
||||
static nsresult DrawBackgroundImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
const nsIntSize& aImageSize,
|
||||
@ -1517,7 +1517,7 @@ public:
|
||||
* @param aDirty Pixels outside this area may be skipped.
|
||||
* @param aImageFlags Image flags of the imgIContainer::FLAG_* variety
|
||||
*/
|
||||
static nsresult DrawImage(nsRenderingContext* aRenderingContext,
|
||||
static nsresult DrawImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
GraphicsFilter aGraphicsFilter,
|
||||
@ -1571,7 +1571,7 @@ public:
|
||||
* in appunits. For best results it should
|
||||
* be aligned with image pixels.
|
||||
*/
|
||||
static nsresult DrawSingleUnscaledImage(nsRenderingContext* aRenderingContext,
|
||||
static nsresult DrawSingleUnscaledImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
GraphicsFilter aGraphicsFilter,
|
||||
@ -1600,7 +1600,7 @@ public:
|
||||
* in appunits. For best results it should
|
||||
* be aligned with image pixels.
|
||||
*/
|
||||
static nsresult DrawSingleImage(nsRenderingContext* aRenderingContext,
|
||||
static nsresult DrawSingleImage(gfxContext& aContext,
|
||||
nsPresContext* aPresContext,
|
||||
imgIContainer* aImage,
|
||||
GraphicsFilter aGraphicsFilter,
|
||||
|
@ -309,7 +309,8 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
|
||||
nsRect dest(padding.left, padding.top,
|
||||
mRect.width - (padding.left + padding.right),
|
||||
mRect.height - (padding.top + padding.bottom));
|
||||
nsLayoutUtils::DrawSingleImage(&aRenderingContext, PresContext(),
|
||||
nsLayoutUtils::DrawSingleImage(*aRenderingContext.ThebesContext(),
|
||||
PresContext(),
|
||||
imageCon, nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
||||
dest + aPt, aDirtyRect, nullptr, aFlags);
|
||||
return;
|
||||
|
@ -1260,7 +1260,7 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext,
|
||||
nsRect dest((vis->mDirection == NS_STYLE_DIRECTION_RTL) ?
|
||||
inner.XMost() - size : inner.x,
|
||||
inner.y, size, size);
|
||||
nsLayoutUtils::DrawSingleImage(&aRenderingContext, PresContext(), imgCon,
|
||||
nsLayoutUtils::DrawSingleImage(*gfx, PresContext(), imgCon,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this), dest, aDirtyRect,
|
||||
nullptr, imgIContainer::FLAG_NONE);
|
||||
iconUsed = true;
|
||||
@ -1491,7 +1491,8 @@ nsImageFrame::PaintImage(nsRenderingContext& aRenderingContext, nsPoint aPt,
|
||||
nsRect dest(inner.TopLeft(), mComputedSize);
|
||||
dest.y -= GetContinuationOffset();
|
||||
|
||||
nsLayoutUtils::DrawSingleImage(&aRenderingContext, PresContext(), aImage,
|
||||
nsLayoutUtils::DrawSingleImage(*aRenderingContext.ThebesContext(),
|
||||
PresContext(), aImage,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this), dest, aDirtyRect,
|
||||
nullptr, aFlags);
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsRenderingContext.h"
|
||||
#include "imgINotificationObserver.h"
|
||||
#include "nsSVGEffects.h"
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
@ -362,8 +361,6 @@ nsSVGImageFrame::PaintSVG(gfxContext& aContext,
|
||||
// force sync probably just isn't worth it, so always pass FLAG_SYNC_DECODE
|
||||
uint32_t drawFlags = imgIContainer::FLAG_SYNC_DECODE;
|
||||
|
||||
nsRenderingContext rendCtx(&aContext);
|
||||
|
||||
if (mImageContainer->GetType() == imgIContainer::TYPE_VECTOR) {
|
||||
// Package up the attributes of this image element which can override the
|
||||
// attributes of mImageContainer's internal SVG document.
|
||||
@ -378,7 +375,7 @@ nsSVGImageFrame::PaintSVG(gfxContext& aContext,
|
||||
// That method needs our image to have a fixed native width & height,
|
||||
// and that's not always true for TYPE_VECTOR images.
|
||||
nsLayoutUtils::DrawSingleImage(
|
||||
&rendCtx,
|
||||
aContext,
|
||||
PresContext(),
|
||||
mImageContainer,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
||||
@ -388,7 +385,7 @@ nsSVGImageFrame::PaintSVG(gfxContext& aContext,
|
||||
drawFlags);
|
||||
} else { // mImageContainer->GetType() == TYPE_RASTER
|
||||
nsLayoutUtils::DrawSingleUnscaledImage(
|
||||
&rendCtx,
|
||||
aContext,
|
||||
PresContext(),
|
||||
mImageContainer,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
||||
|
@ -339,7 +339,8 @@ nsImageBoxFrame::PaintImage(nsRenderingContext& aRenderingContext,
|
||||
|
||||
if (imgCon) {
|
||||
bool hasSubRect = !mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0);
|
||||
nsLayoutUtils::DrawSingleImage(&aRenderingContext, PresContext(), imgCon,
|
||||
nsLayoutUtils::DrawSingleImage(*aRenderingContext.ThebesContext(),
|
||||
PresContext(), imgCon,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
||||
rect, dirty, nullptr, aFlags, hasSubRect ? &mSubRect : nullptr);
|
||||
}
|
||||
|
@ -3390,7 +3390,7 @@ nsTreeBodyFrame::PaintTwisty(int32_t aRowIndex,
|
||||
}
|
||||
|
||||
// Paint the image.
|
||||
nsLayoutUtils::DrawSingleUnscaledImage(&aRenderingContext,
|
||||
nsLayoutUtils::DrawSingleUnscaledImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext, image,
|
||||
GraphicsFilter::FILTER_NEAREST, pt, &aDirtyRect,
|
||||
imgIContainer::FLAG_NONE, &imageSize);
|
||||
@ -3530,7 +3530,7 @@ nsTreeBodyFrame::PaintImage(int32_t aRowIndex,
|
||||
ctx->PushGroup(gfxContentType::COLOR_ALPHA);
|
||||
}
|
||||
|
||||
nsLayoutUtils::DrawImage(&aRenderingContext, aPresContext, image,
|
||||
nsLayoutUtils::DrawImage(*ctx, aPresContext, image,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
||||
wholeImageDest, destRect, destRect.TopLeft(), aDirtyRect,
|
||||
imgIContainer::FLAG_NONE);
|
||||
@ -3728,7 +3728,8 @@ nsTreeBodyFrame::PaintCheckbox(int32_t aRowIndex,
|
||||
}
|
||||
|
||||
// Paint the image.
|
||||
nsLayoutUtils::DrawSingleUnscaledImage(&aRenderingContext, aPresContext,
|
||||
nsLayoutUtils::DrawSingleUnscaledImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext,
|
||||
image, GraphicsFilter::FILTER_NEAREST, pt, &aDirtyRect,
|
||||
imgIContainer::FLAG_NONE, &imageSize);
|
||||
}
|
||||
@ -3790,7 +3791,8 @@ nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
|
||||
image->GetHeight(&height);
|
||||
nsSize size(width*nsDeviceContext::AppUnitsPerCSSPixel(),
|
||||
height*nsDeviceContext::AppUnitsPerCSSPixel());
|
||||
nsLayoutUtils::DrawImage(&aRenderingContext, aPresContext, image,
|
||||
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext, image,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
||||
nsRect(meterRect.TopLeft(), size), meterRect, meterRect.TopLeft(),
|
||||
aDirtyRect, imgIContainer::FLAG_NONE);
|
||||
@ -3816,7 +3818,8 @@ nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
|
||||
image->GetHeight(&height);
|
||||
nsSize size(width*nsDeviceContext::AppUnitsPerCSSPixel(),
|
||||
height*nsDeviceContext::AppUnitsPerCSSPixel());
|
||||
nsLayoutUtils::DrawImage(&aRenderingContext, aPresContext, image,
|
||||
nsLayoutUtils::DrawImage(*aRenderingContext.ThebesContext(),
|
||||
aPresContext, image,
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(this),
|
||||
nsRect(meterRect.TopLeft(), size), meterRect, meterRect.TopLeft(),
|
||||
aDirtyRect, imgIContainer::FLAG_NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user