mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1246756 - part 1 - fix moz2d Skia usage for Skia m49 update. r=jrmuizel
This commit is contained in:
parent
a921af3367
commit
644dbf50ee
@ -440,17 +440,12 @@ DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface *aSurface,
|
||||
shadowPaint.setImageFilter(blurFilter.get());
|
||||
shadowPaint.setColorFilter(colorFilter.get());
|
||||
|
||||
// drawBitmap implicitly calls saveLayer with a src-over xfer mode if given
|
||||
// an image filter, whereas the supplied xfer mode gets used to render into
|
||||
// the layer, which is the wrong order. We instead must use drawSprite which
|
||||
// applies the image filter directly to the bitmap without rendering it first,
|
||||
// then uses the xfer mode to composite it.
|
||||
IntPoint shadowDest = RoundedToInt(aDest + aOffset);
|
||||
mCanvas->drawSprite(bitmap, shadowDest.x, shadowDest.y, &shadowPaint);
|
||||
mCanvas->drawBitmap(bitmap, shadowDest.x, shadowDest.y, &shadowPaint);
|
||||
|
||||
// Composite the original image after the shadow
|
||||
IntPoint dest = RoundedToInt(aDest);
|
||||
mCanvas->drawSprite(bitmap, dest.x, dest.y, &paint);
|
||||
mCanvas->drawBitmap(bitmap, dest.x, dest.y, &paint);
|
||||
|
||||
mCanvas->restore();
|
||||
}
|
||||
@ -666,8 +661,8 @@ DrawTargetSkia::MaskSurface(const Pattern &aSource,
|
||||
|
||||
if (aOffset != Point(0, 0)) {
|
||||
SkMatrix transform;
|
||||
transform.setTranslate(SkFloatToScalar(-aOffset.x), SkFloatToScalar(-aOffset.y));
|
||||
SkShader* matrixShader = SkShader::CreateLocalMatrixShader(paint.mPaint.getShader(), transform);
|
||||
transform.setTranslate(PointToSkPoint(-aOffset));
|
||||
SkShader* matrixShader = paint.mPaint.getShader()->newWithLocalMatrix(transform);
|
||||
SkSafeUnref(paint.mPaint.setShader(matrixShader));
|
||||
}
|
||||
|
||||
@ -1004,6 +999,40 @@ DrawTargetSkia::PopClip()
|
||||
mCanvas->restore();
|
||||
}
|
||||
|
||||
// Image filter that just passes the source through to the result unmodified.
|
||||
class CopyLayerImageFilter : public SkImageFilter
|
||||
{
|
||||
public:
|
||||
CopyLayerImageFilter()
|
||||
: SkImageFilter(0, nullptr)
|
||||
{}
|
||||
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||
SkBitmap* result, SkIPoint* offset) const override {
|
||||
*result = src;
|
||||
offset->set(0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(CopyLayerImageFilter)
|
||||
};
|
||||
|
||||
SkFlattenable*
|
||||
CopyLayerImageFilter::CreateProc(SkReadBuffer& buffer)
|
||||
{
|
||||
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
|
||||
return new CopyLayerImageFilter;
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void
|
||||
CopyLayerImageFilter::toString(SkString* str) const
|
||||
{
|
||||
str->append("CopyLayerImageFilter: ()");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
DrawTargetSkia::PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
|
||||
const Matrix& aMaskTransform, const IntRect& aBounds,
|
||||
@ -1019,35 +1048,15 @@ DrawTargetSkia::PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
|
||||
paint.setAlpha(aMask ? 0 : ColorFloatToByte(aOpacity));
|
||||
|
||||
SkRect bounds = IntRectToSkRect(aBounds);
|
||||
SkRect* boundsPtr = aBounds.IsEmpty() ? nullptr : &bounds;
|
||||
|
||||
// TODO: Replace this with SaveLayerFlags when available in Skia update (m49+)
|
||||
SkCanvas::SaveFlags saveFlags =
|
||||
aOpaque ?
|
||||
SkCanvas::SaveFlags(SkCanvas::kARGB_ClipLayer_SaveFlag & ~SkCanvas::kHasAlphaLayer_SaveFlag) :
|
||||
SkCanvas::kARGB_ClipLayer_SaveFlag;
|
||||
SkAutoTUnref<SkImageFilter> backdrop(aCopyBackground ? new CopyLayerImageFilter : nullptr);
|
||||
|
||||
if (aCopyBackground) {
|
||||
// Get a reference to the background before we save the layer.
|
||||
SkAutoTUnref<SkBaseDevice> bgDevice(SkSafeRef(mCanvas->getTopDevice()));
|
||||
SkIPoint bgOrigin = bgDevice->getOrigin();
|
||||
SkBitmap bgBitmap = bgDevice->accessBitmap(false);
|
||||
SkCanvas::SaveLayerRec saveRec(aBounds.IsEmpty() ? nullptr : &bounds,
|
||||
&paint,
|
||||
backdrop.get(),
|
||||
aOpaque ? SkCanvas::kIsOpaque_SaveLayerFlag : 0);
|
||||
|
||||
mCanvas->saveLayer(boundsPtr, &paint, saveFlags);
|
||||
|
||||
// Draw the background into the layer.
|
||||
SkPaint bgPaint;
|
||||
if (!bgBitmap.isOpaque()) {
|
||||
bgPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
}
|
||||
|
||||
mCanvas->save();
|
||||
mCanvas->resetMatrix();
|
||||
mCanvas->drawBitmap(bgBitmap, bgOrigin.x(), bgOrigin.y(), &bgPaint);
|
||||
mCanvas->restore();
|
||||
} else {
|
||||
mCanvas->saveLayer(boundsPtr, &paint, saveFlags);
|
||||
}
|
||||
mCanvas->saveLayer(saveRec);
|
||||
|
||||
SetPermitSubpixelAA(aOpaque);
|
||||
}
|
||||
|
@ -167,9 +167,9 @@ StrokeOptionsToPaint(SkPaint& aPaint, const StrokeOptions &aOptions)
|
||||
pattern[i] = SkFloatToScalar(aOptions.mDashPattern[i % aOptions.mDashLength]);
|
||||
}
|
||||
|
||||
SkDashPathEffect* dash = SkDashPathEffect::Create(&pattern.front(),
|
||||
dashCount,
|
||||
SkFloatToScalar(aOptions.mDashOffset));
|
||||
SkPathEffect* dash = SkDashPathEffect::Create(&pattern.front(),
|
||||
dashCount,
|
||||
SkFloatToScalar(aOptions.mDashOffset));
|
||||
SkSafeUnref(aPaint.setPathEffect(dash));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user