Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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)
 
void saveXY (SkFixed x, SkFixed y, SkFixed dY)
 
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
 
SkAnalyticEdgefRiteE
 
SkFixed fX
 
SkFixed fDX
 
SkFixed fUpperX
 
SkFixed fY
 
SkFixed fUpperY
 
SkFixed fLowerY
 
SkFixed fDY
 
SkFixed fSavedX
 
SkFixed fSavedY
 
SkFixed fSavedDY
 
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 114 of file SkAnalyticEdge.h.

Member Function Documentation

◆ keepContinuous()

void SkAnalyticQuadraticEdge::keepContinuous ( )
inline

Definition at line 122 of file SkAnalyticEdge.h.

122 {
123 // We use fX as the starting x to ensure the continuouty.
124 // Without it, we may break the sorted edge list.
126 SkASSERT(SkAbs32(fY - fSnappedY) < SK_Fixed1); // This may differ due to smooth jump
127 fSnappedX = fX;
128 fSnappedY = fY;
129 }
#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 266 of file SkAnalyticEdge.cpp.

266 {
267 fRiteE = nullptr;
268
270 return false;
271 }
282
287
290
291 return this->updateQuadratic();
292}
static const int kDefaultAccuracy
SkAnalyticEdge * fRiteE
static SkFixed SnapY(SkFixed y)
int8_t fWinding
Definition SkEdge.h:44
uint8_t fCurveShift
Definition SkEdge.h:42
int8_t fCurveCount
Definition SkEdge.h:41
SkFixed fQDx
Definition SkEdge.h:72
SkFixed fQDDx
Definition SkEdge.h:73
SkFixed fQLastX
Definition SkEdge.h:74
SkFixed fQDy
Definition SkEdge.h:72
SkFixed fQDDy
Definition SkEdge.h:73
SkFixed fQLastY
Definition SkEdge.h:74
bool setQuadraticWithoutUpdate(const SkPoint pts[3], int shiftUp)
Definition SkEdge.cpp:202
SkFixed fQx
Definition SkEdge.h:71
SkFixed fQy
Definition SkEdge.h:71

◆ updateQuadratic()

bool SkAnalyticQuadraticEdge::updateQuadratic ( )

Definition at line 294 of file SkAnalyticEdge.cpp.

294 {
295 int success = 0; // initialize to fail!
296 int count = fCurveCount;
297 SkFixed oldx = fQEdge.fQx;
298 SkFixed oldy = fQEdge.fQy;
300 SkFixed dy = fQEdge.fQDy;
301 SkFixed newx, newy, newSnappedX, newSnappedY;
302 int shift = fCurveShift;
303
304 SkASSERT(count > 0);
305
306 do {
307 SkFixed slope;
308 if (--count > 0)
309 {
310 newx = oldx + (dx >> shift);
311 newy = oldy + (dy >> shift);
312 if (SkAbs32(dy >> shift) >= SK_Fixed1 * 2) { // only snap when dy is large enough
313 SkFDot6 diffY = SkFixedToFDot6(newy - fSnappedY);
314 slope = diffY ? quick_div(SkFixedToFDot6(newx - fSnappedX), diffY)
315 : SK_MaxS32;
316 newSnappedY = std::min<SkFixed>(fQEdge.fQLastY, SkFixedRoundToFixed(newy));
317 newSnappedX = newx - SkFixedMul(slope, newy - newSnappedY);
318 } else {
319 newSnappedY = std::min(fQEdge.fQLastY, SnapY(newy));
320 newSnappedX = newx;
321 SkFDot6 diffY = SkFixedToFDot6(newSnappedY - fSnappedY);
322 slope = diffY ? quick_div(SkFixedToFDot6(newx - fSnappedX), diffY)
323 : SK_MaxS32;
324 }
325 dx += fQEdge.fQDDx;
326 dy += fQEdge.fQDDy;
327 }
328 else // last segment
329 {
330 newx = fQEdge.fQLastX;
331 newy = fQEdge.fQLastY;
332 newSnappedY = newy;
333 newSnappedX = newx;
334 SkFDot6 diffY = (newy - fSnappedY) >> 10;
335 slope = diffY ? quick_div((newx - fSnappedX) >> 10, diffY) : SK_MaxS32;
336 }
337 if (slope < SK_MaxS32) {
338 success = this->updateLine(fSnappedX, fSnappedY, newSnappedX, newSnappedY, slope);
339 }
340 oldx = newx;
341 oldy = newy;
342 } while (count > 0 && !success);
343
344 SkASSERT(newSnappedY <= fQEdge.fQLastY);
345
346 fQEdge.fQx = newx;
347 fQEdge.fQy = newy;
348 fQEdge.fQDx = dx;
349 fQEdge.fQDy = dy;
350 fSnappedX = newSnappedX;
351 fSnappedY = newSnappedY;
353 return success;
354}
int count
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
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 115 of file SkAnalyticEdge.h.

◆ fSnappedX

SkFixed SkAnalyticQuadraticEdge::fSnappedX

Definition at line 118 of file SkAnalyticEdge.h.

◆ fSnappedY

SkFixed SkAnalyticQuadraticEdge::fSnappedY

Definition at line 118 of file SkAnalyticEdge.h.


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