Flutter Engine
The Flutter Engine
Functions
SkDrawBase.cpp File Reference
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkPathUtils.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkStrokeRec.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkCPUTypes.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkFloatingPoint.h"
#include "include/private/base/SkTemplates.h"
#include "src/base/SkTLazy.h"
#include "src/base/SkZip.h"
#include "src/core/SkAutoBlitterChoose.h"
#include "src/core/SkBlendModePriv.h"
#include "src/core/SkBlitter_A8.h"
#include "src/core/SkDevice.h"
#include "src/core/SkDrawBase.h"
#include "src/core/SkDrawProcs.h"
#include "src/core/SkMask.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkPathEffectBase.h"
#include "src/core/SkPathPriv.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkRectPriv.h"
#include "src/core/SkScan.h"
#include <algorithm>
#include <cstddef>
#include <optional>

Go to the source code of this file.

Functions

static SkPoint compute_stroke_size (const SkPaint &paint, const SkMatrix &matrix)
 
static bool easy_rect_join (const SkRect &rect, const SkPaint &paint, const SkMatrix &matrix, SkPoint *strokeSize)
 
static const SkPointrect_points (const SkRect &r)
 
static SkPointrect_points (SkRect &r)
 
static void draw_rect_as_path (const SkDrawBase &orig, const SkRect &prePaintRect, const SkPaint &paint, const SkMatrix &ctm)
 
static SkScalar fast_len (const SkVector &vec)
 
bool SkDrawTreatAAStrokeAsHairline (SkScalar strokeWidth, const SkMatrix &matrix, SkScalar *coverage)
 
static void draw_into_mask (const SkMask &mask, const SkPath &devPath, SkStrokeRec::InitStyle style)
 

Function Documentation

◆ compute_stroke_size()

static SkPoint compute_stroke_size ( const SkPaint paint,
const SkMatrix matrix 
)
inlinestatic

Definition at line 90 of file SkDrawBase.cpp.

90 {
91 SkASSERT(matrix.rectStaysRect());
92 SkASSERT(SkPaint::kFill_Style != paint.getStyle());
93
95 SkPoint pt = { paint.getStrokeWidth(), paint.getStrokeWidth() };
96 matrix.mapVectors(&size, &pt, 1);
98}
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkScalarAbs(x)
Definition: SkScalar.h:39
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
const Paint & paint
Definition: color_source.cc:38
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

◆ draw_into_mask()

static void draw_into_mask ( const SkMask mask,
const SkPath devPath,
SkStrokeRec::InitStyle  style 
)
static

Definition at line 527 of file SkDrawBase.cpp.

528 {
530 draw.fBlitterChooser = SkA8Blitter_Choose;
531 if (!draw.fDst.reset(mask)) {
532 return;
533 }
534
538
539 clip.setRect(SkIRect::MakeWH(mask.fBounds.width(), mask.fBounds.height()));
540 matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
541 -SkIntToScalar(mask.fBounds.fTop));
542
543 draw.fRC = &clip;
544 draw.fCTM = &matrix;
545 paint.setAntiAlias(true);
546 switch (style) {
548 SkASSERT(!paint.getStrokeWidth());
550 break;
552 SkASSERT(paint.getStyle() == SkPaint::kFill_Style);
553 break;
554
555 }
556 draw.drawPath(devPath, paint);
557}
SkBlitter * SkA8Blitter_Choose(const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *alloc, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kHairline_InitStyle
Definition: SkStrokeRec.h:25
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
constexpr int32_t width() const
Definition: SkRect.h:158
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
const SkIRect fBounds
Definition: SkMask.h:42

◆ draw_rect_as_path()

static void draw_rect_as_path ( const SkDrawBase orig,
const SkRect prePaintRect,
const SkPaint paint,
const SkMatrix ctm 
)
static

Definition at line 147 of file SkDrawBase.cpp.

150 {
151 SkDrawBase draw(orig);
152 draw.fCTM = &ctm;
153 SkPath tmp;
154 tmp.addRect(prePaintRect);
156 draw.drawPath(tmp, paint, nullptr, true);
157}
Definition: SkPath.h:59
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition: SkPath.cpp:864

◆ easy_rect_join()

static bool easy_rect_join ( const SkRect rect,
const SkPaint paint,
const SkMatrix matrix,
SkPoint strokeSize 
)
static

Definition at line 100 of file SkDrawBase.cpp.

101 {
102 if (rect.isEmpty() || SkPaint::kMiter_Join != paint.getStrokeJoin() ||
103 paint.getStrokeMiter() < SK_ScalarSqrt2) {
104 return false;
105 }
106
107 *strokeSize = compute_stroke_size(paint, matrix);
108 return true;
109}
static SkPoint compute_stroke_size(const SkPaint &paint, const SkMatrix &matrix)
Definition: SkDrawBase.cpp:90
#define SK_ScalarSqrt2
Definition: SkScalar.h:20
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ fast_len()

static SkScalar fast_len ( const SkVector vec)
static

Definition at line 252 of file SkDrawBase.cpp.

252 {
253 SkScalar x = SkScalarAbs(vec.fX);
254 SkScalar y = SkScalarAbs(vec.fY);
255 if (x < y) {
256 using std::swap;
257 swap(x, y);
258 }
259 return x + SkScalarHalf(y);
260}
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
#define SkScalarHalf(a)
Definition: SkScalar.h:75
float SkScalar
Definition: extension.cpp:12
double y
double x
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ rect_points() [1/2]

static const SkPoint * rect_points ( const SkRect r)
static

Definition at line 139 of file SkDrawBase.cpp.

139 {
140 return reinterpret_cast<const SkPoint*>(&r);
141}

◆ rect_points() [2/2]

static SkPoint * rect_points ( SkRect r)
static

Definition at line 143 of file SkDrawBase.cpp.

143 {
144 return reinterpret_cast<SkPoint*>(&r);
145}

◆ 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
static SkScalar fast_len(const SkVector &vec)
Definition: SkDrawBase.cpp:252
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkScalarAve(a, b)
Definition: SkScalar.h:74
dst
Definition: cp.py:12