Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
SkAnalyticQuadraticEdge Struct Reference

#include <SkAnalyticEdge.h>

Inheritance diagram for SkAnalyticQuadraticEdge:
SkAnalyticEdge

Public Member Functions

bool setQuadratic (const SkPoint pts[3])
 
bool updateQuadratic ()
 
void keepContinuous ()
 
- Public Member Functions inherited from SkAnalyticEdge
void goY (SkFixed y)
 
void goY (SkFixed y, int yShift)
 
bool setLine (const SkPoint &p0, const SkPoint &p1)
 
bool updateLine (SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by, SkFixed slope)
 
bool update (SkFixed last_y, bool sortY=true)
 

Public Attributes

SkQuadraticEdge fQEdge
 
SkFixed fSnappedX
 
SkFixed fSnappedY
 
- Public Attributes inherited from SkAnalyticEdge
SkAnalyticEdgefNext
 
SkAnalyticEdgefPrev
 
SkFixed fX
 
SkFixed fDX
 
SkFixed fUpperX
 
SkFixed fY
 
SkFixed fUpperY
 
SkFixed fLowerY
 
SkFixed fDY
 
Type fEdgeType
 
int8_t fCurveCount
 
uint8_t fCurveShift
 
uint8_t fCubicDShift
 
int8_t fWinding
 

Additional Inherited Members

- Public Types inherited from SkAnalyticEdge
enum  Type { kLine_Type , kQuad_Type , kCubic_Type }
 
- Static Public Member Functions inherited from SkAnalyticEdge
static SkFixed SnapY (SkFixed y)
 
- Static Public Attributes inherited from SkAnalyticEdge
static const int kDefaultAccuracy = 2
 

Detailed Description

Definition at line 100 of file SkAnalyticEdge.h.

Member Function Documentation

◆ keepContinuous()

void SkAnalyticQuadraticEdge::keepContinuous ( )
inline

Definition at line 108 of file SkAnalyticEdge.h.

108 {
109 // We use fX as the starting x to ensure the continuouty.
110 // Without it, we may break the sorted edge list.
112 SkASSERT(SkAbs32(fY - fSnappedY) < SK_Fixed1); // This may differ due to smooth jump
113 fSnappedX = fX;
114 fSnappedY = fY;
115 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SK_Fixed1
Definition: SkFixed.h:26
static SkFixed SkFixedMul(SkFixed a, SkFixed b)
Definition: SkFixed.h:96
static int32_t SkAbs32(int32_t value)
Definition: SkSafe32.h:41

◆ setQuadratic()

bool SkAnalyticQuadraticEdge::setQuadratic ( const SkPoint  pts[3])

Definition at line 264 of file SkAnalyticEdge.cpp.

264 {
266 return false;
267 }
278
283
286
287 return this->updateQuadratic();
288}
static const int kDefaultAccuracy
uint8_t fCurveShift
static SkFixed SnapY(SkFixed y)
SkQuadraticEdge fQEdge
int8_t fWinding
Definition: SkEdge.h:45
uint8_t fCurveShift
Definition: SkEdge.h:43
int8_t fCurveCount
Definition: SkEdge.h:42
SkFixed fQDx
Definition: SkEdge.h:73
SkFixed fQDDx
Definition: SkEdge.h:74
SkFixed fQLastX
Definition: SkEdge.h:75
SkFixed fQDy
Definition: SkEdge.h:73
SkFixed fQDDy
Definition: SkEdge.h:74
SkFixed fQLastY
Definition: SkEdge.h:75
bool setQuadraticWithoutUpdate(const SkPoint pts[3], int shiftUp)
Definition: SkEdge.cpp:202
SkFixed fQx
Definition: SkEdge.h:72
SkFixed fQy
Definition: SkEdge.h:72

◆ updateQuadratic()

bool SkAnalyticQuadraticEdge::updateQuadratic ( )

Definition at line 290 of file SkAnalyticEdge.cpp.

290 {
291 int success = 0; // initialize to fail!
292 int count = fCurveCount;
293 SkFixed oldx = fQEdge.fQx;
294 SkFixed oldy = fQEdge.fQy;
296 SkFixed dy = fQEdge.fQDy;
297 SkFixed newx, newy, newSnappedX, newSnappedY;
298 int shift = fCurveShift;
299
300 SkASSERT(count > 0);
301
302 do {
303 SkFixed slope;
304 if (--count > 0)
305 {
306 newx = oldx + (dx >> shift);
307 newy = oldy + (dy >> shift);
308 if (SkAbs32(dy >> shift) >= SK_Fixed1 * 2) { // only snap when dy is large enough
309 SkFDot6 diffY = SkFixedToFDot6(newy - fSnappedY);
310 slope = diffY ? quick_div(SkFixedToFDot6(newx - fSnappedX), diffY)
311 : SK_MaxS32;
312 newSnappedY = std::min<SkFixed>(fQEdge.fQLastY, SkFixedRoundToFixed(newy));
313 newSnappedX = newx - SkFixedMul(slope, newy - newSnappedY);
314 } else {
315 newSnappedY = std::min(fQEdge.fQLastY, SnapY(newy));
316 newSnappedX = newx;
317 SkFDot6 diffY = SkFixedToFDot6(newSnappedY - fSnappedY);
318 slope = diffY ? quick_div(SkFixedToFDot6(newx - fSnappedX), diffY)
319 : SK_MaxS32;
320 }
321 dx += fQEdge.fQDDx;
322 dy += fQEdge.fQDDy;
323 }
324 else // last segment
325 {
326 newx = fQEdge.fQLastX;
327 newy = fQEdge.fQLastY;
328 newSnappedY = newy;
329 newSnappedX = newx;
330 SkFDot6 diffY = (newy - fSnappedY) >> 10;
331 slope = diffY ? quick_div((newx - fSnappedX) >> 10, diffY) : SK_MaxS32;
332 }
333 if (slope < SK_MaxS32) {
334 success = this->updateLine(fSnappedX, fSnappedY, newSnappedX, newSnappedY, slope);
335 }
336 oldx = newx;
337 oldy = newy;
338 } while (count > 0 && !success);
339
340 SkASSERT(newSnappedY <= fQEdge.fQLastY);
341
342 fQEdge.fQx = newx;
343 fQEdge.fQy = newy;
344 fQEdge.fQDx = dx;
345 fQEdge.fQDy = dy;
346 fSnappedX = newSnappedX;
347 fSnappedY = newSnappedY;
349 return success;
350}
int count
Definition: FontMgrTest.cpp:50
static SkFixed quick_div(SkFDot6 a, SkFDot6 b)
#define SkFixedToFDot6(x)
Definition: SkFDot6.h:56
int32_t SkFDot6
Definition: SkFDot6.h:16
int32_t SkFixed
Definition: SkFixed.h:25
static SkFixed SkFixedRoundToFixed(SkFixed x)
Definition: SkFixed.h:80
static constexpr int32_t SK_MaxS32
Definition: SkMath.h:21
constexpr int8_t SkToS8(S x)
Definition: SkTo.h:21
static float min(float r, float g, float b)
Definition: hsl.cpp:48
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
bool updateLine(SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by, SkFixed slope)

Member Data Documentation

◆ fQEdge

SkQuadraticEdge SkAnalyticQuadraticEdge::fQEdge

Definition at line 101 of file SkAnalyticEdge.h.

◆ fSnappedX

SkFixed SkAnalyticQuadraticEdge::fSnappedX

Definition at line 104 of file SkAnalyticEdge.h.

◆ fSnappedY

SkFixed SkAnalyticQuadraticEdge::fSnappedY

Definition at line 104 of file SkAnalyticEdge.h.


The documentation for this struct was generated from the following files: