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

Public Member Functions

 MorphologyGM ()
 
- 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
 
void onOnceBeforeDraw () override
 
SkISize getISize () override
 
void drawClippedBitmap (SkCanvas *canvas, const SkPaint &paint, int x, int y)
 
void onDraw (SkCanvas *canvas) 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

Definition at line 29 of file morphology.cpp.

Constructor & Destructor Documentation

◆ MorphologyGM()

skiagm::MorphologyGM::MorphologyGM ( )
inline

Definition at line 31 of file morphology.cpp.

31 {
32 this->setBGColor(0xFF000000);
33 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ drawClippedBitmap()

void skiagm::MorphologyGM::drawClippedBitmap ( SkCanvas canvas,
const SkPaint paint,
int  x,
int  y 
)
inlineprotected

Definition at line 52 of file morphology.cpp.

52 {
53 canvas->save();
55 canvas->clipIRect(fImage->bounds());
56 canvas->drawImage(fImage, 0, 0, SkSamplingOptions(), &paint);
57 canvas->restore();
58 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.h:991
int save()
Definition: SkCanvas.cpp:447
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkIRect bounds() const
Definition: SkImage.h:303
const Paint & paint
Definition: color_source.cc:38
double y
double x
SkSamplingOptions(SkFilterMode::kLinear))

◆ getISize()

SkISize skiagm::MorphologyGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 50 of file morphology.cpp.

50{ return SkISize::Make(WIDTH, HEIGHT); }
#define WIDTH
Definition: morphology.cpp:24
#define HEIGHT
Definition: morphology.cpp:25
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::MorphologyGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 36 of file morphology.cpp.

36{ return SkString("morphology"); }

◆ onDraw()

void skiagm::MorphologyGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 60 of file morphology.cpp.

60 {
61 struct {
62 int fWidth, fHeight;
63 int fRadiusX, fRadiusY;
64 } samples[] = {
65 { 140, 140, 0, 0 },
66 { 140, 140, 0, 2 },
67 { 140, 140, 2, 0 },
68 { 140, 140, 2, 2 },
69 { 24, 24, 25, 25 },
70 };
72 SkIRect cropRect = SkIRect::MakeXYWH(25, 20, 100, 80);
73
74 for (unsigned j = 0; j < 4; ++j) {
75 for (unsigned i = 0; i < std::size(samples); ++i) {
76 const SkIRect* cr = j & 0x02 ? &cropRect : nullptr;
77 if (j & 0x01) {
78 paint.setImageFilter(SkImageFilters::Erode(
79 samples[i].fRadiusX, samples[i].fRadiusY, nullptr, cr));
80 } else {
81 paint.setImageFilter(SkImageFilters::Dilate(
82 samples[i].fRadiusX, samples[i].fRadiusY, nullptr, cr));
83 }
84 this->drawClippedBitmap(canvas, paint, i * 140, j * 140);
85 }
86 }
87 }
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
void drawClippedBitmap(SkCanvas *canvas, const SkPaint &paint, int x, int y)
Definition: morphology.cpp:52
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
Definition: SkRect.h:32
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104

◆ onOnceBeforeDraw()

void skiagm::MorphologyGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 38 of file morphology.cpp.

38 {
40
43 paint.setColor(0xFFFFFFFF);
44 surf->getCanvas()->drawString("ABC", 10, 55, font, paint);
45 surf->getCanvas()->drawString("XYZ", 10, 110, font, paint);
46
47 fImage = surf->makeImageSnapshot();
48 }
Definition: SkFont.h:35
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.
static SkImageInfo MakeN32Premul(int width, int height)

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