mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1064084, part 1 - Convert all consumers of gfxContext::Translate() to use gfxContext::SetMatrix()/Multiply(). r=Bas
This commit is contained in:
parent
8eb1f481a7
commit
fa8c7ec8a5
@ -307,9 +307,9 @@ MediaEngineTabVideoSource::Draw() {
|
||||
return;
|
||||
}
|
||||
nsRefPtr<gfxContext> context = new gfxContext(dt);
|
||||
gfxPoint pt(0, 0);
|
||||
context->Translate(pt);
|
||||
context->Scale(scale * size.width / srcW, scale * size.height / srcH);
|
||||
context->SetMatrix(
|
||||
context->CurrentMatrix().Scale(scale * size.width / srcW,
|
||||
scale * size.height / srcH));
|
||||
rv = presShell->RenderDocument(r, renderDocFlags, bgColor, context);
|
||||
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
@ -3520,9 +3520,10 @@ CanvasRenderingContext2D::DrawDirectlyToCanvas(
|
||||
src.Scale(scale.width, scale.height);
|
||||
|
||||
nsRefPtr<gfxContext> context = new gfxContext(tempTarget);
|
||||
context->SetMatrix(contextMatrix);
|
||||
context->Scale(1.0 / contextScale.width, 1.0 / contextScale.height);
|
||||
context->Translate(gfxPoint(dest.x - src.x, dest.y - src.y));
|
||||
context->SetMatrix(contextMatrix.
|
||||
Scale(1.0 / contextScale.width,
|
||||
1.0 / contextScale.height).
|
||||
Translate(dest.x - src.x, dest.y - src.y));
|
||||
|
||||
// FLAG_CLAMP is added for increased performance, since we never tile here.
|
||||
uint32_t modifiedFlags = image.mDrawingFlags | imgIContainer::FLAG_CLAMP;
|
||||
|
@ -2172,7 +2172,8 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
|
||||
|
||||
// Renderer::Draw() draws a rectangle with top-left at the aContext origin.
|
||||
gfxContextAutoSaveRestore autoSR(aContext);
|
||||
aContext->Translate(pluginRect.TopLeft());
|
||||
aContext->SetMatrix(
|
||||
aContext->CurrentMatrix().Translate(pluginRect.TopLeft()));
|
||||
|
||||
Renderer renderer(window, this, pluginSize, pluginDirtyRect);
|
||||
|
||||
|
@ -209,7 +209,7 @@ BasicThebesLayer::Validate(LayerManager::DrawThebesLayerCallback aCallback,
|
||||
if (ctx) {
|
||||
NS_ASSERTION(GetEffectiveOpacity() == 1.0, "Should only read back opaque layers");
|
||||
NS_ASSERTION(!GetMaskLayer(), "Should only read back layers without masks");
|
||||
ctx->Translate(gfxPoint(offset.x, offset.y));
|
||||
ctx->SetMatrix(ctx->CurrentMatrix().Translate(offset.x, offset.y));
|
||||
mContentClient->DrawTo(this, ctx->GetDrawTarget(), 1.0,
|
||||
CompositionOpForOp(ctx->CurrentOperator()),
|
||||
nullptr, nullptr);
|
||||
|
@ -163,8 +163,9 @@ SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile,
|
||||
// do the drawing
|
||||
RefPtr<gfxContext> ctxt = new gfxContext(drawTarget);
|
||||
|
||||
ctxt->Scale(mResolution, mResolution);
|
||||
ctxt->Translate(gfxPoint(-aTileOrigin.x, -aTileOrigin.y));
|
||||
ctxt->SetMatrix(
|
||||
ctxt->CurrentMatrix().Scale(mResolution, mResolution).
|
||||
Translate(-aTileOrigin.x, -aTileOrigin.y));
|
||||
|
||||
mCallback(mThebesLayer, ctxt,
|
||||
drawRegion,
|
||||
|
@ -929,8 +929,9 @@ ClientTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
|
||||
mSinglePaintBufferOffset = nsIntPoint(bounds.x, bounds.y);
|
||||
}
|
||||
ctxt->NewPath();
|
||||
ctxt->Scale(mResolution, mResolution);
|
||||
ctxt->Translate(gfxPoint(-bounds.x, -bounds.y));
|
||||
ctxt->SetMatrix(
|
||||
ctxt->CurrentMatrix().Scale(mResolution, mResolution).
|
||||
Translate(-bounds.x, -bounds.y));
|
||||
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
|
||||
if (PR_IntervalNow() - start > 3) {
|
||||
printf_stderr("Slow alloc %i\n", PR_IntervalNow() - start);
|
||||
@ -1300,8 +1301,10 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile,
|
||||
|
||||
ctxt->NewPath();
|
||||
ctxt->Clip(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height));
|
||||
ctxt->Translate(gfxPoint(-unscaledTileOrigin.x, -unscaledTileOrigin.y));
|
||||
ctxt->Scale(mResolution, mResolution);
|
||||
ctxt->SetMatrix(
|
||||
ctxt->CurrentMatrix().Translate(-unscaledTileOrigin.x,
|
||||
-unscaledTileOrigin.y).
|
||||
Scale(mResolution, mResolution));
|
||||
mCallback(mThebesLayer, ctxt,
|
||||
tileRegion.GetBounds(),
|
||||
DrawRegionClip::CLIP_NONE,
|
||||
|
@ -80,7 +80,8 @@ public:
|
||||
update->mSequenceCounter);
|
||||
|
||||
if (ctx) {
|
||||
ctx->Translate(gfxPoint(offset.x, offset.y));
|
||||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Translate(offset.x, offset.y));
|
||||
ctx->SetSource(sourceSurface, gfxPoint(mTask->mOrigin.x,
|
||||
mTask->mOrigin.y));
|
||||
ctx->Paint();
|
||||
|
@ -396,7 +396,8 @@ ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode)
|
||||
|
||||
nsRefPtr<gfxContext> context = new gfxContext(mDrawTarget);
|
||||
|
||||
context->Translate(gfxPoint(-visibleRect.x, -visibleRect.y));
|
||||
context->SetMatrix(
|
||||
context->CurrentMatrix().Translate(-visibleRect.x, -visibleRect.y));
|
||||
if (aMode == SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA) {
|
||||
nsIntRegionRectIterator iter(aRegion);
|
||||
const nsIntRect *iterRect;
|
||||
|
@ -535,7 +535,7 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode,
|
||||
|
||||
nsRefPtr<gfxContext> context = new gfxContext(dt);
|
||||
|
||||
context->Translate(gfxPoint(-bounds.x, -bounds.y));
|
||||
context->SetMatrix(context->CurrentMatrix().Translate(-bounds.x, -bounds.y));
|
||||
LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo();
|
||||
cbInfo.Callback(this, context, aRegion, DrawRegionClip::CLIP_NONE, nsIntRegion(), cbInfo.CallbackData);
|
||||
|
||||
@ -548,7 +548,7 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode,
|
||||
update.mLayer->GetSink()->BeginUpdate(update.mUpdateRect + offset,
|
||||
update.mSequenceCounter);
|
||||
if (ctx) {
|
||||
ctx->Translate(gfxPoint(offset.x, offset.y));
|
||||
ctx->SetMatrix(ctx->CurrentMatrix().Translate(offset.x, offset.y));
|
||||
ctx->SetSource(destinationSurface, gfxPoint(bounds.x, bounds.y));
|
||||
ctx->Paint();
|
||||
update.mLayer->GetSink()->EndUpdate(ctx, update.mUpdateRect + offset);
|
||||
|
@ -75,7 +75,7 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect,
|
||||
gfxPoint topleft(irect.TopLeft().x, irect.TopLeft().y);
|
||||
|
||||
mContext = new gfxContext(dt);
|
||||
mContext->Translate(-topleft);
|
||||
mContext->SetMatrix(gfxMatrix::Translation(-topleft));
|
||||
|
||||
return mContext;
|
||||
}
|
||||
|
@ -430,13 +430,6 @@ gfxContext::DrawSurface(gfxASurface *surface, const gfxSize& size)
|
||||
}
|
||||
|
||||
// transform stuff
|
||||
void
|
||||
gfxContext::Translate(const gfxPoint& pt)
|
||||
{
|
||||
Matrix newMatrix = mTransform;
|
||||
ChangeTransform(newMatrix.PreTranslate(Float(pt.x), Float(pt.y)));
|
||||
}
|
||||
|
||||
void
|
||||
gfxContext::Scale(gfxFloat x, gfxFloat y)
|
||||
{
|
||||
|
@ -239,12 +239,6 @@ public:
|
||||
** Transformation Matrix manipulation
|
||||
**/
|
||||
|
||||
/**
|
||||
* Adds a translation to the current matrix. This translation takes place
|
||||
* before the previously set transformations.
|
||||
*/
|
||||
void Translate(const gfxPoint& pt);
|
||||
|
||||
/**
|
||||
* Adds a scale to the current matrix. This scaling takes place before the
|
||||
* previously set transformations.
|
||||
|
@ -3577,8 +3577,9 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMod
|
||||
GetAdjustedSize() / GetFontEntry()->UnitsPerEm();
|
||||
gfxContextMatrixAutoSaveRestore matrixRestore(aContext);
|
||||
|
||||
aContext->Translate(gfxPoint(aPoint.x, aPoint.y));
|
||||
aContext->Scale(devUnitsPerSVGUnit, devUnitsPerSVGUnit);
|
||||
aContext->SetMatrix(
|
||||
aContext->CurrentMatrix().Translate(aPoint.x, aPoint.y).
|
||||
Scale(devUnitsPerSVGUnit, devUnitsPerSVGUnit));
|
||||
|
||||
aContextPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
|
||||
|
||||
|
@ -214,13 +214,13 @@ gfxFontMissingGlyphs::DrawMissingGlyph(gfxContext *aContext,
|
||||
gfxFloat halfGap = HEX_CHAR_GAP / 2.0;
|
||||
gfxFloat top = -(MINIFONT_HEIGHT + halfGap);
|
||||
aContext->SetDeviceColor(currentColor);
|
||||
aContext->Translate(center);
|
||||
// We always want integer scaling, otherwise the "bitmap" glyphs will look
|
||||
// even uglier than usual when zoomed
|
||||
int32_t scale =
|
||||
std::max<int32_t>(1, nsDeviceContext::AppUnitsPerCSSPixel() /
|
||||
aAppUnitsPerDevPixel);
|
||||
aContext->Scale(gfxFloat(scale), gfxFloat(scale));
|
||||
aContext->SetMatrix(
|
||||
aContext->CurrentMatrix().Translate(center).Scale(scale, scale));
|
||||
if (aChar < 0x10000) {
|
||||
if (aRect.Width() >= 2 * (MINIFONT_WIDTH + HEX_CHAR_GAP) &&
|
||||
aRect.Height() >= 2 * MINIFONT_HEIGHT + HEX_CHAR_GAP) {
|
||||
|
@ -271,7 +271,8 @@ gfxWindowsNativeDrawing::PaintToContext()
|
||||
gfxImageFormat::ARGB32);
|
||||
|
||||
mContext->Save();
|
||||
mContext->Translate(mNativeRect.TopLeft());
|
||||
mContext->SetMatrix(
|
||||
mContext->CurrentMatrix().Translate(mNativeRect.TopLeft()));
|
||||
mContext->NewPath();
|
||||
mContext->Rectangle(gfxRect(gfxPoint(0.0, 0.0), mNativeRect.Size()));
|
||||
|
||||
|
@ -4469,8 +4469,9 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
|
||||
// Apply the residual transform if it has been enabled, to ensure that
|
||||
// snapping when we draw into aContext exactly matches the ideal transform.
|
||||
// See above for why this is OK.
|
||||
aContext->Translate(aLayer->GetResidualTranslation() - gfxPoint(offset.x, offset.y));
|
||||
aContext->Scale(userData->mXScale, userData->mYScale);
|
||||
aContext->SetMatrix(
|
||||
aContext->CurrentMatrix().Translate(aLayer->GetResidualTranslation() - gfxPoint(offset.x, offset.y)).
|
||||
Scale(userData->mXScale, userData->mYScale));
|
||||
|
||||
layerBuilder->PaintItems(entry->mItems, *iterRect, aContext, rc,
|
||||
builder, presContext,
|
||||
@ -4481,8 +4482,9 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
|
||||
// Apply the residual transform if it has been enabled, to ensure that
|
||||
// snapping when we draw into aContext exactly matches the ideal transform.
|
||||
// See above for why this is OK.
|
||||
aContext->Translate(aLayer->GetResidualTranslation() - gfxPoint(offset.x, offset.y));
|
||||
aContext->Scale(userData->mXScale, userData->mYScale);
|
||||
aContext->SetMatrix(
|
||||
aContext->CurrentMatrix().Translate(aLayer->GetResidualTranslation() - gfxPoint(offset.x, offset.y)).
|
||||
Scale(userData->mXScale,userData->mYScale));
|
||||
|
||||
layerBuilder->PaintItems(entry->mItems, aRegionToDraw.GetBounds(), aContext, rc,
|
||||
builder, presContext,
|
||||
|
@ -2593,7 +2593,8 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext,
|
||||
gradientStart, gradientEnd, &edgeColor)) {
|
||||
ctx->SetColor(edgeColor);
|
||||
} else {
|
||||
ctx->Translate(tileRect.TopLeft());
|
||||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Copy().Translate(tileRect.TopLeft()));
|
||||
ctx->SetPattern(gradientPattern);
|
||||
}
|
||||
ctx->Fill();
|
||||
|
@ -4785,12 +4785,13 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
|
||||
}
|
||||
}
|
||||
|
||||
aThebesContext->Translate(gfxPoint(-nsPresContext::AppUnitsToFloatCSSPixels(aRect.x),
|
||||
-nsPresContext::AppUnitsToFloatCSSPixels(aRect.y)));
|
||||
|
||||
nsDeviceContext* devCtx = mPresContext->DeviceContext();
|
||||
|
||||
gfxPoint offset(-nsPresContext::AppUnitsToFloatCSSPixels(aRect.x),
|
||||
-nsPresContext::AppUnitsToFloatCSSPixels(aRect.y));
|
||||
gfxFloat scale = gfxFloat(devCtx->AppUnitsPerDevPixel())/nsPresContext::AppUnitsPerCSSPixel();
|
||||
aThebesContext->Scale(scale, scale);
|
||||
aThebesContext->SetMatrix(
|
||||
aThebesContext->CurrentMatrix().Translate(offset).Scale(scale, scale));
|
||||
|
||||
// Since canvas APIs use floats to set up their matrices, we may have
|
||||
// some slight inaccuracy here. Adjust matrix components that are
|
||||
|
@ -293,7 +293,8 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
||||
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));
|
||||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Translate(-destRect.x, -destRect.y));
|
||||
context = new nsRenderingContext();
|
||||
context->Init(aCtx->DeviceContext(), ctx);
|
||||
}
|
||||
|
@ -1641,7 +1641,8 @@ nsObjectFrame::PaintPlugin(nsDisplayListBuilder* aBuilder,
|
||||
ctx->Rectangle(nativeClipRect);
|
||||
ctx->Clip();
|
||||
gfxPoint offset(contentPixels.x, contentPixels.y);
|
||||
ctx->Translate(offset);
|
||||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Translate(offset));
|
||||
|
||||
gfxQuartzNativeDrawing nativeDrawing(ctx, nativeClipRect - offset);
|
||||
|
||||
|
@ -2028,16 +2028,18 @@ nsMathMLChar::ApplyTransforms(gfxContext* aThebesContext,
|
||||
// apply the transforms
|
||||
if (mMirrored) {
|
||||
nsPoint pt = r.TopRight();
|
||||
aThebesContext->
|
||||
Translate(gfxPoint(NSAppUnitsToFloatPixels(pt.x, aAppUnitsPerGfxUnit),
|
||||
NSAppUnitsToFloatPixels(pt.y, aAppUnitsPerGfxUnit)));
|
||||
aThebesContext->Scale(-mScaleX, mScaleY);
|
||||
gfxPoint devPixelOffset(NSAppUnitsToFloatPixels(pt.x, aAppUnitsPerGfxUnit),
|
||||
NSAppUnitsToFloatPixels(pt.y, aAppUnitsPerGfxUnit));
|
||||
aThebesContext->SetMatrix(
|
||||
aThebesContext->CurrentMatrix().Translate(devPixelOffset).
|
||||
Scale(-mScaleX, mScaleY));
|
||||
} else {
|
||||
nsPoint pt = r.TopLeft();
|
||||
aThebesContext->
|
||||
Translate(gfxPoint(NSAppUnitsToFloatPixels(pt.x, aAppUnitsPerGfxUnit),
|
||||
NSAppUnitsToFloatPixels(pt.y, aAppUnitsPerGfxUnit)));
|
||||
aThebesContext->Scale(mScaleX, mScaleY);
|
||||
gfxPoint devPixelOffset(NSAppUnitsToFloatPixels(pt.x, aAppUnitsPerGfxUnit),
|
||||
NSAppUnitsToFloatPixels(pt.y, aAppUnitsPerGfxUnit));
|
||||
aThebesContext->SetMatrix(
|
||||
aThebesContext->CurrentMatrix().Translate(devPixelOffset).
|
||||
Scale(mScaleX, mScaleY));
|
||||
}
|
||||
|
||||
// update the bounding rectangle.
|
||||
|
@ -296,23 +296,17 @@ nsFilterInstance::BuildSourcePaint(SourceInfo *aSource,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(offscreenDT);
|
||||
ctx->Translate(-neededRect.TopLeft());
|
||||
|
||||
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
|
||||
tmpCtx->Init(mTargetFrame->PresContext()->DeviceContext(), ctx);
|
||||
|
||||
gfxMatrix deviceToFilterSpace = GetFilterSpaceToDeviceSpaceTransform();
|
||||
if (!deviceToFilterSpace.Invert()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
gfxContext *gfx = tmpCtx->ThebesContext();
|
||||
gfx->Multiply(deviceToFilterSpace);
|
||||
|
||||
gfx->Save();
|
||||
|
||||
if (!mPaintTransform.IsSingular()) {
|
||||
gfx->Multiply(mPaintTransform);
|
||||
nsRefPtr<gfxContext> gfx = new gfxContext(offscreenDT);
|
||||
gfx->Save();
|
||||
gfx->Multiply(mPaintTransform *
|
||||
deviceToFilterSpace *
|
||||
gfxMatrix::Translation(-neededRect.TopLeft()));
|
||||
gfx->Rectangle(FilterSpaceToUserSpace(neededRect));
|
||||
if ((aSource == &mFillPaint &&
|
||||
nsSVGUtils::SetupCairoFillPaint(mTargetFrame, gfx)) ||
|
||||
@ -320,8 +314,8 @@ nsFilterInstance::BuildSourcePaint(SourceInfo *aSource,
|
||||
nsSVGUtils::SetupCairoStrokePaint(mTargetFrame, gfx))) {
|
||||
gfx->Fill();
|
||||
}
|
||||
gfx->Restore();
|
||||
}
|
||||
gfx->Restore();
|
||||
|
||||
|
||||
aSource->mSourceSurface = offscreenDT->Snapshot();
|
||||
@ -362,12 +356,6 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(offscreenDT);
|
||||
ctx->Translate(-neededRect.TopLeft());
|
||||
|
||||
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
|
||||
tmpCtx->Init(mTargetFrame->PresContext()->DeviceContext(), ctx);
|
||||
|
||||
gfxRect r = FilterSpaceToUserSpace(neededRect);
|
||||
r.RoundOut();
|
||||
nsIntRect dirty;
|
||||
@ -389,7 +377,13 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
|
||||
if (!deviceToFilterSpace.Invert()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
tmpCtx->ThebesContext()->Multiply(deviceToFilterSpace);
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(offscreenDT);
|
||||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Translate(-neededRect.TopLeft()).
|
||||
PreMultiply(deviceToFilterSpace));
|
||||
|
||||
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
|
||||
tmpCtx->Init(mTargetFrame->PresContext()->DeviceContext(), ctx);
|
||||
mPaintCallback->Paint(tmpCtx, mTargetFrame, mPaintTransform, &dirty);
|
||||
|
||||
mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();
|
||||
|
@ -1857,9 +1857,9 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsRefPtr<gfxContext> context = new gfxContext(dt);
|
||||
gfxPoint pt(0, 0);
|
||||
context->Translate(pt);
|
||||
context->Scale(scale * bufW / srcW, scale * bufH / srcH);
|
||||
context->SetMatrix(
|
||||
context->CurrentMatrix().Scale(scale * bufW / srcW,
|
||||
scale * bufH / srcH));
|
||||
rv = presShell->RenderDocument(r, renderDocFlags, bgColor, context);
|
||||
if (is24bit) {
|
||||
gfxUtils::ConvertBGRAtoRGBA(data, stride * bufH);
|
||||
|
Loading…
Reference in New Issue
Block a user