Flutter Engine
The Flutter Engine
SkRRectPriv.h
Go to the documentation of this file.
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
12
13class SkRBuffer;
14class SkWBuffer;
15
17public:
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 // Looser version of IsSimpleCircular, where the x & y values of the radii
32 // only have to be nearly equal instead of strictly equal.
33 static bool IsNearlySimpleCircular(const SkRRect& rr, SkScalar tolerance = SK_ScalarNearlyZero);
34
35 static bool EqualRadii(const SkRRect& rr) {
37 }
38
39 static const SkVector* GetRadiiArray(const SkRRect& rr) { return rr.fRadii; }
40
41 static bool AllCornersCircular(const SkRRect& rr, SkScalar tolerance = SK_ScalarNearlyZero);
42
43 static bool ReadFromBuffer(SkRBuffer* buffer, SkRRect* rr);
44
45 static void WriteToBuffer(const SkRRect& rr, SkWBuffer* buffer);
46
47 // Test if a point is in the rrect, if it were a closed set.
48 static bool ContainsPoint(const SkRRect& rr, const SkPoint& p) {
49 return rr.getBounds().contains(p.fX, p.fY) && rr.checkCornerContainment(p.fX, p.fY);
50 }
51
52 // Compute an approximate largest inscribed bounding box of the rounded rect. For empty,
53 // rect, oval, and simple types this will be the largest inscribed rectangle. Otherwise it may
54 // not be the global maximum, but will be non-empty, touch at least one edge and be contained
55 // in the round rect.
56 static SkRect InnerBounds(const SkRRect& rr);
57
58 // Attempt to compute the intersection of two round rects. The intersection is not necessarily
59 // a round rect. This returns intersections only when the shape is representable as a new
60 // round rect (or rect). Empty is returned if 'a' and 'b' do not intersect or if the
61 // intersection is too complicated. This is conservative, it may not always detect that an
62 // intersection could be represented as a round rect. However, when it does return a round rect
63 // that intersection will be exact (i.e. it is NOT just a subset of the actual intersection).
64 static SkRRect ConservativeIntersect(const SkRRect& a, const SkRRect& b);
65};
66
67#endif
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:107
#define SK_ScalarNearlyZero
Definition: SkScalar.h:99
static bool EqualRadii(const SkRRect &rr)
Definition: SkRRectPriv.h:35
static bool ReadFromBuffer(SkRBuffer *buffer, SkRRect *rr)
Definition: SkRRect.cpp:623
static bool IsSimpleCircular(const SkRRect &rr)
Definition: SkRRectPriv.h:27
static SkRect InnerBounds(const SkRRect &rr)
Definition: SkRRect.cpp:750
static SkVector GetSimpleRadii(const SkRRect &rr)
Definition: SkRRectPriv.h:22
static const SkVector * GetRadiiArray(const SkRRect &rr)
Definition: SkRRectPriv.h:39
static SkRRect ConservativeIntersect(const SkRRect &a, const SkRRect &b)
Definition: SkRRect.cpp:812
static bool IsNearlySimpleCircular(const SkRRect &rr, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkRRect.cpp:342
static bool AllCornersCircular(const SkRRect &rr, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkRRect.cpp:353
static bool IsCircle(const SkRRect &rr)
Definition: SkRRectPriv.h:18
static void WriteToBuffer(const SkRRect &rr, SkWBuffer *buffer)
Definition: SkRRect.cpp:605
static bool ContainsPoint(const SkRRect &rr, const SkPoint &p)
Definition: SkRRectPriv.h:48
bool isOval() const
Definition: SkRRect.h:85
bool isRect() const
Definition: SkRRect.h:84
const SkRect & getBounds() const
Definition: SkRRect.h:279
bool isSimple() const
Definition: SkRRect.h:86
bool isComplex() const
Definition: SkRRect.h:88
float SkScalar
Definition: extension.cpp:12
static bool b
struct MyStruct a[10]
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
bool contains(SkScalar x, SkScalar y) const
Definition: extension.cpp:19