diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-02 16:42:21 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-02 16:42:21 +0000 |
commit | 03087072483378a43f7b3f7a47944614187275eb (patch) | |
tree | 7e5b178798203dadf84fe3c3344588ead4ef9f24 /src/core | |
parent | 409774e8accb8772765b376d3126209b198bc87c (diff) |
Make it explicit that some validate methods are debug only
https://codereview.chromium.org/25716003/
git-svn-id: http://skia.googlecode.com/svn/trunk@11575 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPathRef.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp index dd187932d0..08cc4cb08e 100644 --- a/src/core/SkPathRef.cpp +++ b/src/core/SkPathRef.cpp @@ -29,7 +29,7 @@ SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef, } SkPoint* SkPathRef::Editor::growForConic(SkScalar w) { - fPathRef->validate(); + SkDEBUGCODE(fPathRef->validate();) SkPoint* pts = fPathRef->growForVerb(SkPath::kConic_Verb); *fPathRef->fConicWeights.append() = w; return pts; @@ -39,12 +39,12 @@ SkPoint* SkPathRef::Editor::growForConic(SkScalar w) { void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst, const SkPathRef& src, const SkMatrix& matrix) { - src.validate(); + SkDEBUGCODE(src.validate();) if (matrix.isIdentity()) { if (*dst != &src) { src.ref(); dst->reset(const_cast<SkPathRef*>(&src)); - (*dst)->validate(); + SkDEBUGCODE((*dst)->validate();) } return; } @@ -87,7 +87,7 @@ void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst, (*dst)->fBoundsIsDirty = true; } - (*dst)->validate(); + SkDEBUGCODE((*dst)->validate();) } SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer @@ -127,14 +127,14 @@ SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { if ((*pathRef)->unique()) { - (*pathRef)->validate(); + SkDEBUGCODE((*pathRef)->validate();) (*pathRef)->fBoundsIsDirty = true; // this also invalidates fIsFinite (*pathRef)->fVerbCnt = 0; (*pathRef)->fPointCnt = 0; (*pathRef)->fFreeSpace = (*pathRef)->currSize(); (*pathRef)->fGenerationID = 0; (*pathRef)->fConicWeights.rewind(); - (*pathRef)->validate(); + SkDEBUGCODE((*pathRef)->validate();) } else { int oldVCnt = (*pathRef)->countVerbs(); int oldPCnt = (*pathRef)->countPoints(); @@ -144,8 +144,8 @@ void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { } bool SkPathRef::operator== (const SkPathRef& ref) const { - this->validate(); - ref.validate(); + SkDEBUGCODE(this->validate();) + SkDEBUGCODE(ref.validate();) bool genIDMatch = fGenerationID && fGenerationID == ref.fGenerationID; #ifdef SK_RELEASE if (genIDMatch) { @@ -184,7 +184,7 @@ bool SkPathRef::operator== (const SkPathRef& ref) const { } void SkPathRef::writeToBuffer(SkWBuffer* buffer) { - this->validate(); + SkDEBUGCODE(this->validate();) SkDEBUGCODE(size_t beforePos = buffer->pos();) // Call getBounds() to ensure (as a side-effect) that fBounds @@ -219,7 +219,7 @@ uint32_t SkPathRef::writeSize() { void SkPathRef::copy(const SkPathRef& ref, int additionalReserveVerbs, int additionalReservePoints) { - this->validate(); + SkDEBUGCODE(this->validate();) this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(), additionalReserveVerbs, additionalReservePoints); memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt * sizeof(uint8_t)); @@ -233,12 +233,12 @@ void SkPathRef::copy(const SkPathRef& ref, fBounds = ref.fBounds; fIsFinite = ref.fIsFinite; } - this->validate(); + SkDEBUGCODE(this->validate();) } void SkPathRef::resetToSize(int verbCount, int pointCount, int conicCount, int reserveVerbs, int reservePoints) { - this->validate(); + SkDEBUGCODE(this->validate();) fBoundsIsDirty = true; // this also invalidates fIsFinite fGenerationID = 0; @@ -265,11 +265,11 @@ void SkPathRef::resetToSize(int verbCount, int pointCount, int conicCount, fFreeSpace = this->currSize() - minSize; } fConicWeights.setCount(conicCount); - this->validate(); + SkDEBUGCODE(this->validate();) } SkPoint* SkPathRef::growForVerb(int /* SkPath::Verb*/ verb) { - this->validate(); + SkDEBUGCODE(this->validate();) int pCnt; switch (verb) { case SkPath::kMove_Verb: @@ -304,12 +304,12 @@ SkPoint* SkPathRef::growForVerb(int /* SkPath::Verb*/ verb) { fPointCnt += pCnt; fFreeSpace -= space; fBoundsIsDirty = true; // this also invalidates fIsFinite - this->validate(); + SkDEBUGCODE(this->validate();) return ret; } void SkPathRef::makeSpace(size_t size) { - this->validate(); + SkDEBUGCODE(this->validate();) ptrdiff_t growSize = size - fFreeSpace; if (growSize <= 0) { return; @@ -336,7 +336,7 @@ void SkPathRef::makeSpace(size_t size) { memmove(newVerbsDst, oldVerbsSrc, oldVerbSize); fVerbs = reinterpret_cast<uint8_t*>(reinterpret_cast<intptr_t>(fPoints) + newSize); fFreeSpace += growSize; - this->validate(); + SkDEBUGCODE(this->validate();) } int32_t SkPathRef::genID() const { @@ -356,7 +356,9 @@ int32_t SkPathRef::genID() const { return fGenerationID; } +#ifdef SK_DEBUG void SkPathRef::validate() const { + this->INHERITED::validate(); SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPoints) >= 0); SkASSERT((NULL == fPoints) == (NULL == fVerbs)); @@ -381,3 +383,4 @@ void SkPathRef::validate() const { } #endif } +#endif |