aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-07-08 06:48:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-08 06:48:17 -0700
commit4ae94ffce5ecf1b71cb5e295b68bf4ec9e697443 (patch)
tree6c734cf27a2f033bfb5f512420860fd035d0bbfa /src
parent3afef1f75f710b8f183113cdc5188416f7d01f28 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkImageFilter.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 4c4b56beac..b67fbe01e7 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -379,7 +379,10 @@ static uint32_t compute_hash(const uint32_t* data, int count) {
class CacheImpl : public SkImageFilter::Cache {
public:
- explicit CacheImpl(int minChildren) : fMinChildren(minChildren) {}
+ explicit CacheImpl(int minChildren) : fMinChildren(minChildren) {
+ SkASSERT(fMinChildren <= 2);
+ }
+
virtual ~CacheImpl();
bool get(const SkImageFilter* key, SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
void set(const SkImageFilter* key, const SkBitmap& result, const SkIPoint& offset) SK_OVERRIDE;
@@ -422,7 +425,10 @@ void CacheImpl::remove(const SkImageFilter* key) {
}
void CacheImpl::set(const SkImageFilter* key, const SkBitmap& result, const SkIPoint& offset) {
- if (key->getRefCnt() >= fMinChildren) {
+ if (fMinChildren < 2 || !key->unique()) {
+ // We take !key->unique() as a signal that there are probably at least 2 refs on the key,
+ // meaning this filter probably has at least two children and is worth caching when
+ // fMinChildren is 2. If fMinChildren is less than two, we'll just always cache.
fData.add(new Value(key, result, offset));
}
}