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

Public Member Functions

 SimpleOffsetImageFilterGM ()
 
- 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 doDraw (SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imgf, const SkIRect *cropR=nullptr, const SkRect *clipR=nullptr)
 
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 102 of file offsetimagefilter.cpp.

Constructor & Destructor Documentation

◆ SimpleOffsetImageFilterGM()

SimpleOffsetImageFilterGM::SimpleOffsetImageFilterGM ( )
inline

Definition at line 104 of file offsetimagefilter.cpp.

104{}

Member Function Documentation

◆ doDraw()

void SimpleOffsetImageFilterGM::doDraw ( SkCanvas canvas,
const SkRect r,
sk_sp< SkImageFilter imgf,
const SkIRect cropR = nullptr,
const SkRect clipR = nullptr 
)
inlineprotected

Definition at line 111 of file offsetimagefilter.cpp.

112 {
113 SkPaint p;
114
115 if (clipR) {
116 p.setColor(0xFF00FF00);
117 p.setStyle(SkPaint::kStroke_Style);
119 p.setStyle(SkPaint::kFill_Style);
120 }
121
122 // Visualize the crop rect for debugging
123 if (imgf && cropR) {
124 p.setColor(0x66FF00FF);
125 p.setStyle(SkPaint::kStroke_Style);
126
128 canvas->drawRect(cr, p);
129 p.setStyle(SkPaint::kFill_Style);
130 }
131
132 p.setColor(0x660000FF);
133 canvas->drawRect(r, p);
134
135 if (clipR) {
136 canvas->save();
137 canvas->clipRect(*clipR);
138 }
139 if (imgf) {
140 p.setImageFilter(std::move(imgf));
141 }
142 p.setColor(0x66FF0000);
143 canvas->drawRect(r, p);
144
145 if (clipR) {
146 canvas->restore();
147 }
148 }
#define SK_ScalarHalf
Definition: SkScalar.h:19
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
int save()
Definition: SkCanvas.cpp:447
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
SkRect makeInset(float dx, float dy) const
Definition: SkRect.h:987

◆ getISize()

SkISize SimpleOffsetImageFilterGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 109 of file offsetimagefilter.cpp.

109{ return SkISize::Make(640, 200); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString SimpleOffsetImageFilterGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 107 of file offsetimagefilter.cpp.

107{ return SkString("simple-offsetimagefilter"); }

◆ onDraw()

void SimpleOffsetImageFilterGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 150 of file offsetimagefilter.cpp.

150 {
151 SkIRect cr0 = SkIRect::MakeWH(40, 40);
152 SkIRect cr1 = SkIRect::MakeWH(20, 20);
153 SkIRect cr2 = SkIRect::MakeXYWH(40, 0, 40, 40);
154 const SkRect r = SkRect::Make(cr0);
155 const SkRect r2 = SkRect::Make(cr2);
156
157 canvas->translate(40, 40);
158
159 canvas->save();
160 this->doDraw(canvas, r, nullptr);
161
162 canvas->translate(100, 0);
163 this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr));
164
165 canvas->translate(100, 0);
166 this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr0), &cr0);
167
168 canvas->translate(100, 0);
169 this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr), /* cropR */ nullptr, &r);
170
171 canvas->translate(100, 0);
172 this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr1), &cr1);
173
174 SkRect clipR = SkRect::MakeXYWH(40, 40, 40, 40);
175 canvas->translate(100, 0);
176 this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr), /* cropR */ nullptr, &clipR);
177 canvas->restore();
178
179 // 2nd row
180 canvas->translate(0, 80);
181
182 /*
183 * combos of clip and crop rects that align with src and dst
184 */
185
186 // crop==clip==src
187 this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &cr0, &r);
188
189 // crop==src, clip==dst
190 canvas->translate(100, 0);
191 this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &cr0, &r2);
192
193 // crop==dst, clip==src
194 canvas->translate(100, 0);
195 this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &cr2, &r);
196
197 // crop==clip==dst
198 canvas->translate(100, 0);
199 this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &cr2, &r2);
200 }
void doDraw(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imgf, const SkIRect *cropR=nullptr, const SkRect *clipR=nullptr)
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Definition: SkRect.h:32
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
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: