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

Public Member Functions

 ImageFiltersCroppedGM ()
 
- 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 make_checkerboard ()
 
void draw_frame (SkCanvas *canvas, const SkRect &r)
 
void onOnceBeforeDraw () override
 
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 75 of file imagefilterscropped.cpp.

Constructor & Destructor Documentation

◆ ImageFiltersCroppedGM()

ImageFiltersCroppedGM::ImageFiltersCroppedGM ( )
inline

Definition at line 77 of file imagefilterscropped.cpp.

77{}

Member Function Documentation

◆ draw_frame()

void ImageFiltersCroppedGM::draw_frame ( SkCanvas canvas,
const SkRect r 
)
inlineprotected

Definition at line 105 of file imagefilterscropped.cpp.

105 {
108 paint.setColor(SK_ColorRED);
109 canvas->drawRect(r, paint);
110 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38

◆ getISize()

SkISize ImageFiltersCroppedGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 82 of file imagefilterscropped.cpp.

82{ return SkISize::Make(400, 960); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString ImageFiltersCroppedGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 80 of file imagefilterscropped.cpp.

80{ return SkString("imagefilterscropped"); }

◆ make_checkerboard()

void ImageFiltersCroppedGM::make_checkerboard ( )
inlineprotected

Definition at line 84 of file imagefilterscropped.cpp.

84 {
86 auto canvas = surf->getCanvas();
87 SkPaint darkPaint;
88 darkPaint.setColor(0xFF404040);
89 SkPaint lightPaint;
90 lightPaint.setColor(0xFFA0A0A0);
91 for (int y = 0; y < 80; y += 16) {
92 for (int x = 0; x < 80; x += 16) {
93 canvas->save();
94 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
95 canvas->drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
96 canvas->drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
97 canvas->drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
98 canvas->drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
99 canvas->restore();
100 }
101 }
102 fCheckerboard = surf->makeImageSnapshot();
103 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void setColor(SkColor color)
Definition: SkPaint.cpp:119
double y
double x
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onDraw()

void ImageFiltersCroppedGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 116 of file imagefilterscropped.cpp.

116 {
117 void (*drawProc[])(SkCanvas*, const SkRect&, sk_sp<SkImageFilter>) = {
119 };
120
123 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44);
124 SkIRect bogusRect = SkIRect::MakeXYWH(-100, -100, 10, 10);
125
127
129
130 // These are composed with an outer erode along the other axis, so don't add a cropRect to
131 // them or it will interfere with the second filter evaluation.
132 sk_sp<SkImageFilter> erodeX(SkImageFilters::Erode(8, 0, nullptr));
133 sk_sp<SkImageFilter> erodeY(SkImageFilters::Erode(0, 8, nullptr));
134
135 sk_sp<SkImageFilter> filters[] = {
136 nullptr,
137 SkImageFilters::ColorFilter(cf, nullptr, &cropRect),
138 SkImageFilters::Blur(0.0f, 0.0f, nullptr, &cropRect),
139 SkImageFilters::Blur(1.0f, 1.0f, nullptr, &cropRect),
140 SkImageFilters::Blur(8.0f, 0.0f, nullptr, &cropRect),
141 SkImageFilters::Blur(0.0f, 8.0f, nullptr, &cropRect),
142 SkImageFilters::Blur(8.0f, 8.0f, nullptr, &cropRect),
143 SkImageFilters::Erode(1, 1, nullptr, &cropRect),
144 SkImageFilters::Erode(8, 0, std::move(erodeY), &cropRect),
145 SkImageFilters::Erode(0, 8, std::move(erodeX), &cropRect),
146 SkImageFilters::Erode(8, 8, nullptr, &cropRect),
147 SkImageFilters::Merge(nullptr, std::move(cfOffset), &cropRect),
148 SkImageFilters::Blur(8.0f, 8.0f, nullptr, &bogusRect),
149 SkImageFilters::ColorFilter(cf, nullptr, &bogusRect),
150 };
151
154 SkScalar DX = r.width() + MARGIN;
155 SkScalar DY = r.height() + MARGIN;
156
157 canvas->translate(MARGIN, MARGIN);
158 for (size_t j = 0; j < std::size(drawProc); ++j) {
159 canvas->save();
160 for (size_t i = 0; i < std::size(filters); ++i) {
162 canvas->drawImage(fCheckerboard, 0, 0);
163 drawProc[j](canvas, r, filters[i]);
164 canvas->translate(0, DY);
165 }
166 canvas->restore();
167 canvas->translate(DX, 0);
168 }
169 }
@ kSrcIn
r = s * da
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Merge(sk_sp< SkImageFilter > *const filters, int count, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
#define MARGIN
float SkScalar
Definition: extension.cpp:12
static void draw_bitmap(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
static void draw_text(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
static void draw_path(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
static void draw_paint(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
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
SeparatedVector2 offset
Definition: SkRect.h:32
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onOnceBeforeDraw()

void ImageFiltersCroppedGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 112 of file imagefilterscropped.cpp.

112 {
114 }

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