Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
SkScaleToSides Class Reference

#include <SkScaleToSides.h>

Static Public Member Functions

static void AdjustRadii (double limit, double scale, SkScalar *a, SkScalar *b)
 

Detailed Description

Definition at line 17 of file SkScaleToSides.h.

Member Function Documentation

◆ AdjustRadii()

static void SkScaleToSides::AdjustRadii ( double  limit,
double  scale,
SkScalar a,
SkScalar b 
)
inlinestatic

Definition at line 23 of file SkScaleToSides.h.

23 {
24 SkASSERTF(scale < 1.0 && scale > 0.0, "scale: %g", scale);
25
26 *a = (float)((double)*a * scale);
27 *b = (float)((double)*b * scale);
28
29 if (*a + *b > limit) {
30 float* minRadius = a;
31 float* maxRadius = b;
32
33 // Force minRadius to be the smaller of the two.
34 if (*minRadius > *maxRadius) {
35 using std::swap;
36 swap(minRadius, maxRadius);
37 }
38
39 // newMinRadius must be float in order to give the actual value of the radius.
40 // The newMinRadius will always be smaller than limit. The largest that minRadius can be
41 // is 1/2 the ratio of minRadius : (minRadius + maxRadius), therefore in the resulting
42 // division, minRadius can be no larger than 1/2 limit + ULP.
43 float newMinRadius = *minRadius;
44
45 float newMaxRadius = (float)(limit - newMinRadius);
46
47 // Reduce newMaxRadius an ulp at a time until it fits. This usually never happens,
48 // but if it does it could be 1 or 2 times. In certain pathological cases it could be
49 // more. Max iterations seen so far is 17.
50 while (newMaxRadius + newMinRadius > limit) {
51 newMaxRadius = nextafterf(newMaxRadius, 0.0f);
52 }
53 *maxRadius = newMaxRadius;
54 }
55
56 SkASSERTF(*a >= 0.0f && *b >= 0.0f, "a: %g, b: %g, limit: %g, scale: %g", *a, *b, limit,
57 scale);
58
59 SkASSERTF(*a + *b <= limit,
60 "\nlimit: %.17f, sum: %.17f, a: %.10f, b: %.10f, scale: %.20f",
61 limit, *a + *b, *a, *b, scale);
62 }
#define SkASSERTF(cond, fmt,...)
Definition SkAssert.h:117
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition SkRefCnt.h:341
static bool b
struct MyStruct a[10]
const Scalar scale

The documentation for this class was generated from the following file: