Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
SkPathRef.cpp File Reference
#include "include/private/SkPathRef.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkRRect.h"
#include "include/private/base/SkFloatingPoint.h"
#include "include/private/base/SkOnce.h"
#include "src/base/SkVx.h"
#include <cstring>

Go to the source code of this file.

Functions

static void transform_dir_and_start (const SkMatrix &matrix, bool isRRect, bool *isCCW, unsigned *start)
 

Variables

static constexpr int kPathRefGenIDBitCnt = 32
 
static SkPathRefgEmpty = nullptr
 

Function Documentation

◆ transform_dir_and_start()

static void transform_dir_and_start ( const SkMatrix matrix,
bool  isRRect,
bool *  isCCW,
unsigned *  start 
)
static

Definition at line 85 of file SkPathRef.cpp.

86 {
87 int inStart = *start;
88 int rm = 0;
89 if (isRRect) {
90 // Degenerate rrect indices to oval indices and remember the remainder.
91 // Ovals have one index per side whereas rrects have two.
92 rm = inStart & 0b1;
93 inStart /= 2;
94 }
95 // Is the antidiagonal non-zero (otherwise the diagonal is zero)
96 int antiDiag;
97 // Is the non-zero value in the top row (either kMScaleX or kMSkewX) negative
98 int topNeg;
99 // Are the two non-zero diagonal or antidiagonal values the same sign.
100 int sameSign;
101 if (matrix.get(SkMatrix::kMScaleX) != 0) {
102 antiDiag = 0b00;
103 if (matrix.get(SkMatrix::kMScaleX) > 0) {
104 topNeg = 0b00;
105 sameSign = matrix.get(SkMatrix::kMScaleY) > 0 ? 0b01 : 0b00;
106 } else {
107 topNeg = 0b10;
108 sameSign = matrix.get(SkMatrix::kMScaleY) > 0 ? 0b00 : 0b01;
109 }
110 } else {
111 antiDiag = 0b01;
112 if (matrix.get(SkMatrix::kMSkewX) > 0) {
113 topNeg = 0b00;
114 sameSign = matrix.get(SkMatrix::kMSkewY) > 0 ? 0b01 : 0b00;
115 } else {
116 topNeg = 0b10;
117 sameSign = matrix.get(SkMatrix::kMSkewY) > 0 ? 0b00 : 0b01;
118 }
119 }
120 if (sameSign != antiDiag) {
121 // This is a rotation (and maybe scale). The direction is unchanged.
122 // Trust me on the start computation (or draw yourself some pictures)
123 *start = (inStart + 4 - (topNeg | antiDiag)) % 4;
124 SkASSERT(*start < 4);
125 if (isRRect) {
126 *start = 2 * *start + rm;
127 }
128 } else {
129 // This is a mirror (and maybe scale). The direction is reversed.
130 *isCCW = !*isCCW;
131 // Trust me on the start computation (or draw yourself some pictures)
132 *start = (6 + (topNeg | antiDiag) - inStart) % 4;
133 SkASSERT(*start < 4);
134 if (isRRect) {
135 *start = 2 * *start + (rm ? 0 : 1);
136 }
137 }
138}
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr int kMScaleX
horizontal scale factor
Definition SkMatrix.h:353
static constexpr int kMSkewY
vertical skew factor
Definition SkMatrix.h:356
static constexpr int kMScaleY
vertical scale factor
Definition SkMatrix.h:357
static constexpr int kMSkewX
horizontal skew factor
Definition SkMatrix.h:354
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258

Variable Documentation

◆ gEmpty

SkPathRef* gEmpty = nullptr
static

Definition at line 74 of file SkPathRef.cpp.

◆ kPathRefGenIDBitCnt

constexpr int kPathRefGenIDBitCnt = 32
staticconstexpr

Definition at line 22 of file SkPathRef.cpp.