aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPicture.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-07 15:30:46 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-07 15:30:46 +0000
commit82065d667f64e232bcde2ad849756a6096fcbe6f (patch)
treeb286676278e48522d5a1e153ff5696d3f2088cc8 /src/core/SkPicture.cpp
parent18908aacf360eaacf5e6a98dd57342adb98cf463 (diff)
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
Diffstat (limited to 'src/core/SkPicture.cpp')
-rw-r--r--src/core/SkPicture.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 343ca2b4b2..c199caebd6 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2007, 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.
*/
@@ -37,7 +37,7 @@
#ifdef SK_DEBUG
-// enable SK_DEBUG_TRACE to trace DrawType elements when
+// enable SK_DEBUG_TRACE to trace DrawType elements when
// recorded and played back
// #define SK_DEBUG_TRACE
// enable SK_DEBUG_SIZE to see the size of picture components
@@ -77,12 +77,12 @@ const char* DrawTypeToString(DrawType drawType) {
case SCALE: return "SCALE";
case SKEW: return "SKEW";
case TRANSLATE: return "TRANSLATE";
- default:
- SkDebugf("DrawType error 0x%08x\n", drawType);
- SkASSERT(0);
+ default:
+ SkDebugf("DrawType error 0x%08x\n", drawType);
+ SkASSERT(0);
break;
}
- SkASSERT(0);
+ SkASSERT(0);
return NULL;
}
#endif
@@ -133,7 +133,7 @@ SkPicture::SkPicture(const SkPicture& src) : SkRefCnt() {
}
SkPicture::~SkPicture() {
- fRecord->safeUnref();
+ SkSafeUnref(fRecord);
SkDELETE(fPlayback);
}
@@ -166,7 +166,7 @@ SkCanvas* SkPicture::beginRecording(int width, int height,
SkBitmap bm;
bm.setConfig(SkBitmap::kNo_Config, width, height);
fRecord->setBitmapDevice(bm);
-
+
return fRecord;
}
@@ -217,7 +217,7 @@ SkPicture::SkPicture(SkStream* stream) : SkRefCnt() {
void SkPicture::serialize(SkWStream* stream) const {
SkPicturePlayback* playback = fPlayback;
-
+
if (NULL == playback && fRecord) {
playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
}