Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
PathTextBench Class Reference
Inheritance diagram for PathTextBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 PathTextBench (bool clipped, bool uncached)
 
- 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
 

Private Member Functions

const char * onGetName () override
 
SkISize onGetSize () override
 
void onDelayedSetup () override
 
void onDraw (int loops, SkCanvas *canvas) override
 

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 * onGetUniqueName ()
 
virtual void onPerCanvasPreDraw (SkCanvas *)
 
virtual void onPerCanvasPostDraw (SkCanvas *)
 
virtual void onPreDraw (SkCanvas *)
 
virtual void onPostDraw (SkCanvas *)
 

Detailed Description

Definition at line 33 of file PathTextBench.cpp.

Constructor & Destructor Documentation

◆ PathTextBench()

PathTextBench::PathTextBench ( bool  clipped,
bool  uncached 
)
inline

Definition at line 35 of file PathTextBench.cpp.

35: fClipped(clipped), fUncached(uncached) {}

Member Function Documentation

◆ onDelayedSetup()

void PathTextBench::onDelayedSetup ( )
inlineoverrideprivatevirtual

Reimplemented from Benchmark.

Definition at line 50 of file PathTextBench.cpp.

50 {
51 SkFont defaultFont = ToolUtils::DefaultFont();
52 SkStrikeSpec strikeSpec = SkStrikeSpec::MakeWithNoDevice(defaultFont);
53 SkBulkGlyphMetricsAndPaths pathMaker{strikeSpec};
54 for (int i = 0; i < kNumGlyphs; ++i) {
55 SkGlyphID id(defaultFont.unicharToGlyph(kGlyphs[i]));
56 const SkGlyph* glyph = pathMaker.glyph(id);
57 if (glyph->path()) {
58 fGlyphs[i] = *glyph->path();
59 }
60 fGlyphs[i].setIsVolatile(fUncached);
61 }
62
63 SkRandom rand;
64 for (int i = 0; i < kNumDraws; ++i) {
65 const SkPath& glyph = fGlyphs[i % kNumGlyphs];
66 const SkRect& bounds = glyph.getBounds();
67 float glyphSize = std::max(bounds.width(), bounds.height());
68 SkASSERT(glyphSize > 0);
69
70 float t0 = pow(rand.nextF(), 100);
71 float size = (1 - t0) * std::min(kScreenWidth, kScreenHeight) / 50 +
72 t0 * std::min(kScreenWidth, kScreenHeight) / 3;
73 float scale = size / glyphSize;
74 float t1 = rand.nextF(), t2 = rand.nextF();
75 fXforms[i].setTranslate((1 - t1) * sqrt(2) * scale/2 * glyphSize +
76 t1 * (kScreenWidth - sqrt(2) * scale/2 * glyphSize),
77 (1 - t2) * sqrt(2) * scale/2 * glyphSize +
78 t2 * (kScreenHeight - sqrt(2) * scale/2 * glyphSize));
79 fXforms[i].preRotate(rand.nextF() * 360);
80 fXforms[i].preTranslate(-scale/2 * bounds.width(), -scale/2 * bounds.height());
81 fXforms[i].preScale(scale, scale);
82 fPaints[i].setAntiAlias(true);
83 fPaints[i].setColor(rand.nextU() | 0x80808080);
84 }
85
86 if (fClipped) {
88 fClipPath.setIsVolatile(fUncached);
89 }
90 }
static constexpr int kNumDraws
static constexpr int kScreenHeight
static constexpr int kNumGlyphs
static constexpr char kGlyphs[]
static constexpr int kScreenWidth
#define SkASSERT(cond)
Definition SkAssert.h:116
uint16_t SkGlyphID
Definition SkTypes.h:179
SkGlyphID unicharToGlyph(SkUnichar uni) const
Definition SkFont.cpp:173
const SkPath * path() const
Definition SkGlyph.cpp:284
SkMatrix & setTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:254
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:263
SkMatrix & preRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:462
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition SkMatrix.cpp:315
void setColor(SkColor color)
Definition SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition SkPaint.h:170
SkPath & setIsVolatile(bool isVolatile)
Definition SkPath.h:370
const SkRect & getBounds() const
Definition SkPath.cpp:420
uint32_t nextU()
Definition SkRandom.h:42
float nextF()
Definition SkRandom.h:55
static SkStrikeSpec MakeWithNoDevice(const SkFont &font, const SkPaint *paint=nullptr)
Optional< SkRect > bounds
Definition SkRecords.h:189
SkFont DefaultFont()
SkPath make_star(const SkRect &bounds, int numPts, int step)
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
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
const Scalar scale
static SkRect MakeIWH(int w, int h)
Definition SkRect.h:623
const uintptr_t id

◆ onDraw()

void PathTextBench::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverrideprivatevirtual

Implements Benchmark.

Definition at line 92 of file PathTextBench.cpp.

92 {
93 SkAutoCanvasRestore acr(canvas, true);
94 if (fClipped) {
95 canvas->clipPath(fClipPath, SkClipOp::kIntersect, true);
96 }
97 for (int i = 0; i < kNumDraws; ++i) {
98 const SkPath& glyph = fGlyphs[i % kNumGlyphs];
99 canvas->setMatrix(fXforms[i]);
100 canvas->drawPath(glyph, fPaints[i]);
101 }
102 }
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
void drawPath(const SkPath &path, const SkPaint &paint)
void setMatrix(const SkM44 &matrix)

◆ onGetName()

const char * PathTextBench::onGetName ( )
inlineoverrideprivatevirtual

Implements Benchmark.

Definition at line 38 of file PathTextBench.cpp.

38 {
39 fName = "path_text";
40 if (fClipped) {
41 fName.append("_clipped");
42 }
43 if (fUncached) {
44 fName.append("_uncached");
45 }
46 return fName.c_str();
47 }
void append(const char text[])
Definition SkString.h:203
const char * c_str() const
Definition SkString.h:133

◆ onGetSize()

SkISize PathTextBench::onGetSize ( )
inlineoverrideprivatevirtual

Reimplemented from Benchmark.

Definition at line 48 of file PathTextBench.cpp.

static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

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