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

Public Member Functions

 Image2RasterBench ()
 
bool isSuitableFor (Backend backend) 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
 

Protected Member Functions

const char * onGetName () override
 
void onPerCanvasPreDraw (SkCanvas *canvas) override
 
void onPerCanvasPostDraw (SkCanvas *) override
 
void onDraw (int loops, 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 13 of file ImageBench.cpp.

Constructor & Destructor Documentation

◆ Image2RasterBench()

Image2RasterBench::Image2RasterBench ( )
inline

Definition at line 15 of file ImageBench.cpp.

15 {
16 fName.set("native_image_to_raster_surface");
17 }
void set(const SkString &src)
Definition: SkString.h:186

Member Function Documentation

◆ isSuitableFor()

bool Image2RasterBench::isSuitableFor ( Backend  backend)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 19 of file ImageBench.cpp.

19 {
21 }
const char * backend

◆ onDraw()

void Image2RasterBench::onDraw ( int  loops,
SkCanvas  
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 50 of file ImageBench.cpp.

50 {
51 for (int i = 0; i < loops; i++) {
52 for (int inner = 0; inner < 10; ++inner) {
53 fRasterSurface->getCanvas()->drawImage(fImage.get(), 0, 0);
54 }
55 }
56 }
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
T * get() const
Definition: SkRefCnt.h:303

◆ onGetName()

const char * Image2RasterBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 24 of file ImageBench.cpp.

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

◆ onPerCanvasPostDraw()

void Image2RasterBench::onPerCanvasPostDraw ( SkCanvas )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 43 of file ImageBench.cpp.

43 {
44 // Release the image and raster surface here to prevent out of order destruction
45 // between these and the gpu interface.
46 fRasterSurface.reset(nullptr);
47 fImage.reset(nullptr);
48 }
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

◆ onPerCanvasPreDraw()

void Image2RasterBench::onPerCanvasPreDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 31 of file ImageBench.cpp.

31 {
32 // create an Image reflecting the canvas (gpu or cpu)
33 SkImageInfo info = canvas->imageInfo().makeWH(100, 100);
34 auto surface(canvas->makeSurface(info));
35 canvas->drawColor(SK_ColorRED);
36 fImage = surface->makeImageSnapshot();
37
38 // create a cpu-backed Surface
39 SkImageInfo n32Info = SkImageInfo::MakeN32Premul(100, 100);
40 fRasterSurface = SkSurfaces::Raster(n32Info);
41 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
sk_sp< SkSurface > makeSurface(const SkImageInfo &info, const SkSurfaceProps *props=nullptr)
Definition: SkCanvas.cpp:1195
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
VkSurfaceKHR surface
Definition: main.cc:49
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SkImageInfo makeWH(int newWidth, int newHeight) const
Definition: SkImageInfo.h:444
static SkImageInfo MakeN32Premul(int width, int height)

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