remove sk_atomic_inc
Change-Id: I4960b1cd055daf44637e95825f82cb7fe2ce134a Reviewed-on: https://skia-review.googlesource.com/c/174285 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
a2785cc94c
commit
0ec1c571c8
@ -5,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "Benchmark.h"
|
||||
#include "SkAtomics.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkWeakRefCnt.h"
|
||||
#include <memory>
|
||||
@ -15,30 +14,6 @@ enum {
|
||||
M = 2
|
||||
};
|
||||
|
||||
class AtomicInc32 : public Benchmark {
|
||||
public:
|
||||
AtomicInc32() : fX(0) {}
|
||||
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
return backend == kNonRendering_Backend;
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
return "atomic_inc_32";
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas*) override {
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
sk_atomic_inc(&fX);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t fX;
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
class RefCntBench_Stack : public Benchmark {
|
||||
public:
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
@ -214,8 +189,6 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_BENCH( return new AtomicInc32(); )
|
||||
|
||||
DEF_BENCH( return new RefCntBench_Stack(); )
|
||||
DEF_BENCH( return new RefCntBench_Heap(); )
|
||||
DEF_BENCH( return new RefCntBench_New(); )
|
||||
|
@ -422,7 +422,6 @@ skia_core_sources = [
|
||||
|
||||
# private
|
||||
"$_include/private/SkArenaAlloc.h",
|
||||
"$_include/private/SkAtomics.h",
|
||||
"$_include/private/SkChecksum.h",
|
||||
"$_include/private/SkDeferredDisplayList.h",
|
||||
"$_include/private/SkFixed.h",
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkAtomics_DEFINED
|
||||
#define SkAtomics_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
#include <atomic>
|
||||
|
||||
// ~~~~~~~~ Very Legacy APIs ~~~~~~~~~
|
||||
//
|
||||
// Here are shims for our very old atomics API, to be weaned off of. They use
|
||||
// sequentially-consistent memory order to match historical behavior, but most
|
||||
// of the callers could perform better with explicit, weaker memory ordering.
|
||||
|
||||
inline int32_t sk_atomic_inc(int32_t* ptr) {
|
||||
return reinterpret_cast<std::atomic<int32_t>*>(ptr)->fetch_add(+1);
|
||||
}
|
||||
|
||||
#endif//SkAtomics_DEFINED
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkBitmap.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkColorData.h"
|
||||
#include "SkConvertPixels.h"
|
||||
#include "SkData.h"
|
||||
|
@ -5,20 +5,14 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkClipStack.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkPathOps.h"
|
||||
#include "SkClipOpPriv.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <new>
|
||||
|
||||
|
||||
// 0-2 are reserved for invalid, empty & wide-open
|
||||
static const int32_t kFirstUnreservedGenID = 3;
|
||||
int32_t SkClipStack::gGenID = kFirstUnreservedGenID;
|
||||
|
||||
SkClipStack::Element::Element(const Element& that) {
|
||||
switch (that.getDeviceSpaceType()) {
|
||||
case DeviceSpaceType::kEmpty:
|
||||
@ -1004,9 +998,13 @@ bool SkClipStack::isRRect(const SkRect& bounds, SkRRect* rrect, bool* aa) const
|
||||
}
|
||||
|
||||
uint32_t SkClipStack::GetNextGenID() {
|
||||
// 0-2 are reserved for invalid, empty & wide-open
|
||||
static const uint32_t kFirstUnreservedGenID = 3;
|
||||
static std::atomic<uint32_t> nextID{kFirstUnreservedGenID};
|
||||
|
||||
uint32_t id;
|
||||
do {
|
||||
id = static_cast<uint32_t>(sk_atomic_inc(&gGenID));
|
||||
id = nextID++;
|
||||
} while (id < kFirstUnreservedGenID);
|
||||
return id;
|
||||
}
|
||||
|
@ -489,10 +489,6 @@ private:
|
||||
SkDeque fDeque;
|
||||
int fSaveCount;
|
||||
|
||||
// Generation ID for the clip stack. This is incremented for each
|
||||
// clipDevRect and clipDevPath call. 0 is reserved to indicate an
|
||||
// invalid ID.
|
||||
static int32_t gGenID;
|
||||
SkRect fClipRestrictionRect = SkRect::MakeEmpty();
|
||||
|
||||
bool internalQuickContains(const SkRect& devRect) const;
|
||||
|
@ -5,20 +5,18 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDrawable.h"
|
||||
#include <atomic>
|
||||
|
||||
static int32_t next_generation_id() {
|
||||
static int32_t gCanvasDrawableGenerationID;
|
||||
static std::atomic<int32_t> nextID{1};
|
||||
|
||||
// do a loop in case our global wraps around, as we never want to
|
||||
// return a 0
|
||||
int32_t genID;
|
||||
int32_t id;
|
||||
do {
|
||||
genID = sk_atomic_inc(&gCanvasDrawableGenerationID) + 1;
|
||||
} while (0 == genID);
|
||||
return genID;
|
||||
id = nextID++;
|
||||
} while (id == 0);
|
||||
return id;
|
||||
}
|
||||
|
||||
SkDrawable::SkDrawable() : fGenerationID(0) {}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkImageFilter.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkFuzzLogging.h"
|
||||
#include "SkImageFilterCache.h"
|
||||
@ -28,6 +27,7 @@
|
||||
#include "GrTextureProxy.h"
|
||||
#include "SkGr.h"
|
||||
#endif
|
||||
#include <atomic>
|
||||
|
||||
void SkImageFilter::CropRect::applyTo(const SkIRect& imageBounds,
|
||||
const SkMatrix& ctm,
|
||||
@ -70,13 +70,12 @@ void SkImageFilter::CropRect::applyTo(const SkIRect& imageBounds,
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int32_t next_image_filter_unique_id() {
|
||||
static int32_t gImageFilterUniqueID;
|
||||
static std::atomic<int32_t> nextID{1};
|
||||
|
||||
// Never return 0.
|
||||
int32_t id;
|
||||
do {
|
||||
id = sk_atomic_inc(&gImageFilterUniqueID) + 1;
|
||||
} while (0 == id);
|
||||
id = nextID++;
|
||||
} while (id == 0);
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkRWBuffer.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkMakeUnique.h"
|
||||
#include "SkMalloc.h"
|
||||
#include "SkStream.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkSharedMutex.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkTypes.h"
|
||||
#include "SkSemaphore.h"
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkString.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkSafeMath.h"
|
||||
#include "SkTo.h"
|
||||
#include "SkUtils.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkTextBlob.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkGlyphRun.h"
|
||||
#include "SkPaintPriv.h"
|
||||
#include "SkReadBuffer.h"
|
||||
@ -16,6 +15,7 @@
|
||||
#include "SkTypeface.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
|
||||
@ -157,11 +157,11 @@ void SkTextBlob::RunRecord::grow(uint32_t count) {
|
||||
memmove(posBuffer(), initialPosBuffer, copySize);
|
||||
}
|
||||
|
||||
static int32_t gNextID = 1;
|
||||
static int32_t next_id() {
|
||||
static std::atomic<int32_t> nextID{1};
|
||||
int32_t id;
|
||||
do {
|
||||
id = sk_atomic_inc(&gNextID);
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidGenID);
|
||||
return id;
|
||||
}
|
||||
|
@ -5,11 +5,9 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "SkTypefaceCache.h"
|
||||
#include "SkAtomics.h"
|
||||
#include "SkMutex.h"
|
||||
#include <atomic>
|
||||
|
||||
#define TYPEFACE_CACHE_LIMIT 1024
|
||||
|
||||
@ -60,8 +58,8 @@ SkTypefaceCache& SkTypefaceCache::Get() {
|
||||
}
|
||||
|
||||
SkFontID SkTypefaceCache::NewFontID() {
|
||||
static int32_t gFontID;
|
||||
return sk_atomic_inc(&gFontID) + 1;
|
||||
static std::atomic<int32_t> nextID{1};
|
||||
return nextID++;
|
||||
}
|
||||
|
||||
SK_DECLARE_STATIC_MUTEX(gMutex);
|
||||
|
@ -7,20 +7,21 @@
|
||||
|
||||
#include "SkVertices.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkData.h"
|
||||
#include "SkReader32.h"
|
||||
#include "SkSafeMath.h"
|
||||
#include "SkSafeRange.h"
|
||||
#include "SkTo.h"
|
||||
#include "SkWriter32.h"
|
||||
#include <atomic>
|
||||
#include <new>
|
||||
|
||||
static int32_t gNextID = 1;
|
||||
static int32_t next_id() {
|
||||
static std::atomic<int32_t> nextID{1};
|
||||
|
||||
int32_t id;
|
||||
do {
|
||||
id = sk_atomic_inc(&gNextID);
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidGenID);
|
||||
return id;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "GrContext.h"
|
||||
#include <unordered_map>
|
||||
#include "GrBackendSemaphore.h"
|
||||
#include "GrClip.h"
|
||||
#include "GrContextOptions.h"
|
||||
@ -39,6 +38,8 @@
|
||||
#include "effects/GrSkSLFP.h"
|
||||
#include "ccpr/GrCoverageCountingPathRenderer.h"
|
||||
#include "text/GrTextBlobCache.h"
|
||||
#include <atomic>
|
||||
#include <unordered_map>
|
||||
|
||||
#define ASSERT_OWNED_PROXY(P) \
|
||||
SkASSERT(!(P) || !((P)->peekTexture()) || (P)->peekTexture()->getContext() == this)
|
||||
@ -58,11 +59,11 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int32_t gNextID = 1;
|
||||
static int32_t next_id() {
|
||||
static std::atomic<int32_t> nextID{1};
|
||||
int32_t id;
|
||||
do {
|
||||
id = sk_atomic_inc(&gNextID);
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidGenID);
|
||||
return id;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "GrGpu.h"
|
||||
#include "GrGpuResourcePriv.h"
|
||||
#include "SkTraceMemoryDump.h"
|
||||
#include <atomic>
|
||||
|
||||
static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
|
||||
SkASSERT(gpu);
|
||||
@ -206,10 +207,10 @@ void GrGpuResource::makeUnbudgeted() {
|
||||
}
|
||||
|
||||
uint32_t GrGpuResource::CreateUniqueID() {
|
||||
static int32_t gUniqueID = SK_InvalidUniqueID;
|
||||
static std::atomic<uint32_t> nextID{1};
|
||||
uint32_t id;
|
||||
do {
|
||||
id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidUniqueID);
|
||||
return id;
|
||||
}
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include "GrMemoryPool.h"
|
||||
#include "SkMalloc.h"
|
||||
#ifdef SK_DEBUG
|
||||
#include "SkAtomics.h"
|
||||
#endif
|
||||
#include "ops/GrOp.h"
|
||||
#ifdef SK_DEBUG
|
||||
#include <atomic>
|
||||
#endif
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
#define VALIDATE this->validate()
|
||||
@ -89,7 +89,10 @@ void* GrMemoryPool::allocate(size_t size) {
|
||||
// so that we can decrement the live count on delete in constant time.
|
||||
AllocHeader* allocData = reinterpret_cast<AllocHeader*>(ptr);
|
||||
SkDEBUGCODE(allocData->fSentinal = kAssignedMarker);
|
||||
SkDEBUGCODE(allocData->fID = []{static int32_t gID; return sk_atomic_inc(&gID) + 1;}());
|
||||
SkDEBUGCODE(allocData->fID = []{
|
||||
static std::atomic<int32_t> nextID{1};
|
||||
return nextID++;
|
||||
}());
|
||||
// You can set a breakpoint here when a leaked ID is allocated to see the stack frame.
|
||||
SkDEBUGCODE(fAllocatedIDs.add(allocData->fID));
|
||||
allocData->fHeader = fTail;
|
||||
|
@ -13,15 +13,13 @@
|
||||
#include "GrRenderTargetPriv.h"
|
||||
#include "GrSurfaceProxy.h"
|
||||
#include "GrTextureProxyPriv.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include <atomic>
|
||||
|
||||
uint32_t GrOpList::CreateUniqueID() {
|
||||
static int32_t gUniqueID = SK_InvalidUniqueID;
|
||||
static std::atomic<uint32_t> nextID{1};
|
||||
uint32_t id;
|
||||
// Loop in case our global wraps around, as we never want to return a 0.
|
||||
do {
|
||||
id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidUniqueID);
|
||||
return id;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#ifndef GrProcessor_DEFINED
|
||||
#define GrProcessor_DEFINED
|
||||
|
||||
#include "../private/SkAtomics.h"
|
||||
#include "GrBuffer.h"
|
||||
#include "GrColor.h"
|
||||
#include "GrProcessorUnitTest.h"
|
||||
|
@ -19,14 +19,16 @@
|
||||
#include "GrUninstantiateProxyTracker.h"
|
||||
|
||||
#if GR_TRACK_INTERVAL_CREATION
|
||||
uint32_t GrResourceAllocator::Interval::CreateUniqueID() {
|
||||
static int32_t gUniqueID = SK_InvalidUniqueID;
|
||||
uint32_t id;
|
||||
do {
|
||||
id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
|
||||
} while (id == SK_InvalidUniqueID);
|
||||
return id;
|
||||
}
|
||||
#include <atomic>
|
||||
|
||||
uint32_t GrResourceAllocator::Interval::CreateUniqueID() {
|
||||
static std::atomic<uint32_t> nextID{1};
|
||||
uint32_t id;
|
||||
do {
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidUniqueID);
|
||||
return id;
|
||||
}
|
||||
#endif
|
||||
|
||||
void GrResourceAllocator::Interval::assign(sk_sp<GrSurface> s) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "SkRandom.h"
|
||||
#include "SkTSort.h"
|
||||
#include "SkTo.h"
|
||||
#include <atomic>
|
||||
|
||||
DECLARE_SKMESSAGEBUS_MESSAGE(GrUniqueKeyInvalidatedMessage);
|
||||
|
||||
@ -30,9 +31,9 @@ DECLARE_SKMESSAGEBUS_MESSAGE(GrGpuResourceFreedMessage);
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrScratchKey::ResourceType GrScratchKey::GenerateResourceType() {
|
||||
static int32_t gType = INHERITED::kInvalidDomain + 1;
|
||||
static std::atomic<int32_t> nextType{INHERITED::kInvalidDomain + 1};
|
||||
|
||||
int32_t type = sk_atomic_inc(&gType);
|
||||
int32_t type = nextType++;
|
||||
if (type > SkTo<int32_t>(UINT16_MAX)) {
|
||||
SK_ABORT("Too many Resource Types");
|
||||
}
|
||||
@ -41,9 +42,9 @@ GrScratchKey::ResourceType GrScratchKey::GenerateResourceType() {
|
||||
}
|
||||
|
||||
GrUniqueKey::Domain GrUniqueKey::GenerateDomain() {
|
||||
static int32_t gDomain = INHERITED::kInvalidDomain + 1;
|
||||
static std::atomic<int32_t> nextDomain{INHERITED::kInvalidDomain + 1};
|
||||
|
||||
int32_t domain = sk_atomic_inc(&gDomain);
|
||||
int32_t domain = nextDomain++;
|
||||
if (domain > SkTo<int32_t>(UINT16_MAX)) {
|
||||
SK_ABORT("Too many GrUniqueKey Domains");
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "GrTextureProxy.h"
|
||||
#include "SkMakeUnique.h"
|
||||
#include "SkMathPriv.h"
|
||||
#include <atomic>
|
||||
|
||||
class GrCCAtlas::Node {
|
||||
public:
|
||||
@ -154,8 +155,8 @@ void GrCCAtlas::setStrokeBatchID(int id) {
|
||||
}
|
||||
|
||||
static uint32_t next_atlas_unique_id() {
|
||||
static int32_t nextID;
|
||||
return sk_atomic_inc(&nextID);
|
||||
static std::atomic<uint32_t> nextID;
|
||||
return nextID++;
|
||||
}
|
||||
|
||||
const GrUniqueKey& GrCCAtlas::getOrAssignUniqueKey(GrOnFlushResourceProvider* onFlushRP) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "SkSLPipelineStageCodeGenerator.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "../private/GrSkSLFPFactoryCache.h"
|
||||
#include <atomic>
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
#define GR_FP_SRC_STRING const char*
|
||||
@ -33,8 +34,8 @@ public:
|
||||
* NewIndex once, statically, and use this index for all calls to Make.
|
||||
*/
|
||||
static int NewIndex() {
|
||||
static int index = 0;
|
||||
return sk_atomic_inc(&index);
|
||||
static std::atomic<int> nextIndex{0};
|
||||
return nextIndex++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,9 +7,8 @@
|
||||
|
||||
#include "GrOp.h"
|
||||
|
||||
int32_t GrOp::gCurrOpClassID = GrOp::kIllegalOpID;
|
||||
|
||||
int32_t GrOp::gCurrOpUniqueID = GrOp::kIllegalOpID;
|
||||
std::atomic<uint32_t> GrOp::gCurrOpClassID {GrOp::kIllegalOpID + 1};
|
||||
std::atomic<uint32_t> GrOp::gCurrOpUniqueID{GrOp::kIllegalOpID + 1};
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void* GrOp::operator new(size_t size) {
|
||||
|
@ -8,8 +8,6 @@
|
||||
#ifndef GrOp_DEFINED
|
||||
#define GrOp_DEFINED
|
||||
|
||||
#include <new>
|
||||
#include "../private/SkAtomics.h"
|
||||
#include "GrGpuResource.h"
|
||||
#include "GrNonAtomicRef.h"
|
||||
#include "GrTracing.h"
|
||||
@ -17,6 +15,8 @@
|
||||
#include "SkMatrix.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkString.h"
|
||||
#include <atomic>
|
||||
#include <new>
|
||||
|
||||
class GrCaps;
|
||||
class GrGpuCommandBuffer;
|
||||
@ -303,11 +303,9 @@ private:
|
||||
// Otherwise, this op's bounds.
|
||||
virtual void onExecute(GrOpFlushState*, const SkRect& chainBounds) = 0;
|
||||
|
||||
static uint32_t GenID(int32_t* idCounter) {
|
||||
// The atomic inc returns the old value not the incremented value. So we add
|
||||
// 1 to the returned value.
|
||||
uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1;
|
||||
if (!id) {
|
||||
static uint32_t GenID(std::atomic<uint32_t>* idCounter) {
|
||||
uint32_t id = (*idCounter)++;
|
||||
if (id == 0) {
|
||||
SK_ABORT("This should never wrap as it should only be called once for each GrOp "
|
||||
"subclass.");
|
||||
}
|
||||
@ -339,8 +337,8 @@ private:
|
||||
mutable uint32_t fUniqueID = SK_InvalidUniqueID;
|
||||
SkRect fBounds;
|
||||
|
||||
static int32_t gCurrOpUniqueID;
|
||||
static int32_t gCurrOpClassID;
|
||||
static std::atomic<uint32_t> gCurrOpUniqueID;
|
||||
static std::atomic<uint32_t> gCurrOpClassID;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
#include "GrVkResource.h"
|
||||
#include "GrVkSamplerYcbcrConversion.h"
|
||||
#include "SkAtomics.h"
|
||||
#include "SkOpts.h"
|
||||
#include "vk/GrVkTypes.h"
|
||||
#include <atomic>
|
||||
|
||||
class GrSamplerState;
|
||||
class GrVkGpu;
|
||||
@ -71,10 +71,10 @@ private:
|
||||
void abandonGPUData() const override;
|
||||
|
||||
static uint32_t GenID() {
|
||||
static int32_t gUniqueID = SK_InvalidUniqueID;
|
||||
static std::atomic<uint32_t> nextID{1};
|
||||
uint32_t id;
|
||||
do {
|
||||
id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidUniqueID);
|
||||
return id;
|
||||
}
|
||||
|
@ -5,13 +5,12 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "GrBackendSurface.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkFontLCDConfig.h"
|
||||
#include "SkImagePriv.h"
|
||||
#include "SkSurface_Base.h"
|
||||
|
||||
#include "GrBackendSurface.h"
|
||||
#include <atomic>
|
||||
|
||||
static SkPixelGeometry compute_default_geometry() {
|
||||
SkFontLCDConfig::LCDOrder order = SkFontLCDConfig::GetSubpixelOrder();
|
||||
@ -122,8 +121,8 @@ void SkSurface_Base::aboutToDraw(ContentChangeMode mode) {
|
||||
|
||||
uint32_t SkSurface_Base::newGenerationID() {
|
||||
SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
|
||||
static int32_t gID;
|
||||
return sk_atomic_inc(&gID) + 1;
|
||||
static std::atomic<uint32_t> nextID{1};
|
||||
return nextID++;
|
||||
}
|
||||
|
||||
static SkSurface_Base* asSB(SkSurface* surface) {
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkPictureShader.h"
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkArenaAlloc.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBitmapProcShader.h"
|
||||
@ -19,6 +18,7 @@
|
||||
#include "SkPicturePriv.h"
|
||||
#include "SkReadBuffer.h"
|
||||
#include "SkResourceCache.h"
|
||||
#include <atomic>
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrCaps.h"
|
||||
@ -94,13 +94,14 @@ struct BitmapShaderRec : public SkResourceCache::Rec {
|
||||
}
|
||||
};
|
||||
|
||||
static int32_t gNextID = 1;
|
||||
uint32_t next_id() {
|
||||
int32_t id;
|
||||
static std::atomic<uint32_t> nextID{1};
|
||||
|
||||
uint32_t id;
|
||||
do {
|
||||
id = sk_atomic_inc(&gNextID);
|
||||
id = nextID++;
|
||||
} while (id == SK_InvalidGenID);
|
||||
return static_cast<uint32_t>(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "ops/GrRectOpFactory.h"
|
||||
#include "TestUtils.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <random>
|
||||
|
||||
namespace {
|
||||
@ -84,9 +85,8 @@ public:
|
||||
const char* name() const override { return "test"; }
|
||||
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override {
|
||||
// We don't really care about reusing these.
|
||||
static int32_t gKey = 0;
|
||||
b->add32(sk_atomic_inc(&gKey));
|
||||
static std::atomic<int32_t> nextKey{0};
|
||||
b->add32(nextKey++);
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override {
|
||||
|
@ -6,10 +6,11 @@
|
||||
*/
|
||||
|
||||
#include "CrashHandler.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrContextFactory.h"
|
||||
#include "OverwriteLine.h"
|
||||
#include "PathOpsDebug.h"
|
||||
#include "Resources.h"
|
||||
#include "SkAtomics.h"
|
||||
#include "SkCommonFlags.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkOSFile.h"
|
||||
@ -19,9 +20,7 @@
|
||||
#include "SkTemplates.h"
|
||||
#include "SkTime.h"
|
||||
#include "Test.h"
|
||||
|
||||
#include "GrContext.h"
|
||||
#include "GrContextFactory.h"
|
||||
#include <atomic>
|
||||
|
||||
using namespace skiatest;
|
||||
using namespace sk_gpu_test;
|
||||
@ -50,10 +49,8 @@ public:
|
||||
bool success,
|
||||
SkMSec elapsed,
|
||||
int testCount) {
|
||||
const int done = 1 + sk_atomic_inc(&fDone);
|
||||
for (int i = 0; i < testCount; ++i) {
|
||||
sk_atomic_inc(&fTestCount);
|
||||
}
|
||||
const int done = ++fDone;
|
||||
fTestCount += testCount;
|
||||
if (!success) {
|
||||
SkDebugf("\n---- %s FAILED", testName);
|
||||
}
|
||||
@ -68,15 +65,15 @@ public:
|
||||
testName);
|
||||
}
|
||||
|
||||
void reportFailure() { sk_atomic_inc(&fFailCount); }
|
||||
void reportFailure() { fFailCount++; }
|
||||
|
||||
int32_t testCount() { return fTestCount; }
|
||||
int32_t failCount() { return fFailCount; }
|
||||
|
||||
private:
|
||||
int32_t fDone; // atomic
|
||||
int32_t fTestCount; // atomic
|
||||
int32_t fFailCount; // atomic
|
||||
std::atomic<int32_t> fDone;
|
||||
std::atomic<int32_t> fTestCount;
|
||||
std::atomic<int32_t> fFailCount;
|
||||
const int fTotal;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user