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

Unified Diff: src/core/SkPathEffect.cpp

Issue 1817543002: Revert of switch patheffects over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkPaint.cpp ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPathEffect.cpp
diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp
index b2e29bc09d9d30cd0ab2858a62b12fe6039c3055..293bb53b2c416a55ce931b6c727e7d0e686a7047 100644
--- a/src/core/SkPathEffect.cpp
+++ b/src/core/SkPathEffect.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2006 The Android Open Source Project
*
@@ -27,19 +28,25 @@
///////////////////////////////////////////////////////////////////////////////
-SkPairPathEffect::SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1)
- : fPE0(std::move(pe0)), fPE1(std::move(pe1))
-{
- SkASSERT(fPE0.get());
- SkASSERT(fPE1.get());
+SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
+ : fPE0(pe0), fPE1(pe1) {
+ SkASSERT(pe0);
+ SkASSERT(pe1);
+ fPE0->ref();
+ fPE1->ref();
+}
+
+SkPairPathEffect::~SkPairPathEffect() {
+ SkSafeUnref(fPE0);
+ SkSafeUnref(fPE1);
}
/*
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
*/
void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
- buffer.writeFlattenable(fPE0.get());
- buffer.writeFlattenable(fPE1.get());
+ buffer.writeFlattenable(fPE0);
+ buffer.writeFlattenable(fPE1);
}
#ifndef SK_IGNORE_TO_STRING
@@ -58,13 +65,22 @@
///////////////////////////////////////////////////////////////////////////////
SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
- sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
- return SkComposePathEffect::Make(std::move(pe0), std::move(pe1)).release();
+ SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
+ SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
+ if (pe0 && pe1) {
+ return SkComposePathEffect::Create(pe0, pe1);
+ } else {
+ return nullptr;
+ }
}
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;
@@ -86,9 +102,13 @@
///////////////////////////////////////////////////////////////////////////////
SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
- sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
- sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
- return SkSumPathEffect::Make(pe0, pe1).release();
+ SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
+ SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
+ if (pe0 && pe1) {
+ return SkSumPathEffect::Create(pe0, pe1);
+ } else {
+ return nullptr;
+ }
}
bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698