From 9a8065d34dd090837c2a05bc60533fcc6268e6bb Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Tue, 14 Mar 2017 21:05:17 -0400 Subject: add uniqueID BUG=skia:6366 Change-Id: Ie3215a392040be645524a2294d824d953ba3a1b6 Reviewed-on: https://skia-review.googlesource.com/9703 Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- src/core/SkVertices.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core') diff --git a/src/core/SkVertices.cpp b/src/core/SkVertices.cpp index f2a63b9a73..936d70dc09 100644 --- a/src/core/SkVertices.cpp +++ b/src/core/SkVertices.cpp @@ -5,11 +5,21 @@ * found in the LICENSE file. */ +#include "SkAtomics.h" #include "SkVertices.h" #include "SkData.h" #include "SkReader32.h" #include "SkWriter32.h" +static int32_t gNextID = 1; +static int32_t next_id() { + int32_t id; + do { + id = sk_atomic_inc(&gNextID); + } while (id == SK_InvalidGenID); + return id; +} + static size_t compute_arrays_size(int vertexCount, int indexCount, uint32_t builderFlags) { if (vertexCount < 0 || indexCount < 0) { return 0; // signal error @@ -79,6 +89,7 @@ sk_sp SkVertices::Builder::detach() { obj->fColors = fColors; obj->fIndices = fIndices; obj->fBounds.set(fPositions, fVertexCnt); + obj->fUniqueID = next_id(); obj->fVertexCnt = fVertexCnt; obj->fIndexCnt = fIndexCnt; obj->fMode = fMode; -- cgit v1.2.3