diff options
author | 2017-04-03 11:11:09 -0400 | |
---|---|---|
committer | 2017-04-03 15:50:16 +0000 | |
commit | 887cdf112809727c51890ba8b98b3ddce22249f0 (patch) | |
tree | 6ae2774f9ec869f72cf117993eba25c6ef97e28b /include | |
parent | b55dd553124cd00260bc9e3a63ec8a8fe09412a8 (diff) |
move vertex-mode enum into SkVertices
BUG=skia:6366
Change-Id: I3c0bf96cce6d32c9b8d12d16a772aaa6f18981aa
Reviewed-on: https://skia-review.googlesource.com/11062
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkCanvas.h | 2 | ||||
-rw-r--r-- | include/core/SkVertices.h | 46 |
2 files changed, 41 insertions, 7 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index a1ba4c50e7..a40b434739 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -1138,6 +1138,7 @@ public: } #endif +#ifdef SK_SUPPORT_LEGACY_CANVAS_VERTICES enum VertexMode { kTriangles_VertexMode, kTriangleStrip_VertexMode, @@ -1178,6 +1179,7 @@ public: this->drawVertices(vmode, vertexCount, vertices, texs, colors, SkBlendMode::kModulate, indices, indexCount, paint); } +#endif /** Draw vertices from an immutable SkVertices object. diff --git a/include/core/SkVertices.h b/include/core/SkVertices.h index e4b5bcb80b..7006850fbc 100644 --- a/include/core/SkVertices.h +++ b/include/core/SkVertices.h @@ -8,36 +8,64 @@ #ifndef SkVertices_DEFINED #define SkVertices_DEFINED -#include "SkCanvas.h" #include "SkColor.h" #include "SkData.h" #include "SkPoint.h" #include "SkRect.h" #include "SkRefCnt.h" +#ifdef SK_SUPPORT_LEGACY_CANVAS_VERTICES +#include "SkCanvas.h" +#endif + /** * An immutable set of vertex data that can be used with SkCanvas::drawVertices. */ class SkVertices : public SkNVRefCnt<SkVertices> { public: + enum VertexMode { + kTriangles_VertexMode, + kTriangleStrip_VertexMode, + kTriangleFan_VertexMode, + }; + /** * Create a vertices by copying the specified arrays. texs and colors may be nullptr, * and indices is ignored if indexCount == 0. */ - static sk_sp<SkVertices> MakeCopy(SkCanvas::VertexMode mode, int vertexCount, + static sk_sp<SkVertices> MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[]); - static sk_sp<SkVertices> MakeCopy(SkCanvas::VertexMode mode, int vertexCount, + static sk_sp<SkVertices> MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[]) { return MakeCopy(mode, vertexCount, positions, texs, colors, 0, nullptr); } +#ifdef SK_SUPPORT_LEGACY_CANVAS_VERTICES + static sk_sp<SkVertices> MakeCopy(SkCanvas::VertexMode mode, int vertexCount, + const SkPoint positions[], + const SkPoint texs[], + const SkColor colors[], + int indexCount, + const uint16_t indices[]) { + return MakeCopy(static_cast<VertexMode>(mode), vertexCount, positions, texs, colors, + indexCount, indices); + } + + static sk_sp<SkVertices> MakeCopy(SkCanvas::VertexMode mode, int vertexCount, + const SkPoint positions[], + const SkPoint texs[], + const SkColor colors[]) { + return MakeCopy(static_cast<VertexMode>(mode), vertexCount, positions, texs, colors); + } +#endif + struct Sizes; enum BuilderFlags { @@ -46,7 +74,11 @@ public: }; class Builder { public: + Builder(VertexMode mode, int vertexCount, int indexCount, uint32_t flags); + +#ifdef SK_SUPPORT_LEGACY_CANVAS_VERTICES Builder(SkCanvas::VertexMode mode, int vertexCount, int indexCount, uint32_t flags); +#endif bool isValid() const { return fVertices != nullptr; } @@ -62,9 +94,9 @@ public: sk_sp<SkVertices> detach(); private: - Builder(SkCanvas::VertexMode mode, int vertexCount, int indexCount, const Sizes&); + Builder(VertexMode mode, int vertexCount, int indexCount, const Sizes&); - void init(SkCanvas::VertexMode mode, int vertexCount, int indexCount, const Sizes&); + void init(VertexMode mode, int vertexCount, int indexCount, const Sizes&); // holds a partially complete object. only completed in detach() sk_sp<SkVertices> fVertices; @@ -73,7 +105,7 @@ public: }; uint32_t uniqueID() const { return fUniqueID; } - SkCanvas::VertexMode mode() const { return fMode; } + VertexMode mode() const { return fMode; } const SkRect& bounds() const { return fBounds; } bool hasColors() const { return SkToBool(this->colors()); } @@ -127,7 +159,7 @@ private: int fVertexCnt; int fIndexCnt; - SkCanvas::VertexMode fMode; + VertexMode fMode; // below here is where the actual array data is stored. }; |