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

Public Member Functions

 OffsetImageFilterGM ()
 
- 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 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 32 of file offsetimagefilter.cpp.

Constructor & Destructor Documentation

◆ OffsetImageFilterGM()

OffsetImageFilterGM::OffsetImageFilterGM ( )
inline

Definition at line 34 of file offsetimagefilter.cpp.

34 {
35 this->setBGColor(0xFF000000);
36 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize OffsetImageFilterGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 41 of file offsetimagefilter.cpp.

41{ return SkISize::Make(WIDTH, HEIGHT); }
#define WIDTH
#define HEIGHT
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString OffsetImageFilterGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 39 of file offsetimagefilter.cpp.

39{ return SkString("offsetimagefilter"); }

◆ onDraw()

void OffsetImageFilterGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 49 of file offsetimagefilter.cpp.

49 {
50 canvas->clear(SK_ColorBLACK);
52
53 for (int i = 0; i < 4; i++) {
54 sk_sp<SkImage> image = (i & 0x01) ? fCheckerboard : fBitmap;
55 SkIRect cropRect = SkIRect::MakeXYWH(i * 12,
56 i * 8,
57 image->width() - i * 8,
58 image->height() - i * 12);
61 SkScalar dy = SkIntToScalar(i*10);
62 paint.setImageFilter(SkImageFilters::Offset(dx, dy, std::move(tileInput), &cropRect));
63 DrawClippedImage(canvas, image.get(), paint, 1, cropRect);
64 canvas->translate(SkIntToScalar(image->width() + MARGIN), 0);
65 }
66
67 SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
68 paint.setImageFilter(SkImageFilters::Offset(-5, -10, nullptr, &cropRect));
69 DrawClippedImage(canvas, fBitmap.get(), paint, 2, cropRect);
70 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
T * get() const
Definition: SkRefCnt.h:303
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
sk_sp< const SkImage > image
Definition: SkRecords.h:269
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
#define MARGIN
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 OffsetImageFilterGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 43 of file offsetimagefilter.cpp.

43 {
44 fBitmap = ToolUtils::CreateStringImage(80, 80, 0xD000D000, 15, 65, 96, "e");
45
46 fCheckerboard = ToolUtils::create_checkerboard_image(80, 80, 0xFFA0A0A0, 0xFF404040, 8);
47 }
sk_sp< SkImage > create_checkerboard_image(int w, int h, SkColor c1, SkColor c2, int checkSize)
Definition: ToolUtils.cpp:168
sk_sp< SkImage > CreateStringImage(int w, int h, SkColor c, int x, int y, int textSize, const char *str)

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