Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
PtProcRec Struct Reference

Public Types

typedef void(* Proc) (const PtProcRec &, const SkPoint devPts[], int count, SkBlitter *)
 

Public Member Functions

bool init (SkCanvas::PointMode, const SkPaint &, const SkMatrix *matrix, const SkRasterClip *)
 
Proc chooseProc (SkBlitter **blitter)
 

Public Attributes

SkCanvas::PointMode fMode
 
const SkPaintfPaint
 
const SkRegionfClip
 
const SkRasterClipfRC
 
SkRect fClipBounds
 
SkScalar fRadius
 

Detailed Description

Definition at line 56 of file SkDraw.cpp.

Member Typedef Documentation

◆ Proc

typedef void(* PtProcRec::Proc) (const PtProcRec &, const SkPoint devPts[], int count, SkBlitter *)

Definition at line 66 of file SkDraw.cpp.

Member Function Documentation

◆ chooseProc()

PtProcRec::Proc PtProcRec::chooseProc ( SkBlitter **  blitter)

Definition at line 191 of file SkDraw.cpp.

191 {
192 Proc proc = nullptr;
193
194 SkBlitter* blitter = *blitterPtr;
195 if (fRC->isBW()) {
196 fClip = &fRC->bwRgn();
197 } else {
198 fWrapper.init(*fRC, blitter);
199 fClip = &fWrapper.getRgn();
200 blitter = fWrapper.getBlitter();
201 *blitterPtr = blitter;
202 }
203
204 // for our arrays
208 SkASSERT((unsigned)fMode <= (unsigned)SkCanvas::kPolygon_PointMode);
209
210 if (fPaint->isAntiAlias()) {
211 if (0 == fPaint->getStrokeWidth()) {
212 static const Proc gAAProcs[] = {
214 };
215 proc = gAAProcs[fMode];
216 } else if (fPaint->getStrokeCap() != SkPaint::kRound_Cap) {
218 proc = aa_square_proc;
219 }
220 } else { // BW
221 if (fRadius <= 0.5f) { // small radii and hairline
222 static const Proc gBWProcs[] = {
224 };
225 proc = gBWProcs[fMode];
226 } else {
227 proc = bw_square_proc;
228 }
229 }
230 return proc;
231}
#define SkASSERT(cond)
Definition SkAssert.h:116
static void aa_poly_hair_proc(const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
Definition SkDraw.cpp:109
static void bw_pt_hair_proc(const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
Definition SkDraw.cpp:77
static void bw_line_hair_proc(const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
Definition SkDraw.cpp:88
static void aa_line_hair_proc(const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
Definition SkDraw.cpp:102
static void bw_square_proc(const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
Definition SkDraw.cpp:131
static void aa_square_proc(const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
Definition SkDraw.cpp:141
static void bw_poly_hair_proc(const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
Definition SkDraw.cpp:95
void init(const SkRasterClip &, SkBlitter *)
const SkRegion & getRgn() const
SkBlitter * getBlitter()
@ kLines_PointMode
draw each pair of points as a line segment
Definition SkCanvas.h:1242
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition SkCanvas.h:1243
@ kPoints_PointMode
draw each point separately
Definition SkCanvas.h:1241
@ kRound_Cap
adds circle
Definition SkPaint.h:335
bool isAntiAlias() const
Definition SkPaint.h:162
SkScalar getStrokeWidth() const
Definition SkPaint.h:300
Cap getStrokeCap() const
Definition SkPaint.h:372
const SkRegion & bwRgn() const
bool isBW() const
const SkPaint * fPaint
Definition SkDraw.cpp:58
void(* Proc)(const PtProcRec &, const SkPoint devPts[], int count, SkBlitter *)
Definition SkDraw.cpp:66
const SkRasterClip * fRC
Definition SkDraw.cpp:60
SkScalar fRadius
Definition SkDraw.cpp:64
const SkRegion * fClip
Definition SkDraw.cpp:59
SkCanvas::PointMode fMode
Definition SkDraw.cpp:57

◆ init()

bool PtProcRec::init ( SkCanvas::PointMode  mode,
const SkPaint paint,
const SkMatrix matrix,
const SkRasterClip rc 
)

Definition at line 152 of file SkDraw.cpp.

153 {
154 if ((unsigned)mode > (unsigned)SkCanvas::kPolygon_PointMode) {
155 return false;
156 }
157 if (paint.getPathEffect() || paint.getMaskFilter()) {
158 return false;
159 }
160 SkScalar width = paint.getStrokeWidth();
161 SkScalar radius = -1; // sentinel value, a "valid" value must be > 0
162
163 if (0 == width) {
164 radius = 0.5f;
165 } else if (paint.getStrokeCap() != SkPaint::kRound_Cap &&
166 matrix->isScaleTranslate() && SkCanvas::kPoints_PointMode == mode) {
169 if (SkScalarNearlyZero(sx - sy)) {
170 radius = SkScalarHalf(width * SkScalarAbs(sx));
171 }
172 }
173 if (radius > 0) {
174 SkRect clipBounds = SkRect::Make(rc->getBounds());
175 // if we return true, the caller may assume that the constructed shapes can be represented
176 // using SkFixed (after clipping), so we preflight that here.
177 if (!SkRectPriv::FitsInFixed(clipBounds)) {
178 return false;
179 }
180 fMode = mode;
181 fPaint = &paint;
182 fClip = nullptr;
183 fRC = rc;
184 fClipBounds = clipBounds;
185 fRadius = radius;
186 return true;
187 }
188 return false;
189}
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:101
#define SkScalarHalf(a)
Definition SkScalar.h:75
#define SkScalarAbs(x)
Definition SkScalar.h:39
static constexpr int kMScaleX
horizontal scale factor
Definition SkMatrix.h:353
static constexpr int kMScaleY
vertical scale factor
Definition SkMatrix.h:357
static bool FitsInFixed(const SkRect &r)
Definition SkRectPriv.h:56
const Paint & paint
float SkScalar
Definition extension.cpp:12
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition switches.h:228
int32_t width
SkRect fClipBounds
Definition SkDraw.cpp:63
static SkRect Make(const SkISize &size)
Definition SkRect.h:669

Member Data Documentation

◆ fClip

const SkRegion* PtProcRec::fClip

Definition at line 59 of file SkDraw.cpp.

◆ fClipBounds

SkRect PtProcRec::fClipBounds

Definition at line 63 of file SkDraw.cpp.

◆ fMode

SkCanvas::PointMode PtProcRec::fMode

Definition at line 57 of file SkDraw.cpp.

◆ fPaint

const SkPaint* PtProcRec::fPaint

Definition at line 58 of file SkDraw.cpp.

◆ fRadius

SkScalar PtProcRec::fRadius

Definition at line 64 of file SkDraw.cpp.

◆ fRC

const SkRasterClip* PtProcRec::fRC

Definition at line 60 of file SkDraw.cpp.


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