aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-03-14 21:05:17 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-15 01:32:38 +0000
commit9a8065d34dd090837c2a05bc60533fcc6268e6bb (patch)
tree1159fe5ece68e428aaf6d528de38825728d5245c /src/core
parent64b974836a594c4f14384ded399ff09e96160215 (diff)
add uniqueID
BUG=skia:6366 Change-Id: Ie3215a392040be645524a2294d824d953ba3a1b6 Reviewed-on: https://skia-review.googlesource.com/9703 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkVertices.cpp11
1 files changed, 11 insertions, 0 deletions
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> 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;