Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions | Variables
StrokeBench.cpp File Reference
#include "bench/Benchmark.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathUtils.h"
#include "include/core/SkString.h"
#include "src/base/SkRandom.h"

Go to the source code of this file.

Classes

class  StrokeBench
 

Functions

static SkPoint rand_pt (SkRandom &rand)
 
static SkPath line_path_maker ()
 
static SkPath quad_path_maker ()
 
static SkPath conic_path_maker ()
 
static SkPath cubic_path_maker ()
 
static SkPaint paint_maker ()
 
 DEF_BENCH (return new StrokeBench(line_path_maker(), paint_maker(), "line_1", 1);) DEF_BENCH(return new StrokeBench(quad_path_maker()
 
 DEF_BENCH (return new StrokeBench(conic_path_maker(), paint_maker(), "conic_1", 1);) DEF_BENCH(return new StrokeBench(cubic_path_maker()
 
 DEF_BENCH (return new StrokeBench(line_path_maker(), paint_maker(), "line_4", 4);) DEF_BENCH(return new StrokeBench(quad_path_maker()
 
 DEF_BENCH (return new StrokeBench(conic_path_maker(), paint_maker(), "conic_4", 4);) DEF_BENCH(return new StrokeBench(cubic_path_maker()
 
 DEF_BENCH (return new StrokeBench(line_path_maker(), paint_maker(), "line_.25",.25f);) DEF_BENCH(return new StrokeBench(quad_path_maker()
 
 DEF_BENCH (return new StrokeBench(conic_path_maker(), paint_maker(), "conic_.25",.25f);) DEF_BENCH(return new StrokeBench(cubic_path_maker()
 

Variables

static const int N = 100
 
static const SkScalar X = 100
 
static const SkScalar Y = 100
 
 quad_1
 
 cubic_1
 
 quad_4
 
 cubic_4
 
 quad_
 
 cubic_
 

Function Documentation

◆ conic_path_maker()

static SkPath conic_path_maker ( )
static

Definition at line 79 of file StrokeBench.cpp.

79 {
81 SkRandom rand;
82 path.moveTo(rand_pt(rand));
83 for (int i = 0; i < N; ++i) {
84 path.conicTo(rand_pt(rand), rand_pt(rand), rand.nextUScalar1());
85 }
86 return path;
87}
static SkPoint rand_pt(SkRandom &rand)
static const int N
SkScalar nextUScalar1()
Definition SkRandom.h:101
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ cubic_path_maker()

static SkPath cubic_path_maker ( )
static

Definition at line 88 of file StrokeBench.cpp.

88 {
90 SkRandom rand;
91 path.moveTo(rand_pt(rand));
92 for (int i = 0; i < N; ++i) {
93 path.cubicTo(rand_pt(rand), rand_pt(rand), rand_pt(rand));
94 }
95 return path;
96}

◆ DEF_BENCH() [1/6]

DEF_BENCH ( return new StrokeBench(conic_path_maker(), paint_maker(), "conic_.25",.25f);   )
new

◆ DEF_BENCH() [2/6]

DEF_BENCH ( return new StrokeBench(conic_path_maker(), paint_maker(), "conic_1", 1);   )
new

◆ DEF_BENCH() [3/6]

DEF_BENCH ( return new StrokeBench(conic_path_maker(), paint_maker(), "conic_4", 4);   )
new

◆ DEF_BENCH() [4/6]

DEF_BENCH ( return new StrokeBench(line_path_maker(), paint_maker(), "line_.25",.25f);   )
new

◆ DEF_BENCH() [5/6]

DEF_BENCH ( return new StrokeBench(line_path_maker(), paint_maker(), "line_1", 1);   )
new

◆ DEF_BENCH() [6/6]

DEF_BENCH ( return new StrokeBench(line_path_maker(), paint_maker(), "line_4", 4);   )
new

◆ line_path_maker()

static SkPath line_path_maker ( )
static

Definition at line 61 of file StrokeBench.cpp.

61 {
63 SkRandom rand;
64 path.moveTo(rand_pt(rand));
65 for (int i = 0; i < N; ++i) {
66 path.lineTo(rand_pt(rand));
67 }
68 return path;
69}

◆ paint_maker()

paint_maker ( )
static

Definition at line 98 of file StrokeBench.cpp.

98 {
101 paint.setStrokeWidth(X / 10);
102 paint.setStrokeJoin(SkPaint::kMiter_Join);
103 paint.setStrokeCap(SkPaint::kSquare_Cap);
104 return paint;
105}
static const SkScalar X
@ kSquare_Cap
adds square
Definition SkPaint.h:336
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
@ kMiter_Join
extends to miter limit
Definition SkPaint.h:359
const Paint & paint

◆ quad_path_maker()

static SkPath quad_path_maker ( )
static

Definition at line 70 of file StrokeBench.cpp.

70 {
72 SkRandom rand;
73 path.moveTo(rand_pt(rand));
74 for (int i = 0; i < N; ++i) {
75 path.quadTo(rand_pt(rand), rand_pt(rand));
76 }
77 return path;
78}

◆ rand_pt()

static SkPoint rand_pt ( SkRandom rand)
static

Definition at line 57 of file StrokeBench.cpp.

57 {
58 return SkPoint::Make(rand.nextSScalar1() * X, rand.nextSScalar1() * Y);
59}
static const SkScalar Y
SkScalar nextSScalar1()
Definition SkRandom.h:113
static constexpr SkPoint Make(float x, float y)

Variable Documentation

◆ cubic_

cubic_

Definition at line 120 of file StrokeBench.cpp.

◆ cubic_1

cubic_1

Definition at line 110 of file StrokeBench.cpp.

◆ cubic_4

cubic_4

Definition at line 115 of file StrokeBench.cpp.

◆ N

const int N = 100
static

Definition at line 53 of file StrokeBench.cpp.

◆ quad_

quad_

Definition at line 118 of file StrokeBench.cpp.

◆ quad_1

quad_1

Definition at line 108 of file StrokeBench.cpp.

◆ quad_4

quad_4

Definition at line 113 of file StrokeBench.cpp.

◆ X

const SkScalar X = 100
static

Definition at line 54 of file StrokeBench.cpp.

◆ Y

const SkScalar Y = 100
static

Definition at line 55 of file StrokeBench.cpp.