Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / core / SkVerticesPriv.h
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 class SkReadBuffer;
14 class SkWriteBuffer;
15
16 struct SkVertices_DeprecatedBone { float values[6]; };
17
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 {
22 public:
23     SkVertices::VertexMode mode() const { return fVertices->fMode; }
24
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     int vertexCount() const { return fVertices->fVertexCount; }
30     int indexCount() const { return fVertices->fIndexCount; }
31
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; }
36
37     // Never called due to RVO in priv(), but must exist for MSVC 2017.
38     SkVerticesPriv(const SkVerticesPriv&) = default;
39
40     void encode(SkWriteBuffer&) const;
41     static sk_sp<SkVertices> Decode(SkReadBuffer&);
42
43 private:
44     explicit SkVerticesPriv(SkVertices* vertices) : fVertices(vertices) {}
45     SkVerticesPriv& operator=(const SkVerticesPriv&) = delete;
46
47     // No taking addresses of this type
48     const SkVerticesPriv* operator&() const = delete;
49     SkVerticesPriv* operator&() = delete;
50
51     SkVertices* fVertices;
52
53     friend class SkVertices; // to construct this type
54 };
55
56 inline SkVerticesPriv SkVertices::priv() { return SkVerticesPriv(this); }
57
58 inline const SkVerticesPriv SkVertices::priv() const {  // NOLINT(readability-const-return-type)
59     return SkVerticesPriv(const_cast<SkVertices*>(this));
60 }
61
62 #endif