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

Unified Diff: src/core/SkPathRef.h

Issue 18770007: Add a 'unique' method to SkRefCnt, document the usage, and add support. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Update comments. Created 7 years, 5 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 | « include/core/SkRefCnt.h ('k') | src/core/SkTRefArray.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPathRef.h
===================================================================
--- src/core/SkPathRef.h (revision 10200)
+++ src/core/SkPathRef.h (working copy)
@@ -37,15 +37,16 @@
public:
Editor(SkAutoTUnref<SkPathRef>* pathRef,
int incReserveVerbs = 0,
- int incReservePoints = 0) {
- if (pathRef->get()->getRefCnt() > 1) {
+ int incReservePoints = 0)
+ {
+ if ((*pathRef)->unique()) {
+ (*pathRef)->incReserve(incReserveVerbs, incReservePoints);
+ } else {
SkPathRef* copy = SkNEW(SkPathRef);
- copy->copy(*pathRef->get(), incReserveVerbs, incReservePoints);
+ copy->copy(**pathRef, incReserveVerbs, incReservePoints);
pathRef->reset(copy);
- } else {
- (*pathRef)->incReserve(incReserveVerbs, incReservePoints);
}
- fPathRef = pathRef->get();
+ fPathRef = *pathRef;
fPathRef->fGenerationID = 0;
SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);)
}
@@ -135,18 +136,18 @@
const SkMatrix& matrix) {
src.validate();
if (matrix.isIdentity()) {
- if (dst->get() != &src) {
+ if (*dst != &src) {
src.ref();
dst->reset(const_cast<SkPathRef*>(&src));
(*dst)->validate();
}
return;
}
- int32_t rcnt = dst->get()->getRefCnt();
- if (&src == dst->get() && 1 == rcnt) {
+ bool dstUnique = (*dst)->unique();
+ if (&src == *dst && dstUnique) {
matrix.mapPoints((*dst)->fPoints, (*dst)->fPointCnt);
return;
- } else if (rcnt > 1) {
+ } else if (!dstUnique) {
dst->reset(SkNEW(SkPathRef));
}
(*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count());
@@ -179,7 +180,7 @@
* only if necessary.
*/
static void Rewind(SkAutoTUnref<SkPathRef>* pathRef) {
- if (1 == (*pathRef)->getRefCnt()) {
+ if ((*pathRef)->unique()) {
(*pathRef)->validate();
(*pathRef)->fVerbCnt = 0;
(*pathRef)->fPointCnt = 0;
« no previous file with comments | « include/core/SkRefCnt.h ('k') | src/core/SkTRefArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698