Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
preservefillrule.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2019 Google LLC.
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
#include "
gm/gm.h
"
9
10
#include "
include/core/SkPath.h
"
11
#include "
include/gpu/GrContextOptions.h
"
12
#include "
include/gpu/GrRecordingContext.h
"
13
#include "
src/core/SkCanvasPriv.h
"
14
#include "
src/gpu/ganesh/GrDirectContextPriv.h
"
15
#include "
src/gpu/ganesh/GrDrawingManager.h
"
16
#include "
src/gpu/ganesh/GrRecordingContextPriv.h
"
17
#include "
src/gpu/ganesh/SurfaceDrawContext.h
"
18
#include "
tools/ToolUtils.h
"
19
20
namespace
skiagm
{
21
22
#define ERR_MSG_ASSERT(COND) \
23
do { \
24
if (!(COND)) { \
25
errorMsg->printf("preservefillrule.cpp(%i): assert(%s)", \
26
__LINE__, #COND); \
27
return DrawResult::kFail; \
28
} \
29
} while (false)
30
31
32
/**
33
* This test originally ensured that the ccpr path cache preserved fill rules properly. CCPR is gone
34
* now, but we decided to keep the test.
35
*/
36
class
PreserveFillRuleGM
:
public
GM
{
37
public
:
38
PreserveFillRuleGM
(
bool
big) : fBig(big) , fStarSize((big) ? 200 : 20) {}
39
40
private
:
41
SkString
getName
()
const override
{
42
SkString
name
(
"preservefillrule"
);
43
name
+= (fBig) ?
"_big"
:
"_little"
;
44
return
name
;
45
}
46
SkISize
getISize
()
override
{
return
SkISize::Make
(fStarSize * 2, fStarSize * 2); }
47
48
void
modifyGrContextOptions
(
GrContextOptions
* ctxOptions)
override
{
49
ctxOptions->
fAllowPathMaskCaching
=
true
;
50
}
51
52
void
onDraw
(
SkCanvas
* canvas)
override
{
53
auto
starRect =
SkRect::MakeWH
(fStarSize, fStarSize);
54
SkPath
star7_winding =
ToolUtils::make_star
(starRect, 7);
55
star7_winding.
setFillType
(
SkPathFillType::kWinding
);
56
57
SkPath
star7_evenOdd = star7_winding;
58
star7_evenOdd.
transform
(
SkMatrix::Translate
(0, fStarSize));
59
star7_evenOdd.
setFillType
(
SkPathFillType::kEvenOdd
);
60
61
SkPath
star5_winding =
ToolUtils::make_star
(starRect, 5);
62
star5_winding.
transform
(
SkMatrix::Translate
(fStarSize, 0));
63
star5_winding.
setFillType
(
SkPathFillType::kWinding
);
64
65
SkPath
star5_evenOdd = star5_winding;
66
star5_evenOdd.
transform
(
SkMatrix::Translate
(0, fStarSize));
67
star5_evenOdd.
setFillType
(
SkPathFillType::kEvenOdd
);
68
69
SkPaint
paint
;
70
paint
.setColor(
SK_ColorGREEN
);
71
paint
.setAntiAlias(
true
);
72
73
canvas->
clear
(
SK_ColorWHITE
);
74
canvas->
drawPath
(star7_winding,
paint
);
75
canvas->
drawPath
(star7_evenOdd,
paint
);
76
canvas->
drawPath
(star5_winding,
paint
);
77
canvas->
drawPath
(star5_evenOdd,
paint
);
78
79
auto
dContext =
GrAsDirectContext
(canvas->
recordingContext
());
80
if
(dContext) {
81
dContext->flush();
82
}
83
}
84
85
private
:
86
const
bool
fBig;
87
const
int
fStarSize;
88
};
89
90
DEF_GM
(
return
new
PreserveFillRuleGM(
true
); )
91
DEF_GM
(
return
new
PreserveFillRuleGM(
false
); )
92
93
}
// namespace skiagm
GrContextOptions.h
GrDirectContextPriv.h
GrDrawingManager.h
GrRecordingContextPriv.h
GrRecordingContext.h
GrAsDirectContext
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
Definition
GrRecordingContext.h:281
SkCanvasPriv.h
SK_ColorGREEN
constexpr SkColor SK_ColorGREEN
Definition
SkColor.h:131
SK_ColorWHITE
constexpr SkColor SK_ColorWHITE
Definition
SkColor.h:122
SkPathFillType::kWinding
@ kWinding
SkPathFillType::kEvenOdd
@ kEvenOdd
SkPath.h
SurfaceDrawContext.h
ToolUtils.h
SkCanvas
Definition
SkCanvas.h:106
SkCanvas::recordingContext
virtual GrRecordingContext * recordingContext() const
Definition
SkCanvas.cpp:1961
SkCanvas::clear
void clear(SkColor color)
Definition
SkCanvas.h:1199
SkCanvas::drawPath
void drawPath(const SkPath &path, const SkPaint &paint)
Definition
SkCanvas.cpp:2071
SkMatrix::Translate
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition
SkMatrix.h:91
SkPaint
Definition
SkPaint.h:44
SkPath
Definition
SkPath.h:59
SkPath::setFillType
void setFillType(SkPathFillType ft)
Definition
SkPath.h:235
SkPath::transform
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition
SkPath.cpp:1647
SkString
Definition
SkString.h:118
skiagm::GM
Definition
gm.h:110
skiagm::PreserveFillRuleGM
Definition
preservefillrule.cpp:36
skiagm::PreserveFillRuleGM::getName
SkString getName() const override
Definition
preservefillrule.cpp:41
skiagm::PreserveFillRuleGM::PreserveFillRuleGM
PreserveFillRuleGM(bool big)
Definition
preservefillrule.cpp:38
skiagm::PreserveFillRuleGM::modifyGrContextOptions
void modifyGrContextOptions(GrContextOptions *ctxOptions) override
Definition
preservefillrule.cpp:48
skiagm::PreserveFillRuleGM::onDraw
void onDraw(SkCanvas *canvas) override
Definition
preservefillrule.cpp:52
skiagm::PreserveFillRuleGM::getISize
SkISize getISize() override
Definition
preservefillrule.cpp:46
paint
const Paint & paint
Definition
color_source.cc:38
name
const char * name
Definition
fuchsia.cc:50
gm.h
DEF_GM
#define DEF_GM(CODE)
Definition
gm.h:40
ToolUtils::make_star
SkPath make_star(const SkRect &bounds, int numPts, int step)
Definition
ToolUtils.cpp:269
skiagm
Definition
DMSrcSink.h:27
GrContextOptions
Definition
GrContextOptions.h:23
GrContextOptions::fAllowPathMaskCaching
bool fAllowPathMaskCaching
Definition
GrContextOptions.h:136
SkISize
Definition
SkSize.h:16
SkISize::Make
static constexpr SkISize Make(int32_t w, int32_t h)
Definition
SkSize.h:20
SkRect::MakeWH
static constexpr SkRect MakeWH(float w, float h)
Definition
SkRect.h:609
Generated on Fri Apr 26 2024 06:16:08 for Flutter Engine by
1.9.8