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

Public Member Functions

 CompositorGM (const char *name, std::function< ClipTileRendererArray()> makeRendererFn)
 
- 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

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

Detailed Description

Definition at line 422 of file compositor_quads.cpp.

Constructor & Destructor Documentation

◆ CompositorGM()

CompositorGM::CompositorGM ( const char *  name,
std::function< ClipTileRendererArray()>  makeRendererFn 
)
inline

Definition at line 424 of file compositor_quads.cpp.

425 : fMakeRendererFn(std::move(makeRendererFn))
426 , fName(name) {}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Member Function Documentation

◆ getISize()

SkISize CompositorGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 429 of file compositor_quads.cpp.

429 {
430 // Initialize the array of renderers.
431 this->onceBeforeDraw();
432
433 // The GM draws a grid of renderers (rows) x transforms (col). Within each cell, the
434 // renderer draws the transformed tile grid, which is approximately
435 // (kColCount*kTileWidth, kRowCount*kTileHeight), although it has additional line
436 // visualizations and can be transformed outside of those rectangular bounds (i.e. persp),
437 // so pad the cell dimensions to be conservative. Must also account for the banner text.
438 static constexpr SkScalar kCellWidth = 1.3f * kColCount * kTileWidth;
439 static constexpr SkScalar kCellHeight = 1.3f * kRowCount * kTileHeight;
441 SkScalarRoundToInt(kCellHeight * fRenderers.size() + 75.f));
442 }
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
static const SkScalar kCellWidth
Definition: TableBench.cpp:12
int size() const
Definition: SkTArray.h:421
void onceBeforeDraw()
Definition: gm.h:133
static constexpr int kMatrixCount
static constexpr SkScalar kTileHeight
static constexpr SkScalar kTileWidth
static constexpr int kRowCount
static constexpr int kColCount
float SkScalar
Definition: extension.cpp:12
const int kCellHeight
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString CompositorGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 444 of file compositor_quads.cpp.

444 {
445 SkString fullName;
446 fullName.appendf("compositor_quads_%s", fName.c_str());
447 return fullName;
448 }
const char * c_str() const
Definition: SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550

◆ onDraw()

void CompositorGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 455 of file compositor_quads.cpp.

455 {
456 static constexpr SkScalar kGap = 40.f;
457 static constexpr SkScalar kBannerWidth = 120.f;
458 static constexpr SkScalar kOffset = 15.f;
459
460 TArray<int> drawCounts(fRenderers.size());
461 drawCounts.push_back_n(fRenderers.size(), 0);
462
463 canvas->save();
464 canvas->translate(kOffset + kBannerWidth, kOffset);
465 for (int i = 0; i < fMatrices.size(); ++i) {
466 canvas->save();
467 draw_text(canvas, fMatrixNames[i].c_str());
468
469 canvas->translate(0.f, kGap);
470 for (int j = 0; j < fRenderers.size(); ++j) {
471 canvas->save();
472 draw_tile_boundaries(canvas, fMatrices[i]);
473 draw_clipping_boundaries(canvas, fMatrices[i]);
474
475 canvas->concat(fMatrices[i]);
476 drawCounts[j] += fRenderers[j]->drawTiles(canvas);
477
478 canvas->restore();
479 // And advance to the next row
480 canvas->translate(0.f, kGap + kRowCount * kTileHeight);
481 }
482 // Reset back to the left edge
483 canvas->restore();
484 // And advance to the next column
485 canvas->translate(kGap + kColCount * kTileWidth, 0.f);
486 }
487 canvas->restore();
488
489 // Print a row header, with total draw counts
490 canvas->save();
491 canvas->translate(kOffset, kGap + 0.5f * kRowCount * kTileHeight);
492 for (int j = 0; j < fRenderers.size(); ++j) {
493 fRenderers[j]->drawBanner(canvas);
494 canvas->translate(0.f, 15.f);
495 draw_text(canvas, SkStringPrintf("Draws = %d", drawCounts[j]).c_str());
496 canvas->translate(0.f, kGap + kRowCount * kTileHeight);
497 }
498 canvas->restore();
499 }
static constexpr uint64_t kOffset
Definition: DrawPass.cpp:53
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
static void draw_clipping_boundaries(SkCanvas *canvas, const SkMatrix &local)
static void draw_text(SkCanvas *canvas, const char *text)
static void draw_tile_boundaries(SkCanvas *canvas, const SkMatrix &local)

◆ onOnceBeforeDraw()

void CompositorGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 450 of file compositor_quads.cpp.

450 {
451 fRenderers = fMakeRendererFn();
452 this->configureMatrices();
453 }

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