Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
GradientBench.cpp File Reference
#include "bench/Benchmark.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorPriv.h"
#include "include/core/SkPaint.h"
#include "include/core/SkShader.h"
#include "include/core/SkString.h"
#include "include/effects/SkGradientShader.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Classes

struct  GradData
 
class  GradientBench
 
class  Gradient2Bench
 

Typedefs

typedef sk_sp< SkShader >(* GradMaker) (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 

Enumerations

enum  GradType {
  kLinear_GradType , kRadial_GradType , kSweep_GradType , kConical_GradType ,
  kConicalZero_GradType , kConicalOut_GradType , kConicalOutZero_GradType
}
 
enum  GeomType { kRect_GeomType , kOval_GeomType }
 

Functions

static sk_sp< SkShaderMakeLinear (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 Ignores scale.
 
static sk_sp< SkShaderMakeRadial (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 
static sk_sp< SkShaderMakeSweep (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 Ignores scale.
 
static sk_sp< SkShaderMakeConical (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 Ignores scale.
 
static sk_sp< SkShaderMakeConicalZeroRad (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 Ignores scale.
 
static sk_sp< SkShaderMakeConicalOutside (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 Ignores scale.
 
static sk_sp< SkShaderMakeConicalOutsideZeroRad (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
 Ignores scale.
 
static const char * geomtypename (GeomType gt)
 

Variables

static const SkColor gColors []
 
static const SkColor gShallowColors [] = { 0xFF555555, 0xFF444444 }
 
static const SkScalar gPos [] = {0.25f, 0.75f}
 
static const GradData gGradData []
 
struct { 
 
   GradMaker   fMaker 
 
   const char *   fName 
 
gGrads [] 
 

Typedef Documentation

◆ GradMaker

typedef sk_sp< SkShader >(* GradMaker) (const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)

Definition at line 129 of file GradientBench.cpp.

Enumeration Type Documentation

◆ GeomType

enum GeomType
Enumerator
kRect_GeomType 
kOval_GeomType 

Definition at line 155 of file GradientBench.cpp.

155 {
158};
@ kOval_GeomType
@ kRect_GeomType

◆ GradType

enum GradType
Enumerator
kLinear_GradType 
kRadial_GradType 
kSweep_GradType 
kConical_GradType 
kConicalZero_GradType 
kConicalOut_GradType 
kConicalOutZero_GradType 

Definition at line 145 of file GradientBench.cpp.

145 { // these must match the order in gGrads
153};
@ kSweep_GradType
@ kConical_GradType
@ kConicalZero_GradType
@ kRadial_GradType
@ kConicalOutZero_GradType
@ kLinear_GradType
@ kConicalOut_GradType

Function Documentation

◆ geomtypename()

static const char * geomtypename ( GeomType  gt)
static

Definition at line 160 of file GradientBench.cpp.

160 {
161 switch (gt) {
162 case kRect_GeomType:
163 return "rectangle";
164 case kOval_GeomType:
165 return "oval";
166 default:
167 SkDEBUGFAIL("unknown geometry type");
168 return "error";
169 }
170}
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118

◆ MakeConical()

static sk_sp< SkShader > MakeConical ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm,
float  scale 
)
static

Ignores scale.

Definition at line 76 of file GradientBench.cpp.

77 {
78 SkPoint center0, center1;
79 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
80 SkScalarAve(pts[0].fY, pts[1].fY));
81 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
82 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
83 return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7,
84 center0, (pts[1].fX - pts[0].fX) / 2,
85 data.fColors, data.fPos, data.fCount, tm);
86}
#define SkScalarAve(a, b)
Definition SkScalar.h:74
#define SkIntToScalar(x)
Definition SkScalar.h:57
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
Definition SkScalar.h:131
static sk_sp< SkShader > MakeTwoPointConical(const SkPoint &start, SkScalar startRadius, const SkPoint &end, SkScalar endRadius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
void set(float x, float y)

◆ MakeConicalOutside()

static sk_sp< SkShader > MakeConicalOutside ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm,
float  scale 
)
static

Ignores scale.

Definition at line 102 of file GradientBench.cpp.

103 {
104 SkPoint center0, center1;
105 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
106 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
107 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
108 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
109 return SkGradientShader::MakeTwoPointConical(center0, radius0,
110 center1, radius1,
111 data.fColors, data.fPos,
112 data.fCount, tm);
113}
float SkScalar
Definition extension.cpp:12
float fX
x-axis value

◆ MakeConicalOutsideZeroRad()

static sk_sp< SkShader > MakeConicalOutsideZeroRad ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm,
float  scale 
)
static

Ignores scale.

Definition at line 116 of file GradientBench.cpp.

117 {
118 SkPoint center0, center1;
119 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
120 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
121 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
122 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
123 return SkGradientShader::MakeTwoPointConical(center0, 0.0,
124 center1, radius1,
125 data.fColors, data.fPos,
126 data.fCount, tm);
127}

◆ MakeConicalZeroRad()

static sk_sp< SkShader > MakeConicalZeroRad ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm,
float  scale 
)
static

Ignores scale.

Definition at line 89 of file GradientBench.cpp.

90 {
91 SkPoint center0, center1;
92 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
93 SkScalarAve(pts[0].fY, pts[1].fY));
94 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
95 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
96 return SkGradientShader::MakeTwoPointConical(center1, 0.0,
97 center0, (pts[1].fX - pts[0].fX) / 2,
98 data.fColors, data.fPos, data.fCount, tm);
99}

◆ MakeLinear()

static sk_sp< SkShader > MakeLinear ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm,
float  scale 
)
static

Ignores scale.

Definition at line 52 of file GradientBench.cpp.

53 {
54 return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm);
55}
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)

