Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
VertexColorSpaceBench Class Reference
Inheritance diagram for VertexColorSpaceBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 VertexColorSpaceBench (Mode mode, const char *name)
 
bool isSuitableFor (Backend backend) override
 
const char * onGetName () override
 
void onDraw (int loops, SkCanvas *canvas) override
 
- Public Member Functions inherited from Benchmark
 Benchmark ()
 
const char * getName ()
 
const char * getUniqueName ()
 
SkISize getSize ()
 
virtual bool isSuitableFor (Backend backend)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual bool shouldLoop () const
 
void delayedSetup ()
 
void perCanvasPreDraw (SkCanvas *)
 
void perCanvasPostDraw (SkCanvas *)
 
void preDraw (SkCanvas *)
 
void postDraw (SkCanvas *)
 
void draw (int loops, SkCanvas *)
 
virtual void getGpuStats (SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values)
 
virtual bool getDMSAAStats (GrRecordingContext *)
 
int getUnits () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Additional Inherited Members

- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 
- Protected Member Functions inherited from Benchmark
void setUnits (int units)
 
virtual void setupPaint (SkPaint *paint)
 
virtual const char * onGetName ()=0
 
virtual const char * onGetUniqueName ()
 
virtual void onDelayedSetup ()
 
virtual void onPerCanvasPreDraw (SkCanvas *)
 
virtual void onPerCanvasPostDraw (SkCanvas *)
 
virtual void onPreDraw (SkCanvas *)
 
virtual void onPostDraw (SkCanvas *)
 
virtual void onDraw (int loops, SkCanvas *)=0
 
virtual SkISize onGetSize ()
 

Detailed Description

Definition at line 285 of file VertexColorSpaceBench.cpp.

Constructor & Destructor Documentation

◆ VertexColorSpaceBench()

VertexColorSpaceBench::VertexColorSpaceBench ( Mode  mode,
const char *  name 
)
inline

Definition at line 287 of file VertexColorSpaceBench.cpp.

287 : fMode(mode) {
288 fName = "vertexcolorspace";
289 fName.appendf("_%s", name);
290 }
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
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 mode
Definition: switches.h:228

Member Function Documentation

◆ isSuitableFor()

bool VertexColorSpaceBench::isSuitableFor ( Backend  backend)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 292 of file VertexColorSpaceBench.cpp.

292{ return Backend::kGanesh == backend; }
const char * backend

◆ onDraw()

void VertexColorSpaceBench::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverridevirtual

Implements Benchmark.

Definition at line 295 of file VertexColorSpaceBench.cpp.

295 {
296 auto context = canvas->recordingContext()->asDirectContext();
297 SkASSERT(context);
298
299 if (kHalf_Mode == fMode &&
300 !context->priv().caps()->halfFloatVertexAttributeSupport()) {
301 return;
302 }
303
307 p3.get(), kUnpremul_SkAlphaType);
308
309 SkRandom r;
310 const int kDrawsPerLoop = 32;
311
312 for (int i = 0; i < loops; ++i) {
313 auto sdc =
316 p3,
318 {100, 100},
320 /*label=*/"DrawVertexColorSpaceBench");
321 SkASSERT(sdc);
322
323 for (int j = 0; j < kDrawsPerLoop; ++j) {
324 SkColor c = r.nextU();
325 GrOp::Owner op = nullptr;
326 GrRecordingContext* rContext = canvas->recordingContext();
327 switch (fMode) {
328 case kBaseline_Mode:
329 op = GrOp::Make<Op>(rContext, SkColorToPremulGrColor(c));
330 break;
331 case kShader_Mode:
332 op = GrOp::Make<Op>(rContext, SkColorToUnpremulGrColor(c), xform);
333 break;
334 case kHalf_Mode:
335 case kFloat_Mode: {
336 SkColor4f c4f = SkColor4f::FromColor(c);
337 c4f = xform->apply(c4f);
338 op = GrOp::Make<Op>(rContext, c4f, fMode);
339 }
340 }
341 sdc->addDrawOp(std::move(op));
342 }
343
344 context->flushAndSubmit();
345 }
346 }
kUnpremul_SkAlphaType
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkColorSpace * sk_srgb_singleton()
uint32_t SkColor
Definition: SkColor.h:37
static GrColor SkColorToUnpremulGrColor(SkColor c)
Definition: SkGr.h:60
static GrColor SkColorToPremulGrColor(SkColor c)
Definition: SkGr.h:51
static sk_sp< GrColorSpaceXform > Make(SkColorSpace *src, SkAlphaType srcAT, SkColorSpace *dst, SkAlphaType dstAT)
virtual GrDirectContext * asDirectContext()
std::unique_ptr< GrOp > Owner
Definition: GrOp.h:72
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
uint32_t nextU()
Definition: SkRandom.h:42
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
static constexpr skcms_Matrix3x3 kDisplayP3
Definition: SkColorSpace.h:87
static constexpr skcms_TransferFunction kSRGB
Definition: SkColorSpace.h:45

◆ onGetName()

const char * VertexColorSpaceBench::onGetName ( )
inlineoverridevirtual

Implements Benchmark.

Definition at line 293 of file VertexColorSpaceBench.cpp.

293{ return fName.c_str(); }
const char * c_str() const
Definition: SkString.h:133

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