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

Public Member Functions

 PictureShaderCacheGM (SkScalar tileSize)
 
- 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 drawTile (SkCanvas *canvas)
 
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 29 of file pictureshadercache.cpp.

Constructor & Destructor Documentation

◆ PictureShaderCacheGM()

PictureShaderCacheGM::PictureShaderCacheGM ( SkScalar  tileSize)
inline

Definition at line 31 of file pictureshadercache.cpp.

32 : fTileSize(tileSize) {
33 }

Member Function Documentation

◆ drawTile()

void PictureShaderCacheGM::drawTile ( SkCanvas canvas)
inlineprotected

Definition at line 36 of file pictureshadercache.cpp.

36 {
38 paint.setColor(SK_ColorGREEN);
40 paint.setAntiAlias(true);
41
42 canvas->drawCircle(fTileSize / 4, fTileSize / 4, fTileSize / 4, paint);
43 canvas->drawRect(SkRect::MakeXYWH(fTileSize / 2, fTileSize / 2,
44 fTileSize / 2, fTileSize / 2), paint);
45
46 paint.setColor(SK_ColorRED);
47 canvas->drawLine(fTileSize / 2, fTileSize * 1 / 3,
48 fTileSize / 2, fTileSize * 2 / 3, paint);
49 canvas->drawLine(fTileSize * 1 / 3, fTileSize / 2,
50 fTileSize * 2 / 3, fTileSize / 2, paint);
51 }
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 drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
const Paint & paint
Definition: color_source.cc:38
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ getISize()

SkISize PictureShaderCacheGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 62 of file pictureshadercache.cpp.

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

◆ getName()

SkString PictureShaderCacheGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 60 of file pictureshadercache.cpp.

60{ return SkString("pictureshadercache"); }

◆ onDraw()

void PictureShaderCacheGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 64 of file pictureshadercache.cpp.

64 {
68
69 {
70 // Render in a funny color space that converts green to yellow.
71 skcms_Matrix3x3 greenToYellow = {{
72 { 1, 1, 0 },
73 { 0, 1, 0 },
74 { 0, 0, 1 },
75 }};
77 greenToYellow);
78 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100, std::move(gty));
80 surface->getCanvas()->drawRect(SkRect::MakeWH(fTileSize, fTileSize), paint);
81 }
82
83 // When we draw to the canvas, we should see green because we should *not* reuse the
84 // cached picture shader.
85 canvas->drawRect(SkRect::MakeWH(fTileSize, fTileSize), paint);
86 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, SkFilterMode mode, const SkMatrix *localMatrix, const SkRect *tileRect) const
VkSurfaceKHR surface
Definition: main.cc:49
static constexpr skcms_TransferFunction kSRGB
Definition: SkColorSpace.h:45
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onOnceBeforeDraw()

void PictureShaderCacheGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 53 of file pictureshadercache.cpp.

53 {
54 SkPictureRecorder recorder;
55 SkCanvas* pictureCanvas = recorder.beginRecording(fTileSize, fTileSize);
56 this->drawTile(pictureCanvas);
57 fPicture = recorder.finishRecordingAsPicture();
58 }
void drawTile(SkCanvas *canvas)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()

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