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

Protected Member Functions

void onOnceBeforeDraw () override
 
SkString getName () const override
 
SkISize getISize () 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
 
- 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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 49 of file bitmapshader.cpp.

Member Function Documentation

◆ getISize()

SkISize skiagm::BitmapShaderGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 60 of file bitmapshader.cpp.

60{ return SkISize::Make(150, 100); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 58 of file bitmapshader.cpp.

58{ return SkString("bitmapshaders"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 62 of file bitmapshader.cpp.

62 {
64
65 for (int i = 0; i < 2; i++) {
66 SkMatrix s;
67 s.reset();
68 if (1 == i) {
69 s.setScale(1.5f, 1.5f);
70 s.postTranslate(2, 2);
71 }
72
73 canvas->save();
74 paint.setShader(fImage->makeShader(SkSamplingOptions(), s));
75
76 // draw the shader with a bitmap mask
77 canvas->drawImage(fMask, 0, 0, SkSamplingOptions(), &paint);
78 // no blue circle expected (the bitmap shader's coordinates are aligned to CTM still)
79 canvas->drawImage(fMask, 30, 0, SkSamplingOptions(), &paint);
80
81 canvas->translate(0, 25);
82
83 canvas->drawCircle(10, 10, 10, paint);
84 canvas->drawCircle(40, 10, 10, paint); // no blue circle expected
85
86 canvas->translate(0, 25);
87
88 // clear the shader, colorized by a solid color with a bitmap mask
89 paint.setShader(nullptr);
90 paint.setColor(SK_ColorGREEN);
91 canvas->drawImage(fMask, 0, 0, SkSamplingOptions(), &paint);
92 canvas->drawImage(fMask, 30, 0, SkSamplingOptions(), &paint);
93
94 canvas->translate(0, 25);
95
98 paint.setColor(SK_ColorRED);
99
100 // draw the mask using the shader and a color
101 canvas->drawRect(SkRect::MakeXYWH(0, 0, 20, 20), paint);
102 canvas->drawRect(SkRect::MakeXYWH(30, 0, 20, 20), paint);
103 canvas->restore();
104 canvas->translate(60, 0);
105 }
106 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
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
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
const Paint & paint
Definition: color_source.cc:38
struct MyStruct s
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onOnceBeforeDraw()

void skiagm::BitmapShaderGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 52 of file bitmapshader.cpp.

52 {
54 fImage = draw_bm();
55 fMask = draw_mask();
56 }
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
void setBGColor(SkColor)
Definition: gm.cpp:159
static sk_sp< SkImage > draw_bm()
static sk_sp< SkImage > draw_mask()

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