Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
skiagm::DiscardGM Class Reference
Inheritance diagram for skiagm::DiscardGM:
skiagm::GM

Public Member Functions

 DiscardGM ()
 
- 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 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
 
DrawResult onDraw (SkCanvas *canvas, SkString *errorMsg) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
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 35 of file discard.cpp.

Constructor & Destructor Documentation

◆ DiscardGM()

skiagm::DiscardGM::DiscardGM ( )
inline

Definition at line 38 of file discard.cpp.

38{}

Member Function Documentation

◆ getISize()

SkISize skiagm::DiscardGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 43 of file discard.cpp.

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

◆ getName()

SkString skiagm::DiscardGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 41 of file discard.cpp.

41{ return SkString("discard"); }

◆ onDraw()

DrawResult skiagm::DiscardGM::onDraw ( SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 45 of file discard.cpp.

45 {
46
47 SkISize size = this->getISize();
48 size.fWidth /= 10;
49 size.fHeight /= 10;
52
53 auto dContext = GrAsDirectContext(canvas->recordingContext());
54 if (dContext && !dContext->abandoned()) {
56 }
57
58#if defined(SK_GRAPHITE)
59 auto recorder = canvas->recorder();
60 if (recorder) {
62 }
63#endif
64
65 if (!surface) {
67 }
68 if (!surface) {
69 *errorMsg = "Could not create surface.";
70 return DrawResult::kFail;
71 }
72
73 canvas->clear(SK_ColorBLACK);
74
75 SkRandom rand;
76 for (int x = 0; x < 10; ++x) {
77 for (int y = 0; y < 10; ++y) {
78 surface->getCanvas()->discard();
79 // Make something that isn't too close to the background color, black.
80 SkColor color = ToolUtils::color_to_565(rand.nextU() | 0xFF404040);
81 switch (rand.nextULessThan(3)) {
82 case 0:
83 surface->getCanvas()->drawColor(color);
84 break;
85 case 1:
86 surface->getCanvas()->clear(color);
87 break;
88 case 2:
90 paint.setShader(SkShaders::Color(color));
91 surface->getCanvas()->drawPaint(paint);
92 break;
93 }
94 surface->draw(canvas, 10.f*x, 10.f*y);
95 }
96 }
97
98 surface->getCanvas()->discard();
99 return DrawResult::kOk;
100 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
SkColor4f color
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
void clear(SkColor color)
Definition SkCanvas.h:1199
uint32_t nextU()
Definition SkRandom.h:42
uint32_t nextULessThan(uint32_t count)
Definition SkRandom.h:93
SkISize getISize() override
Definition discard.cpp:43
const Paint & paint
VkSurfaceKHR surface
Definition main.cc:49
double y
double x
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
SkColor color_to_565(SkColor color)
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
int32_t fWidth
Definition SkSize.h:17
static SkImageInfo MakeN32Premul(int width, int height)

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