aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-10-20 16:06:52 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-20 22:00:28 +0000
commit7cfd46aebda7b7d2b88e73621ed0d1be7244c2ca (patch)
treeace6ecfe18447644e928f6ef204ab39f2767f24f /src
parent050ffa9ad5d2bafc935c0a48ce3caed47446be12 (diff)
SkScalerContext to use smart pointers.
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot;master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN-Trybot Change-Id: I27a714388b8ded7dfc968e322b0a587205f575f1 Reviewed-on: https://skia-review.googlesource.com/3731 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGlyphCache.cpp17
-rw-r--r--src/core/SkGlyphCache.h7
-rw-r--r--src/core/SkScalerContext.cpp21
-rw-r--r--src/core/SkScalerContext.h7
-rw-r--r--src/core/SkTypeface.cpp17
-rw-r--r--src/fonts/SkGScalerContext.cpp30
-rw-r--r--src/fonts/SkRandomScalerContext.cpp36
-rw-r--r--src/fonts/SkTestScalerContext.cpp41
-rw-r--r--src/fonts/SkTestScalerContext.h11
-rw-r--r--src/gpu/GrPathRendering.cpp2
-rw-r--r--src/ports/SkFontHost_FreeType.cpp19
-rw-r--r--src/ports/SkFontHost_FreeType_common.h16
-rw-r--r--src/ports/SkFontHost_mac.cpp10
-rw-r--r--src/ports/SkFontHost_win.cpp18
-rw-r--r--src/ports/SkScalerContext_win_dw.cpp60
-rw-r--r--src/ports/SkScalerContext_win_dw.h9
-rw-r--r--src/ports/SkTypeface_win_dw.cpp2
17 files changed, 162 insertions, 161 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index d9c21cac2f..7526bbf256 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -38,13 +38,12 @@ static SkGlyphCache_Globals& get_globals() {
#define kMinGlyphImageSize (16*2)
#define kMinAllocAmount ((sizeof(SkGlyph) + kMinGlyphImageSize) * kMinGlyphCount)
-SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc, SkScalerContext* ctx)
+SkGlyphCache::SkGlyphCache(const SkDescriptor* desc, std::unique_ptr<SkScalerContext> ctx)
: fDesc(desc->copy())
- , fScalerContext(ctx)
+ , fScalerContext(std::move(ctx))
, fGlyphAlloc(kMinAllocAmount) {
- SkASSERT(typeface);
SkASSERT(desc);
- SkASSERT(ctx);
+ SkASSERT(fScalerContext);
fPrev = fNext = nullptr;
@@ -54,11 +53,11 @@ SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc, SkSca
}
SkGlyphCache::~SkGlyphCache() {
- fGlyphMap.foreach ([](SkGlyph* g) {
+ fGlyphMap.foreach([](SkGlyph* g) {
if (g->fPathData) {
delete g->fPathData->fPath;
- } } );
- delete fScalerContext;
+ }
+ });
}
SkGlyphCache::CharGlyphRec* SkGlyphCache::getCharGlyphRec(PackedUnicharID packedUnicharID) {
@@ -528,13 +527,13 @@ SkGlyphCache* SkGlyphCache::VisitCache(SkTypeface* typeface,
{
// pass true the first time, to notice if the scalercontext failed,
// so we can try the purge.
- SkScalerContext* ctx = typeface->createScalerContext(effects, desc, true);
+ std::unique_ptr<SkScalerContext> ctx = typeface->createScalerContext(effects, desc, true);
if (!ctx) {
get_globals().purgeAll();
ctx = typeface->createScalerContext(effects, desc, false);
SkASSERT(ctx);
}
- cache = new SkGlyphCache(typeface, desc, ctx);
+ cache = new SkGlyphCache(desc, std::move(ctx));
}
AutoValidate av(cache);
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h
index e18b9923e4..863b2c82fb 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -110,7 +110,7 @@ public:
void dump() const;
- SkScalerContext* getScalerContext() const { return fScalerContext; }
+ SkScalerContext* getScalerContext() const { return fScalerContext.get(); }
/** Find a matching cache entry, and call proc() with it. If none is found create a new one.
If the proc() returns true, detach the cache and return it, otherwise leave it and return
@@ -195,8 +195,7 @@ private:
PackedGlyphID fPackedGlyphID;
};
- // SkGlyphCache takes ownership of the scalercontext.
- SkGlyphCache(SkTypeface*, const SkDescriptor*, SkScalerContext*);
+ SkGlyphCache(const SkDescriptor*, std::unique_ptr<SkScalerContext>);
~SkGlyphCache();
// Return the SkGlyph* associated with MakeID. The id parameter is the
@@ -233,7 +232,7 @@ private:
SkGlyphCache* fNext;
SkGlyphCache* fPrev;
const std::unique_ptr<SkDescriptor> fDesc;
- SkScalerContext* const fScalerContext;
+ const std::unique_ptr<SkScalerContext> fScalerContext;
SkPaint::FontMetrics fFontMetrics;
// Map from a combined GlyphID and sub-pixel position to a SkGlyph.
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index ecac82a34c..581e102034 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -12,6 +12,7 @@
#include "SkDescriptor.h"
#include "SkDraw.h"
#include "SkGlyph.h"
+#include "SkMakeUnique.h"
#include "SkMaskFilter.h"
#include "SkMaskGamma.h"
#include "SkMatrix22.h"
@@ -62,11 +63,11 @@ void SkGlyph::zeroMetrics() {
#define DUMP_RECx
#endif
-SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkScalerContextEffects& effects,
+SkScalerContext::SkScalerContext(sk_sp<SkTypeface> typeface, const SkScalerContextEffects& effects,
const SkDescriptor* desc)
: fRec(*static_cast<const Rec*>(desc->findEntry(kRec_SkDescriptorTag, nullptr)))
- , fTypeface(sk_ref_sp(typeface))
+ , fTypeface(std::move(typeface))
, fPathEffect(sk_ref_sp(effects.fPathEffect))
, fMaskFilter(sk_ref_sp(effects.fMaskFilter))
, fRasterizer(sk_ref_sp(effects.fRasterizer))
@@ -831,9 +832,9 @@ SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText() {
class SkScalerContext_Empty : public SkScalerContext {
public:
- SkScalerContext_Empty(SkTypeface* typeface, const SkScalerContextEffects& effects,
+ SkScalerContext_Empty(sk_sp<SkTypeface> typeface, const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : SkScalerContext(typeface, effects, desc) {}
+ : SkScalerContext(std::move(typeface), effects, desc) {}
protected:
unsigned generateGlyphCount() override {
@@ -859,13 +860,13 @@ protected:
extern SkScalerContext* SkCreateColorScalerContext(const SkDescriptor* desc);
-SkScalerContext* SkTypeface::createScalerContext(const SkScalerContextEffects& effects,
- const SkDescriptor* desc,
- bool allowFailure) const {
- SkScalerContext* c = this->onCreateScalerContext(effects, desc);
-
+std::unique_ptr<SkScalerContext> SkTypeface::createScalerContext(
+ const SkScalerContextEffects& effects, const SkDescriptor* desc, bool allowFailure) const
+{
+ std::unique_ptr<SkScalerContext> c(this->onCreateScalerContext(effects, desc));
if (!c && !allowFailure) {
- c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), effects, desc);
+ c = skstd::make_unique<SkScalerContext_Empty>(sk_ref_sp(const_cast<SkTypeface*>(this)),
+ effects, desc);
}
return c;
}
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index 48ec0624cf..61f94ad006 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -211,7 +211,7 @@ public:
kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag,
};
- SkScalerContext(SkTypeface*, const SkScalerContextEffects&, const SkDescriptor*);
+ SkScalerContext(sk_sp<SkTypeface>, const SkScalerContextEffects&, const SkDescriptor*);
virtual ~SkScalerContext();
SkTypeface* getTypeface() const { return fTypeface.get(); }
@@ -353,11 +353,6 @@ private:
void internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
SkPath* devPath, SkMatrix* fillToDevMatrix);
- // returns the right context from our link-list for this char. If no match
- // is found it returns nullptr. If a match is found then the glyphID param is
- // set to the glyphID that maps to the provided char.
- SkScalerContext* getContextFromChar(SkUnichar uni, uint16_t* glyphID);
-
// SkMaskGamma::PreBlend converts linear masks to gamma correcting masks.
protected:
// Visible to subclasses so that generateImage can apply the pre-blend directly.
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 8747c6e54a..e1cd2b5408 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -346,13 +346,14 @@ bool SkTypeface::onComputeBounds(SkRect* bounds) const {
desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
SkScalerContextEffects noeffects;
- SkAutoTDelete<SkScalerContext> ctx(this->createScalerContext(noeffects, desc, true));
- if (ctx.get()) {
- SkPaint::FontMetrics fm;
- ctx->getFontMetrics(&fm);
- bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize,
- fm.fXMax * invTextSize, fm.fBottom * invTextSize);
- return true;
+ std::unique_ptr<SkScalerContext> ctx = this->createScalerContext(noeffects, desc, true);
+ if (!ctx) {
+ return false;
}
- return false;
+
+ SkPaint::FontMetrics fm;
+ ctx->getFontMetrics(&fm);
+ bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize,
+ fm.fXMax * invTextSize, fm.fBottom * invTextSize);
+ return true;
}
diff --git a/src/fonts/SkGScalerContext.cpp b/src/fonts/SkGScalerContext.cpp
index 5a439b7eb5..53d385437e 100644
--- a/src/fonts/SkGScalerContext.cpp
+++ b/src/fonts/SkGScalerContext.cpp
@@ -5,26 +5,26 @@
* found in the LICENSE file.
*/
+#include "SkCanvas.h"
#include "SkDescriptor.h"
#include "SkGScalerContext.h"
#include "SkGlyph.h"
#include "SkPath.h"
-#include "SkCanvas.h"
+#include "SkMakeUnique.h"
#define STD_SIZE 1
class SkGScalerContext : public SkScalerContext {
public:
- SkGScalerContext(SkGTypeface* face, const SkScalerContextEffects& effects,
+ SkGScalerContext(sk_sp<SkGTypeface> face, const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : SkScalerContext(face, effects, desc)
- , fFace(face)
+ : SkScalerContext(std::move(face), effects, desc)
{
-
+
size_t descSize = SkDescriptor::ComputeOverhead(1) + sizeof(SkScalerContext::Rec);
SkAutoDescriptor ad(descSize);
SkDescriptor* newDesc = ad.getDesc();
-
+
newDesc->init();
void* entry = newDesc->addEntry(kRec_SkDescriptorTag,
sizeof(SkScalerContext::Rec), &fRec);
@@ -38,15 +38,16 @@ public:
}
SkASSERT(descSize == newDesc->getLength());
newDesc->computeChecksum();
-
- fProxy = face->proxy()->createScalerContext(effects, newDesc);
-
+
+ fProxy = this->getGTypeface()->proxy()->createScalerContext(effects, newDesc);
+
fRec.getSingleMatrix(&fMatrix);
fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE);
}
- virtual ~SkGScalerContext() { delete fProxy; }
protected:
+ SkGTypeface* getGTypeface() { return static_cast<SkGTypeface*>(this->getTypeface()); }
+
unsigned generateGlyphCount() override;
uint16_t generateCharToGlyph(SkUnichar) override;
void generateAdvance(SkGlyph*) override;
@@ -56,8 +57,7 @@ protected:
void generateFontMetrics(SkPaint::FontMetrics*) override;
private:
- SkGTypeface* fFace;
- SkScalerContext* fProxy;
+ std::unique_ptr<SkScalerContext> fProxy;
SkMatrix fMatrix;
};
@@ -93,7 +93,7 @@ void SkGScalerContext::generateMetrics(SkGlyph* glyph) {
path.transform(fMatrix);
SkRect storage;
- const SkPaint& paint = fFace->paint();
+ const SkPaint& paint = this->getGTypeface()->paint();
const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(),
&storage,
SkPaint::kFill_Style);
@@ -120,7 +120,7 @@ void SkGScalerContext::generateImage(const SkGlyph& glyph) {
canvas.translate(-SkIntToScalar(glyph.fLeft),
-SkIntToScalar(glyph.fTop));
canvas.concat(fMatrix);
- canvas.drawPath(path, fFace->paint());
+ canvas.drawPath(path, this->getGTypeface()->paint());
} else {
fProxy->getImage(glyph);
}
@@ -159,7 +159,7 @@ SkGTypeface::SkGTypeface(sk_sp<SkTypeface> proxy, const SkPaint& paint)
SkScalerContext* SkGTypeface::onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const {
- return new SkGScalerContext(const_cast<SkGTypeface*>(this), effects, desc);
+ return new SkGScalerContext(sk_ref_sp(const_cast<SkGTypeface*>(this)), effects, desc);
}
void SkGTypeface::onFilterRec(SkScalerContextRec* rec) const {
diff --git a/src/fonts/SkRandomScalerContext.cpp b/src/fonts/SkRandomScalerContext.cpp
index c9cb87c03c..96a2619876 100644
--- a/src/fonts/SkRandomScalerContext.cpp
+++ b/src/fonts/SkRandomScalerContext.cpp
@@ -5,17 +5,19 @@
* found in the LICENSE file.
*/
-#include "SkRandomScalerContext.h"
+#include "SkCanvas.h"
#include "SkGlyph.h"
+#include "SkMakeUnique.h"
#include "SkPath.h"
-#include "SkCanvas.h"
+#include "SkRandomScalerContext.h"
#include "SkRasterizer.h"
+class SkDescriptor;
+
class SkRandomScalerContext : public SkScalerContext {
public:
- SkRandomScalerContext(SkRandomTypeface*, const SkScalerContextEffects&,
+ SkRandomScalerContext(sk_sp<SkRandomTypeface>, const SkScalerContextEffects&,
const SkDescriptor*, bool fFakeIt);
- virtual ~SkRandomScalerContext();
protected:
unsigned generateGlyphCount() override;
@@ -27,27 +29,22 @@ protected:
void generateFontMetrics(SkPaint::FontMetrics*) override;
private:
- SkRandomTypeface* fFace;
- SkScalerContext* fProxy;
+ SkRandomTypeface* getRandomTypeface() const {
+ return static_cast<SkRandomTypeface*>(this->getTypeface());
+ }
+ std::unique_ptr<SkScalerContext> fProxy;
bool fFakeIt;
};
-#define STD_SIZE 1
-
-#include "SkDescriptor.h"
-
-SkRandomScalerContext::SkRandomScalerContext(SkRandomTypeface* face,
+SkRandomScalerContext::SkRandomScalerContext(sk_sp<SkRandomTypeface> face,
const SkScalerContextEffects& effects,
const SkDescriptor* desc,
bool fakeIt)
- : SkScalerContext(face, effects, desc)
- , fFace(face)
+ : SkScalerContext(std::move(face), effects, desc)
, fFakeIt(fakeIt) {
- fProxy = face->proxy()->createScalerContext(effects, desc);
+ fProxy = this->getRandomTypeface()->proxy()->createScalerContext(effects, desc);
}
-SkRandomScalerContext::~SkRandomScalerContext() { delete fProxy; }
-
unsigned SkRandomScalerContext::generateGlyphCount() {
return fProxy->getGlyphCount();
}
@@ -90,7 +87,7 @@ void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) {
fProxy->getPath(*glyph, &path);
SkRect storage;
- const SkPaint& paint = fFace->paint();
+ const SkPaint& paint = this->getRandomTypeface()->paint();
const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(),
&storage,
SkPaint::kFill_Style);
@@ -167,7 +164,7 @@ void SkRandomScalerContext::generateImage(const SkGlyph& glyph) {
SkCanvas canvas(bm);
canvas.translate(-SkIntToScalar(glyph.fLeft),
-SkIntToScalar(glyph.fTop));
- canvas.drawPath(path, fFace->paint());
+ canvas.drawPath(path, this->getRandomTypeface()->paint());
} else {
fProxy->forceGenerateImageFromPath();
fProxy->getImage(glyph);
@@ -198,7 +195,8 @@ SkRandomTypeface::SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint& paint
SkScalerContext* SkRandomTypeface::onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const {
- return new SkRandomScalerContext(const_cast<SkRandomTypeface*>(this), effects, desc, fFakeIt);
+ return new SkRandomScalerContext(sk_ref_sp(const_cast<SkRandomTypeface*>(this)),
+ effects, desc, fFakeIt);
}
void SkRandomTypeface::onFilterRec(SkScalerContextRec* rec) const {
diff --git a/src/fonts/SkTestScalerContext.cpp b/src/fonts/SkTestScalerContext.cpp
index f7678a2ca4..7a97ca8bba 100644
--- a/src/fonts/SkTestScalerContext.cpp
+++ b/src/fonts/SkTestScalerContext.cpp
@@ -11,8 +11,8 @@
#include "SkDescriptor.h"
#include "SkFontDescriptor.h"
#include "SkGlyph.h"
+#include "SkMakeUnique.h"
#include "SkMask.h"
-// #include "SkOTUtils.h"
#include "SkScalerContext.h"
#include "SkTestScalerContext.h"
#include "SkTypefaceCache.h"
@@ -116,9 +116,9 @@ void SkTestFont::init(const SkScalar* pts, const unsigned char* verbs) {
}
}
-SkTestTypeface::SkTestTypeface(SkTestFont* testFont, const SkFontStyle& style)
+SkTestTypeface::SkTestTypeface(sk_sp<SkTestFont> testFont, const SkFontStyle& style)
: SkTypeface(style, false)
- , fTestFont(testFont) {
+ , fTestFont(std::move(testFont)) {
}
void SkTestTypeface::getAdvance(SkGlyph* glyph) {
@@ -194,31 +194,32 @@ SkASSERT(0); // incomplete
class SkTestScalerContext : public SkScalerContext {
public:
- SkTestScalerContext(SkTestTypeface* face, const SkScalerContextEffects& effects,
+ SkTestScalerContext(sk_sp<SkTestTypeface> face, const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : SkScalerContext(face, effects, desc)
- , fFace(face)
+ : SkScalerContext(std::move(face), effects, desc)
{
fRec.getSingleMatrix(&fMatrix);
this->forceGenerateImageFromPath();
}
- virtual ~SkTestScalerContext() {
+protected:
+ SkTestTypeface* getTestTypeface() const {
+ return static_cast<SkTestTypeface*>(this->getTypeface());
}
-protected:
unsigned generateGlyphCount() override {
- return fFace->onCountGlyphs();
+ return this->getTestTypeface()->onCountGlyphs();
}
uint16_t generateCharToGlyph(SkUnichar uni) override {
uint16_t glyph;
- (void) fFace->onCharsToGlyphs((const void *) &uni, SkTypeface::kUTF16_Encoding, &glyph, 1);
+ (void) this->getTestTypeface()->onCharsToGlyphs((const void *) &uni,
+ SkTypeface::kUTF16_Encoding, &glyph, 1);
return glyph;
}
void generateAdvance(SkGlyph* glyph) override {
- fFace->getAdvance(glyph);
+ this->getTestTypeface()->getAdvance(glyph);
const SkVector advance = fMatrix.mapXY(SkFloatToScalar(glyph->fAdvanceX),
SkFloatToScalar(glyph->fAdvanceY));
@@ -227,7 +228,7 @@ protected:
}
void generateMetrics(SkGlyph* glyph) override {
- fFace->getMetrics(glyph);
+ this->getTestTypeface()->getMetrics(glyph);
const SkVector advance = fMatrix.mapXY(SkFloatToScalar(glyph->fAdvanceX),
SkFloatToScalar(glyph->fAdvanceY));
@@ -235,7 +236,7 @@ protected:
glyph->fAdvanceY = SkScalarToFloat(advance.fY);
SkPath path;
- fFace->getPath(*glyph, &path);
+ this->getTestTypeface()->getPath(*glyph, &path);
path.transform(fMatrix);
SkRect storage;
@@ -253,7 +254,7 @@ protected:
void generateImage(const SkGlyph& glyph) override {
SkPath path;
- fFace->getPath(glyph, &path);
+ this->getTestTypeface()->getPath(glyph, &path);
SkBitmap bm;
bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight),
@@ -270,12 +271,12 @@ protected:
}
void generatePath(const SkGlyph& glyph, SkPath* path) override {
- fFace->getPath(glyph, path);
+ this->getTestTypeface()->getPath(glyph, path);
path->transform(fMatrix);
}
void generateFontMetrics(SkPaint::FontMetrics* metrics) override {
- fFace->getFontMetrics(metrics);
+ this->getTestTypeface()->getFontMetrics(metrics);
if (metrics) {
SkScalar scale = fMatrix.getScaleY();
metrics->fTop = SkScalarMul(metrics->fTop, scale);
@@ -291,11 +292,11 @@ protected:
}
private:
- SkTestTypeface* fFace;
SkMatrix fMatrix;
};
-SkScalerContext* SkTestTypeface::onCreateScalerContext(const SkScalerContextEffects& effects,
- const SkDescriptor* desc) const {
- return new SkTestScalerContext(const_cast<SkTestTypeface*>(this), effects, desc);
+SkScalerContext* SkTestTypeface::onCreateScalerContext(
+ const SkScalerContextEffects& effects, const SkDescriptor* desc) const
+{
+ return new SkTestScalerContext(sk_ref_sp(const_cast<SkTestTypeface*>(this)), effects, desc);
}
diff --git a/src/fonts/SkTestScalerContext.h b/src/fonts/SkTestScalerContext.h
index a5fa1de90d..90945970fa 100644
--- a/src/fonts/SkTestScalerContext.h
+++ b/src/fonts/SkTestScalerContext.h
@@ -26,13 +26,11 @@ struct SkTestFontData {
const SkPaint::FontMetrics& fMetrics;
const char* fName;
SkTypeface::Style fStyle;
- SkTestFont* fFontCache;
+ sk_sp<SkTestFont> fCachedFont;
};
class SkTestFont : public SkRefCnt {
public:
-
-
SkTestFont(const SkTestFontData& );
virtual ~SkTestFont();
int codeToIndex(SkUnichar charCode) const;
@@ -58,10 +56,7 @@ private:
class SkTestTypeface : public SkTypeface {
public:
- SkTestTypeface(SkTestFont*, const SkFontStyle& style);
- virtual ~SkTestTypeface() {
- SkSafeUnref(fTestFont);
- }
+ SkTestTypeface(sk_sp<SkTestFont>, const SkFontStyle& style);
void getAdvance(SkGlyph* glyph);
void getFontMetrics(SkPaint::FontMetrics* metrics);
void getMetrics(SkGlyph* glyph);
@@ -105,7 +100,7 @@ protected:
return 0;
}
private:
- SkTestFont* fTestFont;
+ sk_sp<SkTestFont> fTestFont;
friend class SkTestScalerContext;
};
diff --git a/src/gpu/GrPathRendering.cpp b/src/gpu/GrPathRendering.cpp
index 5c6b3d3643..933f0fba9f 100644
--- a/src/gpu/GrPathRendering.cpp
+++ b/src/gpu/GrPathRendering.cpp
@@ -68,7 +68,7 @@ public:
bool isEqualTo(const SkDescriptor& desc) const override { return *fDesc == desc; }
#endif
private:
- const SkAutoTDelete<SkScalerContext> fScalerContext;
+ const std::unique_ptr<SkScalerContext> fScalerContext;
#ifdef SK_DEBUG
const std::unique_ptr<SkDescriptor> fDesc;
#endif
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 71ce865f08..8b233ffdf3 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -14,6 +14,7 @@
#include "SkFontDescriptor.h"
#include "SkFontHost_FreeType_common.h"
#include "SkGlyph.h"
+#include "SkMakeUnique.h"
#include "SkMask.h"
#include "SkMaskGamma.h"
#include "SkMatrix22.h"
@@ -179,7 +180,9 @@ static void unref_ft_library() {
class SkScalerContext_FreeType : public SkScalerContext_FreeType_Base {
public:
- SkScalerContext_FreeType(SkTypeface*, const SkScalerContextEffects&, const SkDescriptor* desc);
+ SkScalerContext_FreeType(sk_sp<SkTypeface>,
+ const SkScalerContextEffects&,
+ const SkDescriptor* desc);
virtual ~SkScalerContext_FreeType();
bool success() const {
@@ -612,13 +615,12 @@ static bool isAxisAligned(const SkScalerContext::Rec& rec) {
SkScalerContext* SkTypeface_FreeType::onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const {
- SkScalerContext_FreeType* c =
- new SkScalerContext_FreeType(const_cast<SkTypeface_FreeType*>(this), effects, desc);
+ auto c = skstd::make_unique<SkScalerContext_FreeType>(
+ sk_ref_sp(const_cast<SkTypeface_FreeType*>(this)), effects, desc);
if (!c->success()) {
- delete c;
c = nullptr;
}
- return c;
+ return c.release();
}
void SkTypeface_FreeType::onFilterRec(SkScalerContextRec* rec) const {
@@ -725,10 +727,10 @@ static FT_Int chooseBitmapStrike(FT_Face face, FT_F26Dot6 scaleY) {
return chosenStrikeIndex;
}
-SkScalerContext_FreeType::SkScalerContext_FreeType(SkTypeface* typeface,
+SkScalerContext_FreeType::SkScalerContext_FreeType(sk_sp<SkTypeface> typeface,
const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : SkScalerContext_FreeType_Base(typeface, effects, desc)
+ : SkScalerContext_FreeType_Base(std::move(typeface), effects, desc)
, fFace(nullptr)
, fFTSize(nullptr)
, fStrikeIndex(-1)
@@ -741,7 +743,8 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(SkTypeface* typeface,
// load the font file
using UnrefFTFace = SkFunctionWrapper<void, skstd::remove_pointer_t<FT_Face>, unref_ft_face>;
- std::unique_ptr<skstd::remove_pointer_t<FT_Face>, UnrefFTFace> ftFace(ref_ft_face(typeface));
+ using FT_FaceRef = skstd::remove_pointer_t<FT_Face>;
+ std::unique_ptr<FT_FaceRef, UnrefFTFace> ftFace(ref_ft_face(this->getTypeface()));
if (nullptr == ftFace) {
SkDEBUGF(("Could not create FT_Face.\n"));
return;
diff --git a/src/ports/SkFontHost_FreeType_common.h b/src/ports/SkFontHost_FreeType_common.h
index 21e7748662..867e139c21 100644
--- a/src/ports/SkFontHost_FreeType_common.h
+++ b/src/ports/SkFontHost_FreeType_common.h
@@ -26,9 +26,9 @@ protected:
// This value was chosen by eyeballing the result in Firefox and trying to match it.
static const FT_Pos kBitmapEmboldenStrength = 1 << 6;
- SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkScalerContextEffects& effects,
+ SkScalerContext_FreeType_Base(sk_sp<SkTypeface> typeface, const SkScalerContextEffects& effects,
const SkDescriptor *desc)
- : INHERITED(typeface, effects, desc)
+ : INHERITED(std::move(typeface), effects, desc)
{}
void generateGlyphImage(FT_Face face, const SkGlyph& glyph, const SkMatrix& bitmapTransform);
@@ -80,17 +80,17 @@ protected:
SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
PerGlyphInfo, const uint32_t*, uint32_t) const override;
int onGetUPEM() const override;
- virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count,
- int32_t adjustments[]) const override;
- virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
- int glyphCount) const override;
+ bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count,
+ int32_t adjustments[]) const override;
+ int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
+ int glyphCount) const override;
int onCountGlyphs() const override;
LocalizedStrings* onCreateFamilyNameIterator() const override;
int onGetTableTags(SkFontTableTag tags[]) const override;
- virtual size_t onGetTableData(SkFontTableTag, size_t offset,
- size_t length, void* data) const override;
+ size_t onGetTableData(SkFontTableTag, size_t offset,
+ size_t length, void* data) const override;
private:
typedef SkTypeface INHERITED;
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index b5d9858b5a..6023375152 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -694,7 +694,7 @@ struct GlyphRect {
class SkScalerContext_Mac : public SkScalerContext {
public:
- SkScalerContext_Mac(SkTypeface_Mac*, const SkScalerContextEffects&, const SkDescriptor*);
+ SkScalerContext_Mac(sk_sp<SkTypeface_Mac>, const SkScalerContextEffects&, const SkDescriptor*);
protected:
unsigned generateGlyphCount(void) override;
@@ -802,10 +802,10 @@ static CTFontRef ctfont_create_exact_copy(CTFontRef baseFont, CGFloat textSize,
return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr);
}
-SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface,
+SkScalerContext_Mac::SkScalerContext_Mac(sk_sp<SkTypeface_Mac> typeface,
const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : INHERITED(typeface, effects, desc)
+ : INHERITED(std::move(typeface), effects, desc)
, fFBoundingBoxes()
, fFBoundingBoxesGlyphOffset(0)
, fGeneratedFBoundingBoxes(false)
@@ -815,7 +815,7 @@ SkScalerContext_Mac::SkScalerContext_Mac(SkTypeface_Mac* typeface,
{
AUTO_CG_LOCK();
- CTFontRef ctFont = typeface->fFontRef.get();
+ CTFontRef ctFont = static_cast<SkTypeface_Mac*>(this->getTypeface())->fFontRef.get();
CFIndex numGlyphs = CTFontGetGlyphCount(ctFont);
SkASSERT(numGlyphs >= 1 && numGlyphs <= 0xFFFF);
fGlyphCount = SkToU16(numGlyphs);
@@ -1962,7 +1962,7 @@ size_t SkTypeface_Mac::onGetTableData(SkFontTableTag tag, size_t offset,
SkScalerContext* SkTypeface_Mac::onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const {
- return new SkScalerContext_Mac(const_cast<SkTypeface_Mac*>(this), effects, desc);
+ return new SkScalerContext_Mac(sk_ref_sp(const_cast<SkTypeface_Mac*>(this)), effects, desc);
}
void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const {
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 0e878bee03..380b502a30 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -16,6 +16,7 @@
#include "SkFontDescriptor.h"
#include "SkGlyph.h"
#include "SkHRESULT.h"
+#include "SkMakeUnique.h"
#include "SkMaskGamma.h"
#include "SkMatrix22.h"
#include "SkOTTable_maxp.h"
@@ -530,7 +531,9 @@ const void* HDCOffscreen::draw(const SkGlyph& glyph, bool isBW,
class SkScalerContext_GDI : public SkScalerContext {
public:
- SkScalerContext_GDI(SkTypeface*, const SkScalerContextEffects&, const SkDescriptor* desc);
+ SkScalerContext_GDI(sk_sp<LogFontTypeface>,
+ const SkScalerContextEffects&,
+ const SkDescriptor* desc);
virtual ~SkScalerContext_GDI();
// Returns true if the constructor was able to complete all of its
@@ -600,17 +603,17 @@ static BYTE compute_quality(const SkScalerContext::Rec& rec) {
}
}
-SkScalerContext_GDI::SkScalerContext_GDI(SkTypeface* rawTypeface,
+SkScalerContext_GDI::SkScalerContext_GDI(sk_sp<LogFontTypeface> rawTypeface,
const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : SkScalerContext(rawTypeface, effects, desc)
+ : SkScalerContext(std::move(rawTypeface), effects, desc)
, fDDC(0)
, fSavefont(0)
, fFont(0)
, fSC(0)
, fGlyphCount(-1)
{
- LogFontTypeface* typeface = reinterpret_cast<LogFontTypeface*>(rawTypeface);
+ LogFontTypeface* typeface = static_cast<LogFontTypeface*>(this->getTypeface());
fDDC = ::CreateCompatibleDC(nullptr);
if (!fDDC) {
@@ -2254,13 +2257,12 @@ size_t LogFontTypeface::onGetTableData(SkFontTableTag tag, size_t offset,
SkScalerContext* LogFontTypeface::onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const {
- SkScalerContext_GDI* ctx = new SkScalerContext_GDI(const_cast<LogFontTypeface*>(this),
- effects, desc);
+ auto ctx = skstd::make_unique<SkScalerContext_GDI>(
+ sk_ref_sp(const_cast<LogFontTypeface*>(this)), effects, desc);
if (!ctx->isValid()) {
- delete ctx;
ctx = nullptr;
}
- return ctx;
+ return ctx.release();
}
void LogFontTypeface::onFilterRec(SkScalerContextRec* rec) const {
diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp
index 0c588e8d3c..c83542f47a 100644
--- a/src/ports/SkScalerContext_win_dw.cpp
+++ b/src/ports/SkScalerContext_win_dw.cpp
@@ -204,18 +204,18 @@ static bool is_axis_aligned(const SkScalerContext::Rec& rec) {
both_zero(rec.fPost2x2[0][0], rec.fPost2x2[1][1]));
}
-SkScalerContext_DW::SkScalerContext_DW(DWriteFontTypeface* typeface,
+SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
const SkScalerContextEffects& effects,
const SkDescriptor* desc)
- : SkScalerContext(typeface, effects, desc)
- , fTypeface(SkRef(typeface))
+ : SkScalerContext(std::move(typefaceRef), effects, desc)
, fGlyphCount(-1) {
+ DWriteFontTypeface* typeface = this->getDWriteTypeface();
#if SK_HAS_DWRITE_2_H
- fTypeface->fFactory->QueryInterface<IDWriteFactory2>(&fFactory2);
+ typeface->fFactory->QueryInterface<IDWriteFactory2>(&fFactory2);
SkTScopedComPtr<IDWriteFontFace2> fontFace2;
- fTypeface->fDWriteFontFace->QueryInterface<IDWriteFontFace2>(&fontFace2);
+ typeface->fDWriteFontFace->QueryInterface<IDWriteFontFace2>(&fontFace2);
fIsColorFont = fFactory2.get() && fontFace2.get() && fontFace2->IsColorFont();
#endif
@@ -335,14 +335,15 @@ SkScalerContext_DW::~SkScalerContext_DW() {
unsigned SkScalerContext_DW::generateGlyphCount() {
if (fGlyphCount < 0) {
- fGlyphCount = fTypeface->fDWriteFontFace->GetGlyphCount();
+ fGlyphCount = this->getDWriteTypeface()->fDWriteFontFace->GetGlyphCount();
}
return fGlyphCount;
}
uint16_t SkScalerContext_DW::generateCharToGlyph(SkUnichar uni) {
uint16_t index = 0;
- fTypeface->fDWriteFontFace->GetGlyphIndices(reinterpret_cast<UINT32*>(&uni), 1, &index);
+ UINT32* uniPtr = reinterpret_cast<UINT32*>(&uni);
+ this->getDWriteTypeface()->fDWriteFontFace->GetGlyphIndices(uniPtr, 1, &index);
return index;
}
@@ -363,7 +364,7 @@ void SkScalerContext_DW::generateAdvance(SkGlyph* glyph) {
DWRITE_MEASURING_MODE_GDI_NATURAL == fMeasuringMode)
{
SkAutoExclusive l(DWriteFactoryMutex);
- HRVM(fTypeface->fDWriteFontFace->GetGdiCompatibleGlyphMetrics(
+ HRVM(this->getDWriteTypeface()->fDWriteFontFace->GetGdiCompatibleGlyphMetrics(
fTextSizeMeasure,
1.0f, // pixelsPerDip
&fGsA,
@@ -373,14 +374,14 @@ void SkScalerContext_DW::generateAdvance(SkGlyph* glyph) {
"Could not get gdi compatible glyph metrics.");
} else {
SkAutoExclusive l(DWriteFactoryMutex);
- HRVM(fTypeface->fDWriteFontFace->GetDesignGlyphMetrics(&glyphId, 1, &gm),
+ HRVM(this->getDWriteTypeface()->fDWriteFontFace->GetDesignGlyphMetrics(&glyphId, 1, &gm),
"Could not get design metrics.");
}
DWRITE_FONT_METRICS dwfm;
{
Shared l(DWriteFactoryMutex);
- fTypeface->fDWriteFontFace->GetMetrics(&dwfm);
+ this->getDWriteTypeface()->fDWriteFontFace->GetMetrics(&dwfm);
}
SkScalar advanceX = SkScalarMulDiv(fTextSizeMeasure,
SkIntToScalar(gm.advanceWidth),
@@ -422,7 +423,7 @@ HRESULT SkScalerContext_DW::getBoundingBox(SkGlyph* glyph,
DWRITE_GLYPH_RUN run;
run.glyphCount = 1;
run.glyphAdvances = &advance;
- run.fontFace = fTypeface->fDWriteFontFace.get();
+ run.fontFace = this->getDWriteTypeface()->fDWriteFontFace.get();
run.fontEmSize = SkScalarToFloat(fTextSizeRender);
run.bidiLevel = 0;
run.glyphIndices = &glyphId;
@@ -432,7 +433,7 @@ HRESULT SkScalerContext_DW::getBoundingBox(SkGlyph* glyph,
SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis;
{
SkAutoExclusive l(DWriteFactoryMutex);
- HRM(fTypeface->fFactory->CreateGlyphRunAnalysis(
+ HRM(this->getDWriteTypeface()->fFactory->CreateGlyphRunAnalysis(
&run,
1.0f, // pixelsPerDip,
&fXform,
@@ -491,7 +492,7 @@ bool SkScalerContext_DW::getColorGlyphRun(const SkGlyph& glyph,
DWRITE_GLYPH_RUN run;
run.glyphCount = 1;
run.glyphAdvances = &advance;
- run.fontFace = fTypeface->fDWriteFontFace.get();
+ run.fontFace = this->getDWriteTypeface()->fDWriteFontFace.get();
run.fontEmSize = SkScalarToFloat(fTextSizeRender);
run.bidiLevel = 0;
run.glyphIndices = &glyphId;
@@ -558,13 +559,13 @@ void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) {
if (DWRITE_MEASURING_MODE_GDI_CLASSIC == fMeasuringMode ||
DWRITE_MEASURING_MODE_GDI_NATURAL == fMeasuringMode)
{
- fTypeface->fDWriteFontFace->GetGdiCompatibleMetrics(
+ this->getDWriteTypeface()->fDWriteFontFace->GetGdiCompatibleMetrics(
fTextSizeRender,
1.0f, // pixelsPerDip
&fXform,
&dwfm);
} else {
- fTypeface->fDWriteFontFace->GetMetrics(&dwfm);
+ this->getDWriteTypeface()->fDWriteFontFace->GetMetrics(&dwfm);
}
SkScalar upem = SkIntToScalar(dwfm.designUnitsPerEm);
@@ -580,9 +581,9 @@ void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) {
metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
#if SK_HAS_DWRITE_1_H
- if (fTypeface->fDWriteFontFace1.get()) {
+ if (this->getDWriteTypeface()->fDWriteFontFace1.get()) {
DWRITE_FONT_METRICS1 dwfm1;
- fTypeface->fDWriteFontFace1->GetMetrics(&dwfm1);
+ this->getDWriteTypeface()->fDWriteFontFace1->GetMetrics(&dwfm1);
metrics->fTop = -fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxTop) / upem;
metrics->fBottom = -fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxBottom) / upem;
metrics->fXMin = fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxLeft) / upem;
@@ -595,7 +596,7 @@ void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) {
# pragma message("No dwrite_1.h is available, font metrics may be affected.")
#endif
- AutoTDWriteTable<SkOTTableHead> head(fTypeface->fDWriteFontFace.get());
+ AutoTDWriteTable<SkOTTableHead> head(this->getDWriteTypeface()->fDWriteFontFace.get());
if (head.fExists &&
head.fSize >= sizeof(SkOTTableHead) &&
head->version == SkOTTableHead::version1)
@@ -726,7 +727,7 @@ const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
DWRITE_GLYPH_RUN run;
run.glyphCount = 1;
run.glyphAdvances = &advance;
- run.fontFace = fTypeface->fDWriteFontFace.get();
+ run.fontFace = this->getDWriteTypeface()->fDWriteFontFace.get();
run.fontEmSize = SkScalarToFloat(fTextSizeRender);
run.bidiLevel = 0;
run.glyphIndices = &index;
@@ -737,7 +738,7 @@ const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis;
{
SkAutoExclusive l(DWriteFactoryMutex);
- HRNM(fTypeface->fFactory->CreateGlyphRunAnalysis(&run,
+ HRNM(this->getDWriteTypeface()->fFactory->CreateGlyphRunAnalysis(&run,
1.0f, // pixelsPerDip,
&fXform,
renderingMode,
@@ -899,15 +900,16 @@ void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) {
SkAutoExclusive l(DWriteFactoryMutex);
//TODO: convert to<->from DIUs? This would make a difference if hinting.
//It may not be needed, it appears that DirectWrite only hints at em size.
- HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSizeRender),
- &glyphId,
- nullptr, //advances
- nullptr, //offsets
- 1, //num glyphs
- FALSE, //sideways
- FALSE, //rtl
- geometryToPath.get()),
- "Could not create glyph outline.");
+ HRVM(this->getDWriteTypeface()->fDWriteFontFace->GetGlyphRunOutline(
+ SkScalarToFloat(fTextSizeRender),
+ &glyphId,
+ nullptr, //advances
+ nullptr, //offsets
+ 1, //num glyphs
+ FALSE, //sideways
+ FALSE, //rtl
+ geometryToPath.get()),
+ "Could not create glyph outline.");
}
path->transform(fSkXform);
diff --git a/src/ports/SkScalerContext_win_dw.h b/src/ports/SkScalerContext_win_dw.h
index 98c4910b27..bcb7ab47db 100644
--- a/src/ports/SkScalerContext_win_dw.h
+++ b/src/ports/SkScalerContext_win_dw.h
@@ -23,7 +23,9 @@ class SkDescriptor;
class SkScalerContext_DW : public SkScalerContext {
public:
- SkScalerContext_DW(DWriteFontTypeface*, const SkScalerContextEffects&, const SkDescriptor*);
+ SkScalerContext_DW(sk_sp<DWriteFontTypeface>,
+ const SkScalerContextEffects&,
+ const SkDescriptor*);
virtual ~SkScalerContext_DW();
protected:
@@ -47,6 +49,10 @@ private:
bool isColorGlyph(const SkGlyph& glyph);
+ DWriteFontTypeface* getDWriteTypeface() {
+ return static_cast<DWriteFontTypeface*>(this->getTypeface());
+ }
+
#if SK_HAS_DWRITE_2_H
bool getColorGlyphRun(const SkGlyph& glyph, IDWriteColorGlyphRunEnumerator** colorGlyph);
@@ -70,7 +76,6 @@ private:
SkScalar fTextSizeRender;
/** The text size to measure with. */
SkScalar fTextSizeMeasure;
- SkAutoTUnref<DWriteFontTypeface> fTypeface;
int fGlyphCount;
DWRITE_RENDERING_MODE fRenderingMode;
DWRITE_TEXTURE_TYPE fTextureType;
diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp
index 220f21b19d..dc872182db 100644
--- a/src/ports/SkTypeface_win_dw.cpp
+++ b/src/ports/SkTypeface_win_dw.cpp
@@ -247,7 +247,7 @@ SkStreamAsset* DWriteFontTypeface::onOpenStream(int* ttcIndex) const {
SkScalerContext* DWriteFontTypeface::onCreateScalerContext(const SkScalerContextEffects& effects,
const SkDescriptor* desc) const {
- return new SkScalerContext_DW(const_cast<DWriteFontTypeface*>(this), effects, desc);
+ return new SkScalerContext_DW(sk_ref_sp(const_cast<DWriteFontTypeface*>(this)), effects, desc);
}
void DWriteFontTypeface::onFilterRec(SkScalerContext::Rec* rec) const {