From 9a6e42ff18133ef77066b82cb7e2d19788edd968 Mon Sep 17 00:00:00 2001 From: Ruiqi Mao Date: Mon, 9 Jul 2018 14:16:56 -0400 Subject: added caching of SkVertices SkVertices can now be "volatile", meaning they should not be cached. SkVertices is volatile by default if the argument is not given. Pulled from reverted CL: https://skia-review.googlesource.com/c/skia/+/138596 Docs-Preview: https://skia.org/?cl=139545 Bug: skia: Change-Id: I92cf832efe1c0aaa8f432eedde2678582dd2454e Reviewed-on: https://skia-review.googlesource.com/139545 Reviewed-by: Brian Osman Reviewed-by: Robert Phillips Commit-Queue: Ruiqi Mao --- include/core/SkCanvas.h | 4 +++- include/core/SkVertices.h | 30 +++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 90e51e9b0e..abac335a0c 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -6,7 +6,7 @@ */ /* Generated by tools/bookmaker from include/core/SkCanvas.h and docs/SkCanvas_Reference.bmh - on 2018-07-02 10:27:08. Additional documentation and examples can be found at: + on 2018-07-03 11:34:22. Additional documentation and examples can be found at: https://skia.org/user/api/SkCanvas_Reference You may edit either file directly. Structural changes to public interfaces require @@ -2156,6 +2156,7 @@ public: The first element of bones should be an object to world space transformation matrix that will be applied before performing mesh deformations. If no such transformation is needed, it should be the identity matrix. + boneCount must be at most 100, and thus the size of bones should be at most 100. @param vertices triangle mesh to draw @param bones bone matrix data @@ -2173,6 +2174,7 @@ public: The first element of bones should be an object to world space transformation matrix that will be applied before performing mesh deformations. If no such transformation is needed, it should be the identity matrix. + boneCount must be at most 100, and thus the size of bones should be at most 100. @param vertices triangle mesh to draw @param bones bone matrix data diff --git a/include/core/SkVertices.h b/include/core/SkVertices.h index 6c4fb390d0..9c1300b0a5 100644 --- a/include/core/SkVertices.h +++ b/include/core/SkVertices.h @@ -55,14 +55,16 @@ public: const BoneIndices boneIndices[], const BoneWeights boneWeights[], int indexCount, - const uint16_t indices[]); + const uint16_t indices[], + bool isVolatile = true); static sk_sp MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], const BoneIndices boneIndices[], - const BoneWeights boneWeights[]) { + const BoneWeights boneWeights[], + bool isVolatile = true) { return MakeCopy(mode, vertexCount, positions, @@ -71,7 +73,8 @@ public: boneIndices, boneWeights, 0, - nullptr); + nullptr, + isVolatile); } static sk_sp MakeCopy(VertexMode mode, int vertexCount, @@ -79,7 +82,8 @@ public: const SkPoint texs[], const SkColor colors[], int indexCount, - const uint16_t indices[]) { + const uint16_t indices[], + bool isVolatile = true) { return MakeCopy(mode, vertexCount, positions, @@ -88,14 +92,16 @@ public: nullptr, nullptr, indexCount, - indices); + indices, + isVolatile); } static sk_sp MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], - const SkColor colors[]) { - return MakeCopy(mode, vertexCount, positions, texs, colors, nullptr, nullptr); + const SkColor colors[], + bool isVolatile = true) { + return MakeCopy(mode, vertexCount, positions, texs, colors, nullptr, nullptr, isVolatile); } struct Sizes; @@ -104,6 +110,7 @@ public: kHasTexCoords_BuilderFlag = 1 << 0, kHasColors_BuilderFlag = 1 << 1, kHasBones_BuilderFlag = 1 << 2, + kIsNonVolatile_BuilderFlag = 1 << 3, }; class Builder { public: @@ -114,6 +121,7 @@ public: // if the builder is invalid, these will return 0 int vertexCount() const; int indexCount() const; + bool isVolatile() const; SkPoint* positions(); SkPoint* texCoords(); // returns null if there are no texCoords SkColor* colors(); // returns null if there are no colors @@ -125,9 +133,9 @@ public: sk_sp detach(); private: - Builder(VertexMode mode, int vertexCount, int indexCount, const Sizes&); + Builder(VertexMode mode, int vertexCount, int indexCount, bool isVolatile, const Sizes&); - void init(VertexMode mode, int vertexCount, int indexCount, const Sizes&); + void init(VertexMode mode, int vertexCount, int indexCount, bool isVolatile, const Sizes&); // holds a partially complete object. only completed in detach() sk_sp fVertices; @@ -158,6 +166,8 @@ public: int indexCount() const { return fIndexCnt; } const uint16_t* indices() const { return fIndices; } + bool isVolatile() const { return fIsVolatile; } + // returns approximate byte size of the vertices object size_t approximateSize() const; @@ -199,6 +209,8 @@ private: int fVertexCnt; int fIndexCnt; + bool fIsVolatile; + VertexMode fMode; // below here is where the actual array data is stored. }; -- cgit v1.2.3