aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-18 11:22:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-18 11:22:57 -0700
commita439334b6e758d38501e225e2e5d0ab73e2fb6eb (patch)
tree8f2919ed2f6dcae5c4d5dbaaf608b5c6d248f2fc /src/core
parent0be9e806af72b3e029e691eef5c891c90d3fd320 (diff)
Reland of "switch patheffects over to sk_sp (patchset #5 id:80001 of https://codereview.chromium.org/1813553005/ )"
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkDraw.cpp2
-rw-r--r--src/core/SkPaint.cpp8
-rw-r--r--src/core/SkPathEffect.cpp46
-rw-r--r--src/core/SkReadBuffer.h4
4 files changed, 22 insertions, 38 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index c35247bd99..60db401aea 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1615,7 +1615,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
// Now restore the original settings, so we "draw" with whatever style/stroking.
paint.setStyle(origPaint.getStyle());
- paint.setPathEffect(origPaint.getPathEffect());
+ paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect()));
while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(cache.get(), &text);
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 5e813f78c4..331f7794bf 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -375,7 +375,9 @@ SET_PTR(ImageFilter)
SET_PTR(Shader)
SET_PTR(ColorFilter)
SET_PTR(Xfermode)
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
SET_PTR(PathEffect)
+#endif
SET_PTR(MaskFilter)
#undef SET_PTR
@@ -1930,7 +1932,7 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
}
if (flatFlags & kHasEffects_FlatFlag) {
- SkSafeUnref(this->setPathEffect(buffer.readPathEffect()));
+ this->setPathEffect(buffer.readPathEffect());
this->setShader(buffer.readShader());
SkSafeUnref(this->setXfermode(buffer.readXfermode()));
SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter()));
@@ -2250,11 +2252,11 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr);
SkPaint::Style style = SkPaint::kFill_Style;
- SkPathEffect* pe = nullptr;
+ sk_sp<SkPathEffect> pe;
if (!applyStrokeAndPathEffects) {
style = paint.getStyle(); // restore
- pe = paint.getPathEffect(); // restore
+ pe = sk_ref_sp(paint.getPathEffect()); // restore
}
fPaint.setStyle(style);
fPaint.setPathEffect(pe);
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index 293bb53b2c..b2e29bc09d 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006 The Android Open Source Project
*
@@ -28,25 +27,19 @@ SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const {
///////////////////////////////////////////////////////////////////////////////
-SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
- : fPE0(pe0), fPE1(pe1) {
- SkASSERT(pe0);
- SkASSERT(pe1);
- fPE0->ref();
- fPE1->ref();
-}
-
-SkPairPathEffect::~SkPairPathEffect() {
- SkSafeUnref(fPE0);
- SkSafeUnref(fPE1);
+SkPairPathEffect::SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1)
+ : fPE0(std::move(pe0)), fPE1(std::move(pe1))
+{
+ SkASSERT(fPE0.get());
+ SkASSERT(fPE1.get());
}
/*
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
*/
void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
- buffer.writeFlattenable(fPE0);
- buffer.writeFlattenable(fPE1);
+ buffer.writeFlattenable(fPE0.get());
+ buffer.writeFlattenable(fPE1.get());
}
#ifndef SK_IGNORE_TO_STRING
@@ -65,22 +58,13 @@ void SkPairPathEffect::toString(SkString* str) const {
///////////////////////////////////////////////////////////////////////////////
SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
- SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
- SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
- if (pe0 && pe1) {
- return SkComposePathEffect::Create(pe0, pe1);
- } else {
- return nullptr;
- }
+ sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
+ sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
+ return SkComposePathEffect::Make(std::move(pe0), std::move(pe1)).release();
}
bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec* rec, const SkRect* cullRect) const {
- // we may have failed to unflatten these, so we have to check
- if (!fPE0 || !fPE1) {
- return false;
- }
-
SkPath tmp;
const SkPath* ptr = &src;
@@ -102,13 +86,9 @@ void SkComposePathEffect::toString(SkString* str) const {
///////////////////////////////////////////////////////////////////////////////
SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
- SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
- SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
- if (pe0 && pe1) {
- return SkSumPathEffect::Create(pe0, pe1);
- } else {
- return nullptr;
- }
+ sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
+ sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
+ return SkSumPathEffect::Make(pe0, pe1).release();
}
bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 7ce6d048e9..c7ac8480ec 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -134,7 +134,9 @@ public:
SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper>(); }
SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); }
SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); }
- SkPathEffect* readPathEffect() { return this->readFlattenable<SkPathEffect>(); }
+ sk_sp<SkPathEffect> readPathEffect() {
+ return sk_sp<SkPathEffect>(this->readFlattenable<SkPathEffect>());
+ }
SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
sk_sp<SkShader> readShader() { return sk_sp<SkShader>(this->readFlattenable<SkShader>()); }
SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(); }