Flutter Engine
The Flutter Engine
Classes | Enumerations | Functions
PathOpsBench.cpp File Reference
#include "bench/Benchmark.h"
#include "include/core/SkPath.h"
#include "include/core/SkShader.h"
#include "include/core/SkString.h"
#include "include/pathops/SkPathOps.h"
#include "include/private/base/SkTArray.h"
#include "src/base/SkRandom.h"
#include "include/core/SkPathBuilder.h"

Go to the source code of this file.

Classes

class  PathOpsBench
 
class  PathOpsSimplifyBench
 
class  PathBuilderBench
 

Enumerations

enum class  MakeType { kPath , kSnapshot , kDetach , kArray }
 

Functions

static SkPath makerects ()
 
 DEF_BENCH (return new PathOpsSimplifyBench("rects", makerects());) template< size_t N > struct ArrayPath
 
template<typename T >
void run_builder (T &b, bool useReserve, int N)
 

Enumeration Type Documentation

◆ MakeType

enum class MakeType
strong
Enumerator
kPath 
kSnapshot 
kDetach 
kArray 

Definition at line 140 of file PathOpsBench.cpp.

140 {
141 kPath,
142 kSnapshot,
143 kDetach,
144 kArray,
145};
@ kPath
Definition: SkGlyph.h:317

Function Documentation

◆ DEF_BENCH()

DEF_BENCH ( return new PathOpsSimplifyBench("rects", makerects());   )

Definition at line 95 of file PathOpsBench.cpp.

99 {
100 SkPoint fPts[N];
101 uint8_t fVbs[N];
102 int fPIndex = 0, fVIndex = 0;
103
104 void moveTo(float x, float y) {
105 fVbs[fVIndex++] = (uint8_t)SkPathVerb::kMove;
106 fPts[fPIndex++] = {x, y};
107 }
108 void lineTo(float x, float y) {
109 fVbs[fVIndex++] = (uint8_t)SkPathVerb::kLine;
110 fPts[fPIndex++] = {x, y};
111 }
112 void quadTo(float x, float y, float x1, float y1) {
113 fVbs[fVIndex++] = (uint8_t)SkPathVerb::kQuad;
114 fPts[fPIndex++] = {x, y};
115 fPts[fPIndex++] = {x1, y1};
116 }
117 void cubicTo(float x, float y, float x1, float y1, float x2, float y2) {
118 fVbs[fVIndex++] = (uint8_t)SkPathVerb::kCubic;
119 fPts[fPIndex++] = {x, y};
120 fPts[fPIndex++] = {x1, y1};
121 fPts[fPIndex++] = {x2, y2};
122 }
123 void incReserve(int) {}
124};
SkPoint fPts[2]
@ kCubic
SkPath::RawIter returns 4 points.
@ kQuad
SkPath::RawIter returns 3 points.
@ kMove
SkPath::RawIter returns 1 point.
@ kLine
SkPath::RawIter returns 2 points.
#define N
Definition: beziers.cpp:19
double y
double x

◆ makerects()

static SkPath makerects ( )
static

Definition at line 84 of file PathOpsBench.cpp.

84 {
85 SkRandom rand;
87 SkScalar scale = 100;
88 for (int i = 0; i < 20; ++i) {
89 SkScalar x = rand.nextUScalar1() * scale;
90 SkScalar y = rand.nextUScalar1() * scale;
91 path.addRect({x, y, x + scale, y + scale});
92 }
93 return path;
94}
Definition: SkPath.h:59
SkScalar nextUScalar1()
Definition: SkRandom.h:101
float SkScalar
Definition: extension.cpp:12
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
const Scalar scale

◆ run_builder()

template<typename T >
void run_builder ( T b,
bool  useReserve,
int  N 
)

Definition at line 126 of file PathOpsBench.cpp.

126 {
127 if (useReserve) {
128 b.incReserve(N * 12);
129 }
130
131 float x = 0, y = 0;
132 b.moveTo(x, y);
133 for (int i = 1; i < N; ++i) {
134 b.lineTo(x, y);
135 b.quadTo(x, y, x, y);
136 b.cubicTo(x, y, x, y, x, y);
137 }
138}
static bool b