Flutter Engine
The Flutter Engine
SkStroke.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkStroke_DEFINED
9#define SkStroke_DEFINED
10
17
18#include <cmath>
19#include <cstdint>
20
21class SkPath;
22struct SkRect;
23
24#ifdef SK_DEBUG
25extern bool gDebugStrokerErrorSet;
26extern SkScalar gDebugStrokerError;
27extern int gMaxRecursion[];
28#endif
29
30/** \class SkStroke
31 SkStroke is the utility class that constructs paths by stroking
32 geometries (lines, rects, ovals, roundrects, paths). This is
33 invoked when a geometry or text is drawn in a canvas with the
34 kStroke_Mask bit set in the paint.
35*/
36class SkStroke {
37public:
38 SkStroke();
39 SkStroke(const SkPaint&);
40 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStrokeWidth()
41
42 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; }
43 void setCap(SkPaint::Cap);
44
45 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; }
47
49 void setWidth(SkScalar);
50
51 bool getDoFill() const { return SkToBool(fDoFill); }
52 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
53
54 /**
55 * ResScale is the "intended" resolution for the output.
56 * Default is 1.0.
57 * Larger values (res > 1) indicate that the result should be more precise, since it will
58 * be zoomed up, and small errors will be magnified.
59 * Smaller values (0 < res < 1) indicate that the result can be less precise, since it will
60 * be zoomed down, and small errors may be invisible.
61 */
62 SkScalar getResScale() const { return fResScale; }
64 SkASSERT(rs > 0 && std::isfinite(rs));
65 fResScale = rs;
66 }
67
68 /**
69 * Stroke the specified rect, winding it in the specified direction..
70 */
71 void strokeRect(const SkRect& rect, SkPath* result,
73 void strokePath(const SkPath& path, SkPath*) const;
74
75 ////////////////////////////////////////////////////////////////
76
77private:
78 SkScalar fWidth, fMiterLimit;
79 SkScalar fResScale;
80 uint8_t fCap, fJoin;
81 bool fDoFill;
82
83 friend class SkPaint;
84};
85
86#endif
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkPathDirection
Definition: SkPathTypes.h:34
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
constexpr uint8_t SkToU8(S x)
Definition: SkTo.h:22
Definition: SkPath.h:59
SkPaint::Cap getCap() const
Definition: SkStroke.h:42
void strokePath(const SkPath &path, SkPath *) const
Definition: SkStroke.cpp:1433
SkScalar getResScale() const
Definition: SkStroke.h:62
void setWidth(SkScalar)
Definition: SkStroke.cpp:1385
void setCap(SkPaint::Cap)
Definition: SkStroke.cpp:1395
void setDoFill(bool doFill)
Definition: SkStroke.h:52
void setResScale(SkScalar rs)
Definition: SkStroke.h:63
void setJoin(SkPaint::Join)
Definition: SkStroke.cpp:1400
void strokeRect(const SkRect &rect, SkPath *result, SkPathDirection=SkPathDirection::kCW) const
Definition: SkStroke.cpp:1584
SkPaint::Join getJoin() const
Definition: SkStroke.h:45
bool getDoFill() const
Definition: SkStroke.h:51
void setMiterLimit(SkScalar)
Definition: SkStroke.cpp:1390
float SkScalar
Definition: extension.cpp:12
GAsyncResult * result
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003
int32_t width