1 | /* |
---|---|
2 | * Copyright 2020 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #ifndef SkVerticesPriv_DEFINED |
9 | #define SkVerticesPriv_DEFINED |
10 | |
11 | #include "include/core/SkVertices.h" |
12 | |
13 | struct SkVertices_DeprecatedBoneIndices { uint32_t values[4]; }; |
14 | struct SkVertices_DeprecatedBoneWeights { float values[4]; }; |
15 | struct SkVertices_DeprecatedBone { float values[6]; }; |
16 | |
17 | /** Class that adds methods to SkVertices that are only intended for use internal to Skia. |
18 | This class is purely a privileged window into SkVertices. It should never have additional |
19 | data members or virtual methods. */ |
20 | class SkVerticesPriv { |
21 | public: |
22 | SkVertices::VertexMode mode() const { return fVertices->fMode; } |
23 | |
24 | bool hasCustomData() const { return SkToBool(fVertices->fCustomData); } |
25 | bool hasColors() const { return SkToBool(fVertices->fColors); } |
26 | bool hasTexCoords() const { return SkToBool(fVertices->fTexs); } |
27 | bool hasIndices() const { return SkToBool(fVertices->fIndices); } |
28 | |
29 | bool hasUsage(SkVertices::Attribute::Usage) const; |
30 | bool usesLocalToWorldMatrix() const; |
31 | |
32 | int vertexCount() const { return fVertices->fVertexCount; } |
33 | int indexCount() const { return fVertices->fIndexCount; } |
34 | int attributeCount() const { return fVertices->fAttributeCount; } |
35 | size_t customDataSize() const; |
36 | |
37 | const SkPoint* positions() const { return fVertices->fPositions; } |
38 | const void* customData() const { return fVertices->fCustomData; } |
39 | const SkPoint* texCoords() const { return fVertices->fTexs; } |
40 | const SkColor* colors() const { return fVertices->fColors; } |
41 | const uint16_t* indices() const { return fVertices->fIndices; } |
42 | const SkVertices::Attribute* attributes() const { return fVertices->fAttributes; } |
43 | |
44 | // Never called due to RVO in priv(), but must exist for MSVC 2017. |
45 | SkVerticesPriv(const SkVerticesPriv&) = default; |
46 | |
47 | private: |
48 | explicit SkVerticesPriv(SkVertices* vertices) : fVertices(vertices) {} |
49 | SkVerticesPriv& operator=(const SkVerticesPriv&) = delete; |
50 | |
51 | // No taking addresses of this type |
52 | const SkVerticesPriv* operator&() const = delete; |
53 | SkVerticesPriv* operator&() = delete; |
54 | |
55 | SkVertices* fVertices; |
56 | |
57 | friend class SkVertices; // to construct this type |
58 | }; |
59 | |
60 | inline SkVerticesPriv SkVertices::priv() { return SkVerticesPriv(this); } |
61 | |
62 | inline const SkVerticesPriv SkVertices::priv() const { |
63 | return SkVerticesPriv(const_cast<SkVertices*>(this)); |
64 | } |
65 | |
66 | #endif |
67 |