SkCanvas::VertexMode mode() const { return fMode; }
+ uint32_t uniqueID() const { return fUniqueID; }
int vertexCount() const { return fVertexCnt; }
bool hasColors() const { return SkToBool(fColors); }
bool hasTexCoords() const { return SkToBool(fTexs); }
const SkRect& bounds() const { return fBounds; }
-
static sk_sp<SkVertices> Decode(const void*, size_t);
sk_sp<SkData> encode() const;
const SkColor* fColors;
const uint16_t* fIndices;
SkRect fBounds;
+ uint32_t fUniqueID;
int fVertexCnt;
int fIndexCnt;
SkCanvas::VertexMode fMode;
* 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
obj->fColors = fColors;
obj->fIndices = fIndices;
obj->fBounds.set(fPositions, fVertexCnt);
+ obj->fUniqueID = next_id();
obj->fVertexCnt = fVertexCnt;
obj->fIndexCnt = fIndexCnt;
obj->fMode = fMode;
sk_sp<SkData> data = v0->encode();
sk_sp<SkVertices> v1 = SkVertices::Decode(data->data(), data->size());
+ REPORTER_ASSERT(reporter, v0->uniqueID() != 0);
+ REPORTER_ASSERT(reporter, v1->uniqueID() != 0);
+ REPORTER_ASSERT(reporter, v0->uniqueID() != v1->uniqueID());
REPORTER_ASSERT(reporter, equal(v0.get(), v1.get()));
}
}