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

Public Member Functions

 GrMipMapBench (int w, int h)
 
- 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
 

Protected Member Functions

bool isSuitableFor (Backend backend) override
 
const char * onGetName () override
 
void onDraw (int loops, SkCanvas *canvas) override
 
void onPerCanvasPostDraw (SkCanvas *) override
 
- 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 ()
 

Additional Inherited Members

- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Detailed Description

Definition at line 17 of file GrMipmapBench.cpp.

Constructor & Destructor Documentation

◆ GrMipMapBench()

GrMipMapBench::GrMipMapBench ( int  w,
int  h 
)
inline

Definition at line 23 of file GrMipmapBench.cpp.

23 : fW(w), fH(h) {
24 fName.printf("gr_mipmap_build_%dx%d", w, h);
25 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
SkScalar w
SkScalar h

Member Function Documentation

◆ isSuitableFor()

bool GrMipMapBench::isSuitableFor ( Backend  backend)
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 28 of file GrMipmapBench.cpp.

28 {
29 return Backend::kGanesh == backend;
30 }
const char * backend

◆ onDraw()

void GrMipMapBench::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 34 of file GrMipmapBench.cpp.

34 {
35 if (!fSurface) {
36 auto context = canvas->recordingContext();
37 if (!context) {
38 return;
39 }
40 auto srgb = SkColorSpace::MakeSRGB();
43 // We're benching the regeneration of the mip levels not the need to allocate them every
44 // frame. Thus we create the surface with mips to begin with.
45 fSurface = SkSurfaces::RenderTarget(context,
47 info,
48 /* sampleCount= */ 0,
50 /* surfaceProps= */ nullptr,
51 /* shouldCreateWithMips= */ true);
52 }
53
54 // Clear surface once:
55 fSurface->getCanvas()->clear(SK_ColorBLACK);
56
60 paint.setColor(SK_ColorWHITE);
61 for (int i = 0; i < loops; i++) {
62 // Touch surface so mips are dirtied
63 fSurface->getCanvas()->drawPoint(0, 0, paint);
64
65 // Draw reduced version of surface to original canvas, to trigger mip generation
66 canvas->save();
67 canvas->scale(0.1f, 0.1f);
68 canvas->drawImage(fSurface->makeImageSnapshot(), 0, 0, sampling, &paint);
69 canvas->restore();
70 }
71 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void restore()
Definition: SkCanvas.cpp:461
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2695
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkColorSpace > MakeSRGB()
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
sk_sp< SkImage > makeImageSnapshot()
Definition: SkSurface.cpp:90
const Paint & paint
Definition: color_source.cc:38
SkSamplingOptions sampling
Definition: SkRecords.h:337
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)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ onGetName()

const char * GrMipMapBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 32 of file GrMipmapBench.cpp.

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

◆ onPerCanvasPostDraw()

void GrMipMapBench::onPerCanvasPostDraw ( SkCanvas )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 73 of file GrMipmapBench.cpp.

73 {
74 fSurface.reset(nullptr);
75 }
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

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