Flutter Engine
The Flutter Engine
Macros | Functions
SkEdge.cpp File Reference
#include "src/core/SkEdge.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkMathPriv.h"
#include "src/core/SkFDot6.h"
#include <algorithm>
#include <utility>

Go to the source code of this file.

Macros

#define MAX_COEFF_SHIFT   6
 

Functions

static SkFixed SkFDot6ToFixedDiv2 (SkFDot6 value)
 
static SkFDot6 cheap_distance (SkFDot6 dx, SkFDot6 dy)
 
static int diff_to_shift (SkFDot6 dx, SkFDot6 dy, int shiftAA=2)
 
static int SkFDot6UpShift (SkFDot6 x, int upShift)
 
static SkFDot6 cubic_delta_from_line (SkFDot6 a, SkFDot6 b, SkFDot6 c, SkFDot6 d)
 

Macro Definition Documentation

◆ MAX_COEFF_SHIFT

#define MAX_COEFF_SHIFT   6

Definition at line 171 of file SkEdge.cpp.

Function Documentation

◆ cheap_distance()

static SkFDot6 cheap_distance ( SkFDot6  dx,
SkFDot6  dy 
)
inlinestatic

Definition at line 173 of file SkEdge.cpp.

174{
175 dx = SkAbs32(dx);
176 dy = SkAbs32(dy);
177 // return max + min/2
178 if (dx > dy)
179 dx += dy >> 1;
180 else
181 dx = dy + (dx >> 1);
182 return dx;
183}
static int32_t SkAbs32(int32_t value)
Definition: SkSafe32.h:41
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208

◆ cubic_delta_from_line()

static SkFDot6 cubic_delta_from_line ( SkFDot6  a,
SkFDot6  b,
SkFDot6  c,
SkFDot6  d 
)
static

Definition at line 364 of file SkEdge.cpp.

365{
366 // since our parameters may be negative, we don't use << to avoid ASAN warnings
367 SkFDot6 oneThird = (a*8 - b*15 + 6*c + d) * 19 >> 9;
368 SkFDot6 twoThird = (a + 6*b - c*15 + d*8) * 19 >> 9;
369
370 return std::max(SkAbs32(oneThird), SkAbs32(twoThird));
371}
int32_t SkFDot6
Definition: SkFDot6.h:16
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
static bool b
struct MyStruct a[10]
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ diff_to_shift()

static int diff_to_shift ( SkFDot6  dx,
SkFDot6  dy,
int  shiftAA = 2 
)
inlinestatic

Definition at line 185 of file SkEdge.cpp.

186{
187 // cheap calc of distance from center of p0-p2 to the center of the curve
188 SkFDot6 dist = cheap_distance(dx, dy);
189
190 // shift down dist (it is currently in dot6)
191 // down by 3 should give us 1/8 pixel accuracy (assuming our dist is accurate...)
192 // this is chosen by heuristic: make it as big as possible (to minimize segments)
193 // ... but small enough so that our curves still look smooth
194 // When shift > 0, we're using AA and everything is scaled up so we can
195 // lower the accuracy.
196 dist = (dist + (1 << (2 + shiftAA))) >> (3 + shiftAA);
197
198 // each subdivision (shift value) cuts this dist (error) by 1/4
199 return (32 - SkCLZ(dist)) >> 1;
200}
static SkFDot6 cheap_distance(SkFDot6 dx, SkFDot6 dy)
Definition: SkEdge.cpp:173
static int SkCLZ(uint32_t mask)
Definition: SkMathPriv.h:186

◆ SkFDot6ToFixedDiv2()

static SkFixed SkFDot6ToFixedDiv2 ( SkFDot6  value)
inlinestatic

Definition at line 30 of file SkEdge.cpp.

30 {
31 // we want to return SkFDot6ToFixed(value >> 1), but we don't want to throw
32 // away data in value, so just perform a modify up-shift
33 return SkLeftShift(value, 16 - 6 - 1);
34}
static constexpr int32_t SkLeftShift(int32_t value, int32_t shift)
Definition: SkMath.h:37
uint8_t value

◆ SkFDot6UpShift()

static int SkFDot6UpShift ( SkFDot6  x,
int  upShift 
)
inlinestatic

Definition at line 351 of file SkEdge.cpp.

351 {
352 SkASSERT((SkLeftShift(x, upShift) >> upShift) == x);
353 return SkLeftShift(x, upShift);
354}
#define SkASSERT(cond)
Definition: SkAssert.h:116
double x