aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-05-19 16:23:47 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-19 16:23:47 -0700
commit8b6fa5e8a9016ebbf3a03009abc3845b71452550 (patch)
treea9c51f5f20f01e71f7739b4b582708f2f4d0a7ae /src
parentb525721907fa56fd20682116f7645b4d0a861b78 (diff)
Make GrAtlasTextBlob::run own effects it points to.
BUG=chromium:608566 Currently the run has bare pointers and the effects can be destroyed while a run is pointing at them. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1993213003 Review-Url: https://codereview.chromium.org/1993213003
Diffstat (limited to 'src')
-rw-r--r--src/gpu/text/GrAtlasTextBlob.cpp8
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h8
-rw-r--r--src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp6
3 files changed, 18 insertions, 4 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 54af7af87a..13c96b5e64 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -58,9 +58,13 @@ SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex,
// if we have an override descriptor for the run, then we should use that
SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDescriptor.get() :
&run->fDescriptor;
- skPaint.getScalerContextDescriptor(&run->fEffects, desc, props, scalerContextFlags, viewMatrix);
+ SkScalerContextEffects effects;
+ skPaint.getScalerContextDescriptor(&effects, desc, props, scalerContextFlags, viewMatrix);
run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
- return SkGlyphCache::DetachCache(run->fTypeface, run->fEffects, desc->getDesc());
+ run->fPathEffect = sk_ref_sp(effects.fPathEffect);
+ run->fRasterizer = sk_ref_sp(effects.fRasterizer);
+ run->fMaskFilter = sk_ref_sp(effects.fMaskFilter);
+ return SkGlyphCache::DetachCache(run->fTypeface, effects, desc->getDesc());
}
void GrAtlasTextBlob::appendGlyph(int runIndex,
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index d9083b2f56..63c8033322 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -14,6 +14,8 @@
#include "GrMemoryPool.h"
#include "SkDescriptor.h"
#include "SkMaskFilter.h"
+#include "SkPathEffect.h"
+#include "SkRasterizer.h"
#include "SkSurfaceProps.h"
#include "SkTInternalLList.h"
@@ -477,7 +479,11 @@ private:
SkAutoTUnref<SkTypeface> fTypeface;
SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo;
SkAutoDescriptor fDescriptor;
- SkScalerContextEffects fEffects;
+
+ // Effects from the paint that are used to build a SkScalerContext.
+ sk_sp<SkPathEffect> fPathEffect;
+ sk_sp<SkRasterizer> fRasterizer;
+ sk_sp<SkMaskFilter> fMaskFilter;
// Distance field text cannot draw coloremoji, and so has to fall back. However,
// though the distance field text and the coloremoji may share the same run, they
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
index 28d32198de..59df1fa81d 100644
--- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
+++ b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
@@ -158,7 +158,11 @@ void GrAtlasTextBlob::regenInBatch(GrDrawBatch::Target* target,
: run->fDescriptor.getDesc();
if (!*lazyCache || (*lazyCache)->getDescriptor() != *desc) {
- lazyCache->reset(SkGlyphCache::DetachCache(run->fTypeface, run->fEffects, desc));
+ SkScalerContextEffects effects;
+ effects.fPathEffect = run->fPathEffect.get();
+ effects.fRasterizer = run->fRasterizer.get();
+ effects.fMaskFilter = run->fMaskFilter.get();
+ lazyCache->reset(SkGlyphCache::DetachCache(run->fTypeface, effects, desc));
}
if (regenGlyphs) {