Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions
SkLineClipper.cpp File Reference
#include "src/core/SkLineClipper.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTo.h"
#include <cstring>
#include <utility>

Go to the source code of this file.

Functions

template<typename T >
T pin_unsorted (T value, T limit0, T limit1)
 
static SkScalar sect_with_horizontal (const SkPoint src[2], SkScalar Y)
 
static SkScalar sect_with_vertical (const SkPoint src[2], SkScalar X)
 
static SkScalar sect_clamp_with_vertical (const SkPoint src[2], SkScalar x)
 
static bool nestedLT (SkScalar a, SkScalar b, SkScalar dim)
 
static bool containsNoEmptyCheck (const SkRect &outer, const SkRect &inner)
 

Function Documentation

◆ containsNoEmptyCheck()

static bool containsNoEmptyCheck ( const SkRect outer,
const SkRect inner 
)
inlinestatic

Definition at line 90 of file SkLineClipper.cpp.

91 {
92 return outer.fLeft <= inner.fLeft && outer.fTop <= inner.fTop &&
93 outer.fRight >= inner.fRight && outer.fBottom >= inner.fBottom;
94}
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ nestedLT()

static bool nestedLT ( SkScalar  a,
SkScalar  b,
SkScalar  dim 
)
inlinestatic

Definition at line 84 of file SkLineClipper.cpp.

84 {
85 return a <= b && (a < b || dim > 0);
86}
static bool b
struct MyStruct a[10]

◆ pin_unsorted()

template<typename T >
T pin_unsorted ( T  value,
T  limit0,
T  limit1 
)

Definition at line 19 of file SkLineClipper.cpp.

19 {
20 if (limit1 < limit0) {
21 using std::swap;
22 swap(limit0, limit1);
23 }
24 // now the limits are sorted
25 SkASSERT(limit0 <= limit1);
26
27 if (value < limit0) {
28 value = limit0;
29 } else if (value > limit1) {
30 value = limit1;
31 }
32 return value;
33}
#define SkASSERT(cond)
Definition: SkAssert.h:116
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
uint8_t value

◆ sect_clamp_with_vertical()

static SkScalar sect_clamp_with_vertical ( const SkPoint  src[2],
SkScalar  x 
)
static

Definition at line 73 of file SkLineClipper.cpp.

73 {
75 // Our caller expects y to be between src[0].fY and src[1].fY (unsorted), but due to the
76 // numerics of floats/doubles, we might have computed a value slightly outside of that,
77 // so we have to manually clamp afterwards.
78 // See skbug.com/7491
79 return pin_unsorted(y, src[0].fY, src[1].fY);
80}
T pin_unsorted(T value, T limit0, T limit1)
static SkScalar sect_with_vertical(const SkPoint src[2], SkScalar X)
float SkScalar
Definition: extension.cpp:12
double y
double x

◆ sect_with_horizontal()

static SkScalar sect_with_horizontal ( const SkPoint  src[2],
SkScalar  Y 
)
static

Definition at line 36 of file SkLineClipper.cpp.

36 {
37 SkScalar dy = src[1].fY - src[0].fY;
38 if (SkScalarNearlyZero(dy)) {
39 return SkScalarAve(src[0].fX, src[1].fX);
40 } else {
41 // need the extra precision so we don't compute a value that exceeds
42 // our original limits
43 double X0 = src[0].fX;
44 double Y0 = src[0].fY;
45 double X1 = src[1].fX;
46 double Y1 = src[1].fY;
47 double result = X0 + ((double)Y - Y0) * (X1 - X0) / (Y1 - Y0);
48
49 // The computed X value might still exceed [X0..X1] due to quantum flux
50 // when the doubles were added and subtracted, so we have to pin the
51 // answer :(
52 return (float)pin_unsorted(result, X0, X1);
53 }
54}
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:101
#define SkScalarAve(a, b)
Definition: SkScalar.h:74
static const SkScalar Y
Definition: StrokeBench.cpp:55
GAsyncResult * result

◆ sect_with_vertical()

static SkScalar sect_with_vertical ( const SkPoint  src[2],
SkScalar  X 
)
static

Definition at line 57 of file SkLineClipper.cpp.

57 {
58 SkScalar dx = src[1].fX - src[0].fX;
60 return SkScalarAve(src[0].fY, src[1].fY);
61 } else {
62 // need the extra precision so we don't compute a value that exceeds
63 // our original limits
64 double X0 = src[0].fX;
65 double Y0 = src[0].fY;
66 double X1 = src[1].fX;
67 double Y1 = src[1].fY;
68 double result = Y0 + ((double)X - X0) * (Y1 - Y0) / (X1 - X0);
69 return (float)result;
70 }
71}
static const SkScalar X
Definition: StrokeBench.cpp:54
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208