use std::atomic in SkRegionPriv

Bug: skia:7882
Change-Id: I333f3457fbcd9621d712c40844f4896bd85a9a1c
Reviewed-on: https://skia-review.googlesource.com/124266
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-04-27 12:06:44 -04:00 committed by Skia Commit-Bot
parent 8efbb49afe
commit f80989f5f0
2 changed files with 4 additions and 4 deletions

View File

@ -129,7 +129,7 @@ SkRegion::~SkRegion() {
void SkRegion::freeRuns() {
if (this->isComplex()) {
SkASSERT(fRunHead->fRefCnt >= 1);
if (sk_atomic_dec(&fRunHead->fRefCnt) == 1) {
if (--fRunHead->fRefCnt == 0) {
//SkASSERT(gRgnAllocCounter > 0);
//SkDEBUGCODE(sk_atomic_dec(&gRgnAllocCounter));
//SkDEBUGF(("************** gRgnAllocCounter::free %d\n", gRgnAllocCounter));
@ -199,7 +199,7 @@ bool SkRegion::setRegion(const SkRegion& src) {
fBounds = src.fBounds;
fRunHead = src.fRunHead;
if (this->isComplex()) {
sk_atomic_inc(&fRunHead->fRefCnt);
fRunHead->fRefCnt++;
}
}
return fRunHead != SkRegion_gEmptyRunHeadPtr;

View File

@ -42,7 +42,7 @@ struct SkRegion::RunHead {
private:
public:
int32_t fRefCnt;
std::atomic<int32_t> fRefCnt;
int32_t fRunCount;
/**
@ -120,7 +120,7 @@ public:
// fRefCount might have changed since we last checked.
// If we own the last reference at this point, we need to
// free the memory.
if (sk_atomic_dec(&fRefCnt) == 1) {
if (--fRefCnt == 0) {
sk_free(this);
}
}