Flutter Engine
The Flutter Engine
SkVerticesPriv.h
Go to the documentation of this file.
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
12
14
15class SkReadBuffer;
16class SkWriteBuffer;
17
18struct SkVertices_DeprecatedBone { float values[6]; };
19
20/** Class that adds methods to SkVertices that are only intended for use internal to Skia.
21 This class is purely a privileged window into SkVertices. It should never have additional
22 data members or virtual methods. */
24public:
25 SkVertices::VertexMode mode() const { return fVertices->fMode; }
26
27 bool hasColors() const { return SkToBool(fVertices->fColors); }
28 bool hasTexCoords() const { return SkToBool(fVertices->fTexs); }
29 bool hasIndices() const { return SkToBool(fVertices->fIndices); }
30
31 int vertexCount() const { return fVertices->fVertexCount; }
32 int indexCount() const { return fVertices->fIndexCount; }
33
34 const SkPoint* positions() const { return fVertices->fPositions; }
35 const SkPoint* texCoords() const { return fVertices->fTexs; }
36 const SkColor* colors() const { return fVertices->fColors; }
37 const uint16_t* indices() const { return fVertices->fIndices; }
38
39 // Never called due to RVO in priv(), but must exist for MSVC 2017.
40 SkVerticesPriv(const SkVerticesPriv&) = default;
41
42 void encode(SkWriteBuffer&) const;
44
45private:
46 explicit SkVerticesPriv(SkVertices* vertices) : fVertices(vertices) {}
47 SkVerticesPriv& operator=(const SkVerticesPriv&) = delete;
48
49 // No taking addresses of this type
50 const SkVerticesPriv* operator&() const = delete;
51 SkVerticesPriv* operator&() = delete;
52
53 SkVertices* fVertices;
54
55 friend class SkVertices; // to construct this type
56};
57
59
60inline const SkVerticesPriv SkVertices::priv() const { // NOLINT(readability-const-return-type)
61 return SkVerticesPriv(const_cast<SkVertices*>(this));
62}
63
64#endif
uint32_t SkColor
Definition: SkColor.h:37
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
bool hasColors() const
SkVertices::VertexMode mode() const
bool hasIndices() const
bool hasTexCoords() const
void encode(SkWriteBuffer &) const
Definition: SkVertices.cpp:240
const SkColor * colors() const
const uint16_t * indices() const
const SkPoint * texCoords() const
static sk_sp< SkVertices > Decode(SkReadBuffer &)
Definition: SkVertices.cpp:267
SkVerticesPriv(const SkVerticesPriv &)=default
int indexCount() const
int vertexCount() const
const SkPoint * positions() const
friend class SkVerticesPriv
Definition: SkVertices.h:110
SkVerticesPriv priv()