Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Unified Diff: src/core/SkScalerContext.cpp

Issue 1863013003: Pass effects directly to fontcache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkScalerContext.cpp
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index cf4098bbdda9ccc07358d55415b6693f883e4aa8..10082b7c7c3606924246d8c94bbd716f496a522c 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -76,16 +76,14 @@ static SkFlattenable* load_flattenable(const SkDescriptor* desc, uint32_t tag,
return obj;
}
-SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc)
+SkScalerContext::SkScalerContext(const SkScalerContextEffects& effects,
+ const SkDescriptor* desc)
: fRec(*static_cast<const Rec*>(desc->findEntry(kRec_SkDescriptorTag, nullptr)))
- , fTypeface(SkRef(typeface))
- , fPathEffect(static_cast<SkPathEffect*>(load_flattenable(desc, kPathEffect_SkDescriptorTag,
- SkFlattenable::kSkPathEffect_Type)))
- , fMaskFilter(static_cast<SkMaskFilter*>(load_flattenable(desc, kMaskFilter_SkDescriptorTag,
- SkFlattenable::kSkMaskFilter_Type)))
- , fRasterizer(static_cast<SkRasterizer*>(load_flattenable(desc, kRasterizer_SkDescriptorTag,
- SkFlattenable::kSkRasterizer_Type)))
+ , fTypeface(effects.fTypeface)
+ , fPathEffect(effects.fPathEffect)
+ , fMaskFilter(effects.fMaskFilter)
+ , fRasterizer(effects.fRasterizer)
f(malita) 2016/04/06 13:28:32 Is there a way to take advantage of move semantics
// Initialize based on our settings. Subclasses can also force this.
, fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != nullptr || fRasterizer != nullptr)
@@ -109,11 +107,7 @@ SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc)
#endif
}
-SkScalerContext::~SkScalerContext() {
- SkSafeUnref(fPathEffect);
- SkSafeUnref(fMaskFilter);
- SkSafeUnref(fRasterizer);
-}
+SkScalerContext::~SkScalerContext() {}
void SkScalerContext::getAdvance(SkGlyph* glyph) {
// mark us as just having a valid advance
@@ -156,7 +150,7 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
SkMask mask;
if (fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
- fMaskFilter, &mask,
+ fMaskFilter.get(), &mask,
SkMask::kJustComputeBounds_CreateMode)) {
glyph->fLeft = mask.fBounds.fLeft;
glyph->fTop = mask.fBounds.fTop;
@@ -485,10 +479,9 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
tmpGlyph.initGlyphIdFrom(origGlyph);
// need the original bounds, sans our maskfilter
- SkMaskFilter* mf = fMaskFilter;
- fMaskFilter = nullptr; // temp disable
+ SkMaskFilter* mf = fMaskFilter.release(); // temp disable
this->getMetrics(&tmpGlyph);
- fMaskFilter = mf; // restore
+ fMaskFilter = sk_sp<SkMaskFilter>(mf); // restore
// we need the prefilter bounds to be <= filter bounds
SkASSERT(tmpGlyph.fWidth <= origGlyph.fWidth);
@@ -516,7 +509,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
sk_bzero(glyph->fImage, mask.computeImageSize());
if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
- fMaskFilter, &mask,
+ fMaskFilter.get(), &mask,
SkMask::kJustRenderImage_CreateMode)) {
return;
}
@@ -851,8 +844,8 @@ SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText() {
class SkScalerContext_Empty : public SkScalerContext {
public:
- SkScalerContext_Empty(SkTypeface* face, const SkDescriptor* desc)
- : SkScalerContext(face, desc) {}
+ SkScalerContext_Empty(const SkScalerContextEffects& effects, const SkDescriptor* desc)
+ : SkScalerContext(effects, desc) {}
protected:
unsigned generateGlyphCount() override {
@@ -878,12 +871,15 @@ protected:
extern SkScalerContext* SkCreateColorScalerContext(const SkDescriptor* desc);
-SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc,
+SkScalerContext* SkTypeface::createScalerContext(const SkScalerContextEffects& effects,
+ const SkDescriptor* desc,
bool allowFailure) const {
- SkScalerContext* c = this->onCreateScalerContext(desc);
+ SkScalerContext* c = this->onCreateScalerContext(effects, desc);
if (!c && !allowFailure) {
- c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), desc);
+ SkScalerContextEffects effects;
+ effects.fTypeface = sk_ref_sp(const_cast<SkTypeface*>(this));
+ c = new SkScalerContext_Empty(effects, desc);
}
return c;
}

Powered by Google App Engine
This is Rietveld 408576698