Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
PathMaskCache Class Reference
Inheritance diagram for PathMaskCache:
skiagm::GM

Public Member Functions

 PathMaskCache ()
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 
void modifyGrContextOptions (GrContextOptions *options) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

This tests the GPU backend's caching of path coverage masks

Definition at line 24 of file pathmaskcache.cpp.

Constructor & Destructor Documentation

◆ PathMaskCache()

PathMaskCache::PathMaskCache ( )
inline

Definition at line 26 of file pathmaskcache.cpp.

26{}

Member Function Documentation

◆ getISize()

SkISize PathMaskCache::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 31 of file pathmaskcache.cpp.

31{ return SkISize::Make(650, 950); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString PathMaskCache::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 29 of file pathmaskcache.cpp.

29{ return SkString("path_mask_cache"); }

◆ modifyGrContextOptions()

void PathMaskCache::modifyGrContextOptions ( GrContextOptions options)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 111 of file pathmaskcache.cpp.

111 {
112 options->fGpuPathRenderers = GpuPathRenderers::kNone;
113 options->fAllowPathMaskCaching = true;
114 }
const char * options

◆ onDraw()

void PathMaskCache::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 33 of file pathmaskcache.cpp.

33 {
34 static constexpr SkScalar kPad = 5.f;
35
37 paint.setAntiAlias(true);
38 auto drawPathSet = [canvas] (const SkPath& path, const SkMatrix& m) {
40 paint.setAntiAlias(true);
41 SkRect bounds = path.getBounds();
42 m.mapRect(&bounds);
43 bounds.roundOut();
44 canvas->save();
45 canvas->translate(-bounds.fLeft, -bounds.fTop);
46
47 canvas->save();
48 canvas->concat(m);
49 canvas->drawPath(path, paint);
50 canvas->restore();
51
52 // translate by integer
53 canvas->translate(bounds.width() + kPad, 0.f);
54 canvas->save();
55 canvas->concat(m);
56 canvas->drawPath(path, paint);
57 canvas->restore();
58
59 // translate by non-integer
60 canvas->translate(bounds.width() + kPad + 0.15f, 0.f);
61 canvas->save();
62 canvas->concat(m);
63 canvas->drawPath(path, paint);
64 canvas->restore();
65
66 // translate again so total translate fraction is almost identical to previous.
67 canvas->translate(bounds.width() + kPad + 0.002f, 0.f);
68 canvas->save();
69 canvas->concat(m);
70 canvas->drawPath(path, paint);
71 canvas->restore();
72 canvas->restore();
73 return bounds.fBottom + kPad;
74 };
75
76
77 TArray<SkPath> paths;
78 paths.push_back();
79 paths.back().moveTo(0.f, 0.f);
80 paths.back().lineTo(98.f, 100.f);
81 paths.back().lineTo(100.f, 100.f);
82 paths.back().conicTo(150.f, 50.f, 100.f, 0.f, 0.6f);
83 paths.back().conicTo(148.f, 50.f, 100.f, 100.f, 0.6f);
84 paths.back().conicTo(50.f, 30.f, 0.f, 100.f, 0.9f);
85
86 paths.push_back();
87 paths.back().addCircle(30.f, 30.f, 30.f);
88 paths.back().addRect(SkRect::MakeXYWH(45.f, 45.f, 50.f, 60.f));
90
91 canvas->translate(kPad, kPad);
92
93 for (const SkPath& path : paths) {
94 SkScalar ty = drawPathSet(path, SkMatrix::I());
95 canvas->translate(0, ty);
96
97 // Non-uniform scale.
98 SkMatrix s;
99 s.setScale(0.5f, 2.f);
100 ty = drawPathSet(path, s);
101 canvas->translate(0.f, ty);
102
103 // Rotation
104 SkMatrix r;
105 r.setRotate(60.f, path.getBounds().centerX(), path.getBounds().centerY());
106 ty = drawPathSet(path, r);
107 canvas->translate(0.f, ty);
108 }
109 }
constexpr int kPad
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:452
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
Definition: SkPath.h:59
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1213
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
Definition: SkPath.cpp:766
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition: SkPath.cpp:864
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
struct MyStruct s
Optional< SkRect > bounds
Definition: SkRecords.h:189
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
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

The documentation for this class was generated from the following file: