Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkDrawProcs.h File Reference
#include "include/core/SkPaint.h"
#include "include/core/SkScalar.h"

Go to the source code of this file.

Functions

bool SkDrawTreatAAStrokeAsHairline (SkScalar strokeWidth, const SkMatrix &, SkScalar *coverage)
 
bool SkDrawTreatAsHairline (const SkPaint &paint, const SkMatrix &matrix, SkScalar *coverage)
 

Function Documentation

◆ SkDrawTreatAAStrokeAsHairline()

bool SkDrawTreatAAStrokeAsHairline ( SkScalar  strokeWidth,
const SkMatrix matrix,
SkScalar coverage 
)

Definition at line 262 of file SkDrawBase.cpp.

263 {
265 // We need to try to fake a thick-stroke with a modulated hairline.
266
267 if (matrix.hasPerspective()) {
268 return false;
269 }
270
271 SkVector src[2], dst[2];
272 src[0].set(strokeWidth, 0);
273 src[1].set(0, strokeWidth);
274 matrix.mapVectors(dst, src, 2);
275 SkScalar len0 = fast_len(dst[0]);
276 SkScalar len1 = fast_len(dst[1]);
277 if (len0 <= SK_Scalar1 && len1 <= SK_Scalar1) {
278 if (coverage) {
279 *coverage = SkScalarAve(len0, len1);
280 }
281 return true;
282 }
283 return false;
284}
static const int strokeWidth
Definition BlurTest.cpp:60
#define SkASSERT(cond)
Definition SkAssert.h:116
static SkScalar fast_len(const SkVector &vec)
#define SK_Scalar1
Definition SkScalar.h:18
#define SkScalarAve(a, b)
Definition SkScalar.h:74
float SkScalar
Definition extension.cpp:12
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
dst
Definition cp.py:12

◆ SkDrawTreatAsHairline()

bool SkDrawTreatAsHairline ( const SkPaint paint,
const SkMatrix matrix,
SkScalar coverage 
)
inline

If the current paint is set to stroke and the stroke-width when applied to the matrix is <= 1.0, then this returns true, and sets coverage (simulating a stroke by drawing a hairline with partial coverage). If any of these conditions are false, then this returns false and coverage is ignored.

Definition at line 24 of file SkDrawProcs.h.

25 {
26 if (SkPaint::kStroke_Style != paint.getStyle()) {
27 return false;
28 }
29
30 SkScalar strokeWidth = paint.getStrokeWidth();
31 if (0 == strokeWidth) {
33 return true;
34 }
35
36 if (!paint.isAntiAlias()) {
37 return false;
38 }
39
40 return SkDrawTreatAAStrokeAsHairline(strokeWidth, matrix, coverage);
41}
bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix &, SkScalar *coverage)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
const Paint & paint