Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DisplacementBaseBench Class Reference
Inheritance diagram for DisplacementBaseBench:
Benchmark SkRefCnt SkRefCntBase DisplacementAlphaBench DisplacementFullBench DisplacementZeroBench

Public Member Functions

 DisplacementBaseBench (bool small)
 
- 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

void onDelayedSetup () override
 
void makeBitmap ()
 
void makeCheckerboard ()
 
void drawClippedBitmap (SkCanvas *canvas, int x, int y, const SkPaint &paint)
 
bool isSmall () const
 
- 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 ()
 

Protected Attributes

sk_sp< SkImagefImage
 
sk_sp< SkImagefCheckerboard
 

Additional Inherited Members

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

Detailed Description

Definition at line 21 of file DisplacementBench.cpp.

Constructor & Destructor Documentation

◆ DisplacementBaseBench()

DisplacementBaseBench::DisplacementBaseBench ( bool  small)
inline

Definition at line 23 of file DisplacementBench.cpp.

23: fInitialized(false), fIsSmall(small) { }

Member Function Documentation

◆ drawClippedBitmap()

void DisplacementBaseBench::drawClippedBitmap ( SkCanvas canvas,
int  x,
int  y,
const SkPaint paint 
)
inlineprotected

Definition at line 72 of file DisplacementBench.cpp.

72 {
73 canvas->save();
74 canvas->clipIRect(fImage->bounds().makeOffset(x, y));
76 canvas->restore();
77 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void restore()
Definition: SkCanvas.cpp:461
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.h:991
int save()
Definition: SkCanvas.cpp:447
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkIRect bounds() const
Definition: SkImage.h:303
const Paint & paint
Definition: color_source.cc:38
double y
double x
SkSamplingOptions(SkFilterMode::kLinear))
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
Definition: SkRect.h:300

◆ isSmall()

bool DisplacementBaseBench::isSmall ( ) const
inlineprotected

Definition at line 79 of file DisplacementBench.cpp.

79{ return fIsSmall; }

◆ makeBitmap()

void DisplacementBaseBench::makeBitmap ( )
inlineprotected

Definition at line 34 of file DisplacementBench.cpp.

34 {
35 const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
36 const int h = this->isSmall() ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
39 paint.setColor(0xFF884422);
40
42 font.setSize(SkIntToScalar(96));
43 surf->getCanvas()->drawSimpleText("g", 1, SkTextEncoding::kUTF8, 15, 55, font, paint);
44 fImage = surf->makeImageSnapshot();
45 }
#define FILTER_WIDTH_SMALL
#define FILTER_WIDTH_LARGE
#define FILTER_HEIGHT_SMALL
#define FILTER_HEIGHT_LARGE
@ kUTF8
uses bytes to represent UTF-8 or ASCII
Definition: SkFont.h:35
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SkFont DefaultFont()
font
Font Metadata and Metrics.
SkScalar w
SkScalar h
static SkImageInfo MakeN32Premul(int width, int height)

◆ makeCheckerboard()

void DisplacementBaseBench::makeCheckerboard ( )
inlineprotected

Definition at line 47 of file DisplacementBench.cpp.

47 {
48 const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
49 const int h = this->isSmall() ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
51 SkCanvas* canvas = surface->getCanvas();
52 canvas->clear(0x00000000);
53 SkPaint darkPaint;
54 darkPaint.setColor(0xFF804020);
55 SkPaint lightPaint;
56 lightPaint.setColor(0xFF244484);
57 for (int y = 0; y < h; y += 16) {
58 for (int x = 0; x < w; x += 16) {
59 canvas->save();
61 canvas->drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
62 canvas->drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
63 canvas->drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
64 canvas->drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
65 canvas->restore();
66 }
67 }
68
69 fCheckerboard = surface->makeImageSnapshot();
70 }
sk_sp< SkImage > fCheckerboard
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
void setColor(SkColor color)
Definition: SkPaint.cpp:119
VkSurfaceKHR surface
Definition: main.cc:49
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onDelayedSetup()

void DisplacementBaseBench::onDelayedSetup ( )
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 26 of file DisplacementBench.cpp.

26 {
27 if (!fInitialized) {
28 this->makeBitmap();
29 this->makeCheckerboard();
30 fInitialized = true;
31 }
32 }

Member Data Documentation

◆ fCheckerboard

sk_sp<SkImage> DisplacementBaseBench::fCheckerboard
protected

Definition at line 81 of file DisplacementBench.cpp.

◆ fImage

sk_sp<SkImage> DisplacementBaseBench::fImage
protected

Definition at line 81 of file DisplacementBench.cpp.


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