From 4ae94ffce5ecf1b71cb5e295b68bf4ec9e697443 Mon Sep 17 00:00:00 2001 From: mtklein Date: Tue, 8 Jul 2014 06:48:17 -0700 Subject: Remove ability for Release code to call getRefCnt() or getWeakRefCnt(). These getRefCnt() methods are not thread safe, so Skia code should not be calling them. unique() is fine. SkDEBUG code (SkASSERTs) can still call getRefCnt() / getWeakRefCnt(). This adds tools/RefCntIs.{h,cpp}, which lets tests make their assertions in both debug and release modes. BUG=skia:2726 R=senorblanco@chromium.org, mtklein@google.com, reed@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/378643003 --- tools/RefCntIs.cpp | 9 +++++++++ tools/RefCntIs.h | 13 +++++++++++++ tools/tsan.supp | 3 --- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tools/RefCntIs.cpp create mode 100644 tools/RefCntIs.h (limited to 'tools') diff --git a/tools/RefCntIs.cpp b/tools/RefCntIs.cpp new file mode 100644 index 0000000000..48154b045c --- /dev/null +++ b/tools/RefCntIs.cpp @@ -0,0 +1,9 @@ +#include "RefCntIs.h" + +bool RefCntIs(const SkRefCntBase& obj, int32_t n) { + return obj.fRefCnt == n; +} + +bool WeakRefCntIs(const SkWeakRefCnt& obj, int32_t n) { + return obj.fWeakCnt == n; +} diff --git a/tools/RefCntIs.h b/tools/RefCntIs.h new file mode 100644 index 0000000000..86d3cc3e12 --- /dev/null +++ b/tools/RefCntIs.h @@ -0,0 +1,13 @@ +#ifndef RefCntIs_DEFINED +#define RefCntIs_DEFINED + +// Allows tests to assert a particular value for a ref count, +// without letting Skia library code look at that value. + +#include "SkRefCnt.h" +#include "SkWeakRefCnt.h" + +bool RefCntIs(const SkRefCntBase&, int32_t); +bool WeakRefCntIs(const SkWeakRefCnt&, int32_t); + +#endif//RefCntIs_DEFINED diff --git a/tools/tsan.supp b/tools/tsan.supp index 179adc9b4a..6c2b0909fc 100644 --- a/tools/tsan.supp +++ b/tools/tsan.supp @@ -31,9 +31,6 @@ race:SkPDF race:SkPixelRef::callGenIDChangeListeners race:SkPixelRef::needsNewGenID -# This calls SkRefCnt::getRefCnt(), which is not thread safe. skia:2726 -race:SkImageFilter::filterImage - # SkPathRef caches its bounding box the first time it's needed. # This will be fixed naturally once we create (from a single thread) a # bounding-box hierarchy for SkRecord-based SkPictures; all bounds will come pre-cached. -- cgit v1.2.3