◆ MakeRadial()

static sk_sp< SkShader > MakeRadial ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm,
float  scale 
)
static

Definition at line 57 of file GradientBench.cpp.

58 {
60 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
61 SkScalarAve(pts[0].fY, pts[1].fY));
63 data.fPos, data.fCount, tm);
64}
static SkScalar center(float pos0, float pos1)
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
const Scalar scale

◆ MakeSweep()

static sk_sp< SkShader > MakeSweep ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm,
float  scale 
)
static

Ignores scale.

Definition at line 67 of file GradientBench.cpp.

68 {
70 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
71 SkScalarAve(pts[0].fY, pts[1].fY));
72 return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
73}
static sk_sp< SkShader > MakeSweep(SkScalar cx, SkScalar cy, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, SkScalar startAngle, SkScalar endAngle, uint32_t flags, const SkMatrix *localMatrix)

Variable Documentation

◆ fMaker

GradMaker fMaker

Definition at line 133 of file GradientBench.cpp.

◆ fName

const char* fName

Definition at line 134 of file GradientBench.cpp.

◆ gColors

const SkColor gColors[]
static
Initial value:

Definition at line 25 of file GradientBench.cpp.

◆ gGradData

const GradData gGradData[]
static
Initial value:
= {
{ 2, gColors, nullptr, "" },
{ 50, gColors, nullptr, "_hicolor" },
{ 3, gColors, nullptr, "_3color" },
{ 2, gShallowColors, nullptr, "_shallow" },
{ 2, gColors, gPos, "_pos" },
}
static const SkColor gShallowColors[]
static const SkScalar gPos[]
static const SkColor gColors[]

Definition at line 43 of file GradientBench.cpp.

43 {
44 { 2, gColors, nullptr, "" },
45 { 50, gColors, nullptr, "_hicolor" }, // many color gradient
46 { 3, gColors, nullptr, "_3color" },
47 { 2, gShallowColors, nullptr, "_shallow" },
48 { 2, gColors, gPos, "_pos" },
49};

◆ [struct]

const struct { ... } gGrads[]
Initial value:
= {
{ MakeLinear, "linear" },
{ MakeRadial, "radial1" },
{ MakeSweep, "sweep" },
{ MakeConical, "conical" },
{ MakeConicalZeroRad, "conicalZero" },
{ MakeConicalOutside, "conicalOut" },
{ MakeConicalOutsideZeroRad, "conicalOutZero" },
}
static sk_sp< SkShader > MakeConical(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
static sk_sp< SkShader > MakeSweep(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
static sk_sp< SkShader > MakeConicalZeroRad(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
static sk_sp< SkShader > MakeConicalOutside(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
static sk_sp< SkShader > MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
static sk_sp< SkShader > MakeRadial()
static sk_sp< SkShader > MakeLinear()

◆ gPos

const SkScalar gPos[] = {0.25f, 0.75f}
static

Definition at line 39 of file GradientBench.cpp.

39{0.25f, 0.75f};

◆ gShallowColors

const SkColor gShallowColors[] = { 0xFF555555, 0xFF444444 }
static

Definition at line 38 of file GradientBench.cpp.

38{ 0xFF555555, 0xFF444444 };