remove SkRefCnt safeRef() and safeUnref(), and replace the call-sites with
SkSafeRef() and SkSafeUnref().
This is basically a bug waiting to happen. An optimizing compiler can remove
checks for null on "this" if it chooses. However, SkRefCnt::safeRef() relies on
precisely this check...
void SkRefCnt::safeRef() {
if (this) {
this->ref();
}
}
Since a compiler might skip the if-clause, it breaks the intention of this
method, hence its removal.
static inline void SkSafeRef(SkRefCnt* obj) {
if (obj) {
obj->ref();
}
}
This form is not ignored by an optimizing compile, so we use it instead.
git-svn-id: http://skia.googlecode.com/svn/trunk@762 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/animator/SkDrawExtraPathEffect.cpp b/src/animator/SkDrawExtraPathEffect.cpp
index 4cca738..76b55c6 100644
--- a/src/animator/SkDrawExtraPathEffect.cpp
+++ b/src/animator/SkDrawExtraPathEffect.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -70,7 +70,7 @@
virtual ~SkDrawComposePathEffect();
virtual bool add(SkAnimateMaker& , SkDisplayable* );
virtual SkPathEffect* getPathEffect();
- virtual bool isPaint() const;
+ virtual bool isPaint() const;
private:
SkDrawPathEffect* effect1;
SkDrawPathEffect* effect2;
@@ -127,7 +127,7 @@
m.reset();
if (fDraw->addMatrix) {
SkDrawMatrix* matrix;
- if (fDraw->addMatrix->getType() == SkType_Matrix)
+ if (fDraw->addMatrix->getType() == SkType_Matrix)
matrix = (SkDrawMatrix*) fDraw->addMatrix;
else {
SkApply* apply = (SkApply*) fDraw->addMatrix;
@@ -185,12 +185,12 @@
DEFINE_GET_MEMBER(SkDrawShapePathEffect);
-SkDrawShapePathEffect::SkDrawShapePathEffect() :
+SkDrawShapePathEffect::SkDrawShapePathEffect() :
addPath(NULL), addMatrix(NULL), path(NULL), fPathEffect(NULL) {
}
SkDrawShapePathEffect::~SkDrawShapePathEffect() {
- fPathEffect->safeUnref();
+ SkSafeUnref(fPathEffect);
}
bool SkDrawShapePathEffect::add(SkAnimateMaker& , SkDisplayable* child) {
@@ -234,7 +234,7 @@
class SkShape2DPathEffect : public Sk2DPathEffect {
public:
- SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker,
+ SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker,
const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(maker) {
}
@@ -265,7 +265,7 @@
goto clearCallBack;
if (fDraw->matrix) {
SkDrawMatrix* matrix;
- if (fDraw->matrix->getType() == SkType_Matrix)
+ if (fDraw->matrix->getType() == SkType_Matrix)
matrix = (SkDrawMatrix*) fDraw->matrix;
else {
SkApply* apply = (SkApply*) fDraw->matrix;
@@ -301,7 +301,7 @@
}
return true;
}
-
+
SkPoint fLoc;
SkRect fUVBounds;
int32_t fU;
@@ -418,13 +418,13 @@
class SkExtraPathEffects : public SkExtras {
public:
- SkExtraPathEffects(SkAnimator* animator) :
+ SkExtraPathEffects(SkAnimator* animator) :
skDrawShape1DPathEffectType(SkType_Unknown),
skDrawShape2DPathEffectType(SkType_Unknown),
skDrawComposePathEffectType(SkType_Unknown),
skDrawCornerPathEffectType(SkType_Unknown) {
}
-
+
virtual SkDisplayable* createInstance(SkDisplayTypes type) {
SkDisplayable* result = NULL;
if (skDrawShape1DPathEffectType == type)
@@ -439,8 +439,8 @@
}
virtual bool definesType(SkDisplayTypes type) {
- return type == skDrawShape1DPathEffectType ||
- type == skDrawShape2DPathEffectType ||
+ return type == skDrawShape1DPathEffectType ||
+ type == skDrawShape2DPathEffectType ||
type == skDrawComposePathEffectType ||
type == skDrawCornerPathEffectType;
}