Bug 1335139 - part 2 - implement StrokeGlyphs for DrawTargetSkia. r=mchang

MozReview-Commit-ID: AupfyGu1nwa
This commit is contained in:
Lee Salzman 2017-02-12 09:24:44 -05:00
parent ec204ce670
commit 7c93ca2486
4 changed files with 65 additions and 22 deletions

View File

@ -20,8 +20,8 @@ fuzzy-if(azureSkia,1,1500) == global-alpha.html global-alpha-ref.html
== units-off-screen.html ref.html
fuzzy(1,700) == fillText-with-filter-opacity-1.html fillText-with-filter-opacity-1-ref.html
fuzzy(1,302) == fillText-with-filter-opacity-2.html fillText-with-filter-opacity-2-ref.html
fuzzy(1,400) == strokeText-with-filter-grayscale-1.html strokeText-with-filter-grayscale-1-ref.html
fuzzy(1,400) == strokeText-with-filter-grayscale-2.html strokeText-with-filter-grayscale-2-ref.html
fuzzy(1,600) == strokeText-with-filter-grayscale-1.html strokeText-with-filter-grayscale-1-ref.html
fuzzy(1,600) == strokeText-with-filter-grayscale-2.html strokeText-with-filter-grayscale-2-ref.html
!= fillText-with-shadow-1.html fillText-without-shadow-1-ref.html
!= fillText-with-shadow-2.html fillText-without-shadow-2-ref.html
fuzzy(1,400) == fillText-with-filter-grayscale-1.html fillText-with-filter-grayscale-1-ref.html

View File

@ -1334,11 +1334,12 @@ CanDrawFont(ScaledFont* aFont)
}
void
DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
const GlyphBuffer &aBuffer,
const Pattern &aPattern,
const DrawOptions &aOptions,
const GlyphRenderingOptions *aRenderingOptions)
DrawTargetSkia::DrawGlyphs(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const StrokeOptions* aStrokeOptions,
const DrawOptions& aOptions,
const GlyphRenderingOptions* aRenderingOptions)
{
if (!CanDrawFont(aFont)) {
return;
@ -1347,7 +1348,8 @@ DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
MarkChanged();
#ifdef MOZ_WIDGET_COCOA
if (ShouldUseCGToFillGlyphs(aRenderingOptions, aPattern)) {
if (!aStrokeOptions &&
ShouldUseCGToFillGlyphs(aRenderingOptions, aPattern)) {
if (FillGlyphsWithCG(aFont, aBuffer, aPattern, aOptions, aRenderingOptions)) {
return;
}
@ -1361,6 +1363,11 @@ DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
}
AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
if (aStrokeOptions &&
!StrokeOptionsToPaint(paint.mPaint, *aStrokeOptions)) {
return;
}
AntialiasMode aaMode = aFont->GetDefaultAAMode();
if (aOptions.mAntialiasMode != AntialiasMode::DEFAULT) {
aaMode = aOptions.mAntialiasMode;
@ -1448,6 +1455,27 @@ DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
mCanvas->drawPosText(&indices.front(), aBuffer.mNumGlyphs*2, &offsets.front(), paint.mPaint);
}
void
DrawTargetSkia::FillGlyphs(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const DrawOptions& aOptions,
const GlyphRenderingOptions* aRenderingOptions)
{
DrawGlyphs(aFont, aBuffer, aPattern, nullptr, aOptions, aRenderingOptions);
}
void
DrawTargetSkia::StrokeGlyphs(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions,
const GlyphRenderingOptions* aRenderingOptions)
{
DrawGlyphs(aFont, aBuffer, aPattern, &aStrokeOptions, aOptions, aRenderingOptions);
}
void
DrawTargetSkia::Mask(const Pattern &aSource,
const Pattern &aMask,

View File

@ -24,6 +24,7 @@ namespace mozilla {
namespace gfx {
class SourceSurfaceSkia;
class BorrowedCGContext;
class DrawTargetSkia : public DrawTarget
{
@ -79,21 +80,18 @@ public:
virtual void Fill(const Path *aPath,
const Pattern &aPattern,
const DrawOptions &aOptions = DrawOptions()) override;
#ifdef MOZ_WIDGET_COCOA
CGContextRef BorrowCGContext(const DrawOptions &aOptions);
void ReturnCGContext(CGContextRef);
bool FillGlyphsWithCG(ScaledFont *aFont,
const GlyphBuffer &aBuffer,
const Pattern &aPattern,
const DrawOptions &aOptions = DrawOptions(),
const GlyphRenderingOptions *aRenderingOptions = nullptr);
#endif
virtual void FillGlyphs(ScaledFont *aFont,
const GlyphBuffer &aBuffer,
const Pattern &aPattern,
const DrawOptions &aOptions = DrawOptions(),
const GlyphRenderingOptions *aRenderingOptions = nullptr) override;
virtual void StrokeGlyphs(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions = StrokeOptions(),
const DrawOptions& aOptions = DrawOptions(),
const GlyphRenderingOptions* aRenderingOptions = nullptr) override;
virtual void Mask(const Pattern &aSource,
const Pattern &aMask,
const DrawOptions &aOptions = DrawOptions()) override;
@ -168,6 +166,13 @@ private:
bool ShouldLCDRenderText(FontType aFontType, AntialiasMode aAntialiasMode);
void DrawGlyphs(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const StrokeOptions* aStrokeOptions = nullptr,
const DrawOptions& aOptions = DrawOptions(),
const GlyphRenderingOptions* aRenderingOptions = nullptr);
bool UsingSkiaGPU() const;
struct PushedLayer
@ -204,6 +209,16 @@ private:
SourceSurfaceSkia* mSnapshot;
#ifdef MOZ_WIDGET_COCOA
friend class BorrowedCGContext;
CGContextRef BorrowCGContext(const DrawOptions &aOptions);
void ReturnCGContext(CGContextRef);
bool FillGlyphsWithCG(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const DrawOptions& aOptions = DrawOptions(),
const GlyphRenderingOptions* aRenderingOptions = nullptr);
CGContextRef mCG;
CGColorSpaceRef mColorSpace;
uint8_t* mCanvasData;

View File

@ -2,8 +2,8 @@
# fuzzy is needed here for platform dependent backends
default-preferences pref(layout.css.prefixes.webkit,true)
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) == webkit-text-stroke-property-001.html webkit-text-stroke-property-001-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) == webkit-text-stroke-property-002.html webkit-text-stroke-property-002-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) == webkit-text-stroke-property-003.html webkit-text-stroke-property-003-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) == webkit-text-stroke-property-004.html webkit-text-stroke-property-004-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) == webkit-text-stroke-property-005.html webkit-text-stroke-property-005-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent) == webkit-text-stroke-property-001.html webkit-text-stroke-property-001-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent) == webkit-text-stroke-property-002.html webkit-text-stroke-property-002-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent) == webkit-text-stroke-property-003.html webkit-text-stroke-property-003-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent) == webkit-text-stroke-property-004.html webkit-text-stroke-property-004-ref.html
fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent) == webkit-text-stroke-property-005.html webkit-text-stroke-property-005-ref.html