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

Public Member Functions

 PictureShaderGM (SkScalar tileSize, SkScalar sceneSize, bool useLocalMatrixWrapper=false, float alpha=1)
 
- 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

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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 38 of file pictureshader.cpp.

Constructor & Destructor Documentation

◆ PictureShaderGM()

PictureShaderGM::PictureShaderGM ( SkScalar  tileSize,
SkScalar  sceneSize,
bool  useLocalMatrixWrapper = false,
float  alpha = 1 
)
inline

Definition at line 40 of file pictureshader.cpp.

42 : fTileSize(tileSize)
43 , fSceneSize(sceneSize)
44 , fAlpha(alpha)
45 , fUseLocalMatrixWrapper(useLocalMatrixWrapper)
46 {}

Member Function Documentation

◆ getISize()

SkISize PictureShaderGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 69 of file pictureshader.cpp.

69{ return SkISize::Make(1400, 1450); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString PictureShaderGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 63 of file pictureshader.cpp.

63 {
64 return SkStringPrintf("pictureshader%s%s",
65 fUseLocalMatrixWrapper ? "_localwrapper" : "",
66 fAlpha < 1 ? "_alpha" : "");
67 }
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.

◆ onDraw()

void PictureShaderGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 71 of file pictureshader.cpp.

71 {
72 this->drawSceneColumn(canvas, SkPoint::Make(0, 0), 1, 1, 0);
73 this->drawSceneColumn(canvas, SkPoint::Make(0, fSceneSize * 6.4f), 1, 2, 0);
74 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, 0), 1, 1, 1);
75 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, fSceneSize * 6.4f), 1, 1, 2);
76 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 4.8f, 0), 2, 1, 0);
77 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 9.6f, 0), 2, 2, 0);
78
79 // One last custom row to exercise negative scaling
80 SkMatrix ctm, localMatrix;
81 ctm.setTranslate(fSceneSize * 2.1f, fSceneSize * 13.8f);
82 ctm.preScale(-1, -1);
83 localMatrix.setScale(2, 2);
84 this->drawScene(canvas, ctm, localMatrix, 0);
85
86 ctm.setTranslate(fSceneSize * 2.4f, fSceneSize * 12.8f);
87 localMatrix.setScale(-1, -1);
88 this->drawScene(canvas, ctm, localMatrix, 0);
89
90 ctm.setTranslate(fSceneSize * 4.8f, fSceneSize * 12.3f);
91 ctm.preScale(2, 2);
92 this->drawScene(canvas, ctm, localMatrix, 0);
93
94 ctm.setTranslate(fSceneSize * 13.8f, fSceneSize * 14.3f);
95 ctm.preScale(-2, -2);
96 localMatrix.setTranslate(fTileSize / 4, fTileSize / 4);
97 localMatrix.preRotate(45);
98 localMatrix.preScale(-2, -2);
99 this->drawScene(canvas, ctm, localMatrix, 0);
100 }
SkMatrix & setTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:254
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:296
SkMatrix & preRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:462
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:315
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

◆ onOnceBeforeDraw()

void PictureShaderGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 49 of file pictureshader.cpp.

49 {
50 // Build the picture.
51 SkPictureRecorder recorder;
52 SkCanvas* pictureCanvas = recorder.beginRecording(fTileSize, fTileSize);
53 this->drawTile(pictureCanvas);
54 fPicture = recorder.finishRecordingAsPicture();
55
56 // Build a reference bitmap.
57 fBitmap.allocN32Pixels(SkScalarCeilToInt(fTileSize), SkScalarCeilToInt(fTileSize));
59 SkCanvas bitmapCanvas(fBitmap);
60 this->drawTile(&bitmapCanvas);
61 }
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
#define SkScalarCeilToInt(x)
Definition: SkScalar.h:36
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()

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