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

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
 
- 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 94 of file pictureshadertile.cpp.

Member Function Documentation

◆ getISize()

SkISize PictureShaderTileGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 98 of file pictureshadertile.cpp.

98{ return SkISize::Make(800, 600); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString PictureShaderTileGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 96 of file pictureshadertile.cpp.

96{ return SkString("pictureshadertile"); }

◆ onDraw()

void PictureShaderTileGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 138 of file pictureshadertile.cpp.

138 {
139 canvas->clear(SK_ColorBLACK);
140
142 paint.setStyle(SkPaint::kFill_Style);
143
144 for (unsigned i = 0; i < std::size(fShaders); ++i) {
145 paint.setShader(fShaders[i]);
146
147 canvas->save();
148 canvas->translate((i % kRowSize) * kFillSize * 1.1f,
149 (i / kRowSize) * kFillSize * 1.1f);
151 canvas->restore();
152 }
153 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
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
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
const Paint & paint
Definition: color_source.cc:38
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
constexpr SkScalar kFillSize
constexpr unsigned kRowSize
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onOnceBeforeDraw()

void PictureShaderTileGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 100 of file pictureshadertile.cpp.

100 {
101 SkPictureRecorder recorder;
102 SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPictureSize);
103 draw_scene(pictureCanvas, kPictureSize);
105
106 SkPoint offset = SkPoint::Make(100, 100);
107 pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), offset.y(),
109 pictureCanvas->translate(offset.x(), offset.y());
110 draw_scene(pictureCanvas, kPictureSize);
111 sk_sp<SkPicture> offsetPicture(recorder.finishRecordingAsPicture());
112
113 for (unsigned i = 0; i < std::size(tiles); ++i) {
117 tiles[i].h * kPictureSize);
118 SkMatrix localMatrix;
119 localMatrix.setTranslate(tiles[i].offsetX * kPictureSize,
121 localMatrix.postScale(kFillSize / (2 * kPictureSize),
122 kFillSize / (2 * kPictureSize));
123
124 sk_sp<SkPicture> pictureRef = picture;
125 SkRect* tilePtr = &tile;
126
128 // When the tile == picture bounds, exercise the picture + offset path.
129 pictureRef = offsetPicture;
130 tilePtr = nullptr;
131 }
132
133 fShaders[i] = pictureRef->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat,
134 SkFilterMode::kNearest, &localMatrix, tilePtr);
135 }
136 }
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:360
SkMatrix & setTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:254
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, SkFilterMode mode, const SkMatrix *localMatrix, const SkRect *tileRect) const
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
SkScalar offsetX
constexpr SkScalar kPictureSize
SkScalar w
SkScalar offsetY
SkScalar y
static void draw_scene(SkCanvas *canvas, SkScalar pictureSize)
SkScalar x
constexpr struct @263 tiles[]
SkScalar h
SeparatedVector2 offset
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
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: