2 * Copyright 2020 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkVerticesPriv_DEFINED
9 #define SkVerticesPriv_DEFINED
11 #include "include/core/SkVertices.h"
16 struct SkVertices_DeprecatedBone { float values[6]; };
18 /** Class that adds methods to SkVertices that are only intended for use internal to Skia.
19 This class is purely a privileged window into SkVertices. It should never have additional
20 data members or virtual methods. */
21 class SkVerticesPriv {
23 SkVertices::VertexMode mode() const { return fVertices->fMode; }
25 bool hasColors() const { return SkToBool(fVertices->fColors); }
26 bool hasTexCoords() const { return SkToBool(fVertices->fTexs); }
27 bool hasIndices() const { return SkToBool(fVertices->fIndices); }
29 int vertexCount() const { return fVertices->fVertexCount; }
30 int indexCount() const { return fVertices->fIndexCount; }
32 const SkPoint* positions() const { return fVertices->fPositions; }
33 const SkPoint* texCoords() const { return fVertices->fTexs; }
34 const SkColor* colors() const { return fVertices->fColors; }
35 const uint16_t* indices() const { return fVertices->fIndices; }
37 // Never called due to RVO in priv(), but must exist for MSVC 2017.
38 SkVerticesPriv(const SkVerticesPriv&) = default;
40 void encode(SkWriteBuffer&) const;
41 static sk_sp<SkVertices> Decode(SkReadBuffer&);
44 explicit SkVerticesPriv(SkVertices* vertices) : fVertices(vertices) {}
45 SkVerticesPriv& operator=(const SkVerticesPriv&) = delete;
47 // No taking addresses of this type
48 const SkVerticesPriv* operator&() const = delete;
49 SkVerticesPriv* operator&() = delete;
51 SkVertices* fVertices;
53 friend class SkVertices; // to construct this type
56 inline SkVerticesPriv SkVertices::priv() { return SkVerticesPriv(this); }
58 inline const SkVerticesPriv SkVertices::priv() const { // NOLINT(readability-const-return-type)
59 return SkVerticesPriv(const_cast<SkVertices*>(this));