Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
16
17#include <cmath>
18#include <cstdint>
19
20class SkPath;
21struct SkRect;
22
23#ifdef SK_DEBUG
24extern bool gDebugStrokerErrorSet;
25extern SkScalar gDebugStrokerError;
26extern int gMaxRecursion[];
27#endif
28
29/** \class SkStroke
30 SkStroke is the utility class that constructs paths by stroking
31 geometries (lines, rects, ovals, roundrects, paths). This is
32 invoked when a geometry or text is drawn in a canvas with the
33 kStroke_Mask bit set in the paint.
34*/
35class SkStroke {
36public:
37 SkStroke();
38 SkStroke(const SkPaint&);
39 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStrokeWidth()
40
41 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; }
42 void setCap(SkPaint::Cap);
43
44 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; }
46
48 void setWidth(SkScalar);
49
50 bool getDoFill() const { return SkToBool(fDoFill); }
51 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
52
53 /**
54 * ResScale is the "intended" resolution for the output.
55 * Default is 1.0.
56 * Larger values (res > 1) indicate that the result should be more precise, since it will
57 * be zoomed up, and small errors will be magnified.
58 * Smaller values (0 < res < 1) indicate that the result can be less precise, since it will
59 * be zoomed down, and small errors may be invisible.
60 */
61 SkScalar getResScale() const { return fResScale; }
63 SkASSERT(rs > 0 && std::isfinite(rs));
64 fResScale = rs;
65 }
66
67 /**
68 * Stroke the specified rect, winding it in the specified direction..
69 */
70 void strokeRect(const SkRect& rect, SkPath* result,
72 void strokePath(const SkPath& path, SkPath*) const;
73
74 ////////////////////////////////////////////////////////////////
75
76private:
77 SkScalar fWidth, fMiterLimit;
78 SkScalar fResScale;
79 uint8_t fCap, fJoin;
80 bool fDoFill;
81
82 friend class SkPaint;
83};
84
85#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
SkPaint::Cap getCap() const
Definition SkStroke.h:41
void strokePath(const SkPath &path, SkPath *) const
SkScalar getResScale() const
Definition SkStroke.h:61
void setWidth(SkScalar)
void setCap(SkPaint::Cap)
void setDoFill(bool doFill)
Definition SkStroke.h:51
void setResScale(SkScalar rs)
Definition SkStroke.h:62
void setJoin(SkPaint::Join)
void strokeRect(const SkRect &rect, SkPath *result, SkPathDirection=SkPathDirection::kCW) const
SkPaint::Join getJoin() const
Definition SkStroke.h:44
bool getDoFill() const
Definition SkStroke.h:50
void setMiterLimit(SkScalar)
float SkScalar
Definition extension.cpp:12
GAsyncResult * result
int32_t width