Flutter Engine
The Flutter Engine
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>
#include <utility>

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 86 of file SkPathRef.cpp.

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

◆ kPathRefGenIDBitCnt

constexpr int kPathRefGenIDBitCnt = 32
staticconstexpr

Definition at line 23 of file SkPathRef.cpp.