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

Public Member Functions

 ImageShaderGM ()
 
- 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 testImage (SkCanvas *canvas, SkImage *image)
 
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 109 of file image_shader.cpp.

Constructor & Destructor Documentation

◆ ImageShaderGM()

ImageShaderGM::ImageShaderGM ( )
inline

Definition at line 113 of file image_shader.cpp.

113{}

Member Function Documentation

◆ getISize()

SkISize ImageShaderGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 118 of file image_shader.cpp.

118{ return SkISize::Make(850, 450); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString ImageShaderGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 116 of file image_shader.cpp.

116{ return SkString("image-shader"); }

◆ onDraw()

void ImageShaderGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 141 of file image_shader.cpp.

141 {
142 canvas->translate(20, 20);
143
145
146 for (size_t i = 0; i < std::size(gProcs); ++i) {
147 sk_sp<SkImage> image(gProcs[i](canvas->recordingContext(), fPicture.get(), info));
148 if (image) {
149 this->testImage(canvas, image.get());
150 }
151 canvas->translate(120, 0);
152 }
153 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
void testImage(SkCanvas *canvas, SkImage *image)
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
T * get() const
Definition: SkRefCnt.h:303
const ImageMakerProc gProcs[]
sk_sp< const SkImage > image
Definition: SkRecords.h:269
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
static SkImageInfo MakeN32Premul(int width, int height)

◆ onOnceBeforeDraw()

void ImageShaderGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 120 of file image_shader.cpp.

120 {
121 const SkRect bounds = SkRect::MakeWH(100, 100);
122 SkPictureRecorder recorder;
124 fPicture = recorder.finishRecordingAsPicture();
125 }
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
static void draw_something(SkCanvas *canvas, const SkRect &bounds)
Optional< SkRect > bounds
Definition: SkRecords.h:189
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ testImage()

void ImageShaderGM::testImage ( SkCanvas canvas,
SkImage image 
)
inlineprotected

Definition at line 127 of file image_shader.cpp.

127 {
128 SkAutoCanvasRestore acr(canvas, true);
129
130 canvas->drawImage(image, 0, 0);
131 canvas->translate(0, 120);
132
133 const SkTileMode tile = SkTileMode::kRepeat;
134 const SkMatrix localM = SkMatrix::Translate(-50, -50);
136 paint.setShader(image->makeShader(tile, tile, SkSamplingOptions(), &localM));
137 paint.setAntiAlias(true);
138 canvas->drawCircle(50, 50, 50, paint);
139 }
SkTileMode
Definition: SkTileMode.h:13
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
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
const Paint & paint
Definition: color_source.cc:38

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