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

Unified Diff: src/core/SkScalerContext.cpp

Issue 1872253004: Revert of 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
« no previous file with comments | « src/core/SkScalerContext.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScalerContext.cpp
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index ad753dfd21d060260b43cf2f1f2b5076d389fe0f..cf4098bbdda9ccc07358d55415b6693f883e4aa8 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -62,14 +62,30 @@
#define DUMP_RECx
#endif
-SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkScalerContextEffects& effects,
- const SkDescriptor* desc)
+static SkFlattenable* load_flattenable(const SkDescriptor* desc, uint32_t tag,
+ SkFlattenable::Type ft) {
+ SkFlattenable* obj = nullptr;
+ uint32_t len;
+ const void* data = desc->findEntry(tag, &len);
+
+ if (data) {
+ SkReadBuffer buffer(data, len);
+ obj = buffer.readFlattenable(ft);
+ SkASSERT(buffer.offset() == buffer.size());
+ }
+ return obj;
+}
+
+SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc)
: fRec(*static_cast<const Rec*>(desc->findEntry(kRec_SkDescriptorTag, nullptr)))
- , fTypeface(sk_ref_sp(typeface))
- , fPathEffect(sk_ref_sp(effects.fPathEffect))
- , fMaskFilter(sk_ref_sp(effects.fMaskFilter))
- , fRasterizer(sk_ref_sp(effects.fRasterizer))
+ , 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)))
// Initialize based on our settings. Subclasses can also force this.
, fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != nullptr || fRasterizer != nullptr)
@@ -93,7 +109,11 @@
#endif
}
-SkScalerContext::~SkScalerContext() {}
+SkScalerContext::~SkScalerContext() {
+ SkSafeUnref(fPathEffect);
+ SkSafeUnref(fMaskFilter);
+ SkSafeUnref(fRasterizer);
+}
void SkScalerContext::getAdvance(SkGlyph* glyph) {
// mark us as just having a valid advance
@@ -136,7 +156,7 @@
SkMask mask;
if (fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
- fMaskFilter.get(), &mask,
+ fMaskFilter, &mask,
SkMask::kJustComputeBounds_CreateMode)) {
glyph->fLeft = mask.fBounds.fLeft;
glyph->fTop = mask.fBounds.fTop;
@@ -465,9 +485,10 @@
tmpGlyph.initGlyphIdFrom(origGlyph);
// need the original bounds, sans our maskfilter
- SkMaskFilter* mf = fMaskFilter.release(); // temp disable
+ SkMaskFilter* mf = fMaskFilter;
+ fMaskFilter = nullptr; // temp disable
this->getMetrics(&tmpGlyph);
- fMaskFilter = sk_sp<SkMaskFilter>(mf); // restore
+ fMaskFilter = mf; // restore
// we need the prefilter bounds to be <= filter bounds
SkASSERT(tmpGlyph.fWidth <= origGlyph.fWidth);
@@ -495,7 +516,7 @@
sk_bzero(glyph->fImage, mask.computeImageSize());
if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
- fMaskFilter.get(), &mask,
+ fMaskFilter, &mask,
SkMask::kJustRenderImage_CreateMode)) {
return;
}
@@ -830,9 +851,8 @@
class SkScalerContext_Empty : public SkScalerContext {
public:
- SkScalerContext_Empty(SkTypeface* typeface, const SkScalerContextEffects& effects,
- const SkDescriptor* desc)
- : SkScalerContext(typeface, effects, desc) {}
+ SkScalerContext_Empty(SkTypeface* face, const SkDescriptor* desc)
+ : SkScalerContext(face, desc) {}
protected:
unsigned generateGlyphCount() override {
@@ -858,13 +878,12 @@
extern SkScalerContext* SkCreateColorScalerContext(const SkDescriptor* desc);
-SkScalerContext* SkTypeface::createScalerContext(const SkScalerContextEffects& effects,
- const SkDescriptor* desc,
+SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc,
bool allowFailure) const {
- SkScalerContext* c = this->onCreateScalerContext(effects, desc);
+ SkScalerContext* c = this->onCreateScalerContext(desc);
if (!c && !allowFailure) {
- c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), effects, desc);
+ c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), desc);
}
return c;
}
« no previous file with comments | « src/core/SkScalerContext.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698