1 | /* |
---|---|
2 | * Copyright 2018 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 SkRRectPriv_DEFINED |
9 | #define SkRRectPriv_DEFINED |
10 | |
11 | #include "include/core/SkRRect.h" |
12 | |
13 | class SkRBuffer; |
14 | class SkWBuffer; |
15 | |
16 | class SkRRectPriv { |
17 | public: |
18 | static bool IsCircle(const SkRRect& rr) { |
19 | return rr.isOval() && SkScalarNearlyEqual(rr.fRadii[0].fX, rr.fRadii[0].fY); |
20 | } |
21 | |
22 | static SkVector GetSimpleRadii(const SkRRect& rr) { |
23 | SkASSERT(!rr.isComplex()); |
24 | return rr.fRadii[0]; |
25 | } |
26 | |
27 | static bool IsSimpleCircular(const SkRRect& rr) { |
28 | return rr.isSimple() && SkScalarNearlyEqual(rr.fRadii[0].fX, rr.fRadii[0].fY); |
29 | } |
30 | |
31 | static bool EqualRadii(const SkRRect& rr) { |
32 | return rr.isRect() || SkRRectPriv::IsCircle(rr) || SkRRectPriv::IsSimpleCircular(rr); |
33 | } |
34 | |
35 | static const SkVector* GetRadiiArray(const SkRRect& rr) { return rr.fRadii; } |
36 | |
37 | static bool AllCornersCircular(const SkRRect& rr, SkScalar tolerance = SK_ScalarNearlyZero); |
38 | |
39 | static bool ReadFromBuffer(SkRBuffer* buffer, SkRRect* rr); |
40 | |
41 | static void WriteToBuffer(const SkRRect& rr, SkWBuffer* buffer); |
42 | }; |
43 | |
44 | #endif |
45 | |
46 |