Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
gradients_degenerate.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Classes

class  DegenerateGradientGM
 

Typedefs

typedef sk_sp< SkShader >(* GradientFactory) (SkTileMode tm)
 

Functions

static void draw_tile_header (SkCanvas *canvas)
 
static void draw_row (SkCanvas *canvas, const char *desc, GradientFactory factory)
 
static sk_sp< SkShadermake_linear (SkTileMode mode)
 
static sk_sp< SkShadermake_radial (SkTileMode mode)
 
static sk_sp< SkShadermake_sweep (SkTileMode mode)
 
static sk_sp< SkShadermake_sweep_zero_ang (SkTileMode mode)
 
static sk_sp< SkShadermake_2pt_conic (SkTileMode mode)
 
static sk_sp< SkShadermake_2pt_conic_zero_rad (SkTileMode mode)
 

Variables

static const SkColor COLORS []
 
static const SkScalar POS [] = { 0.0, 0.0, 0.5, 1.0, 1.0 }
 
static const int COLOR_CT = std::size(COLORS)
 
static const SkTileMode TILE_MODES []
 
static const char * TILE_NAMES [] = { "decal", "repeat", "mirror", "clamp" }
 
static const int TILE_MODE_CT = std::size(TILE_MODES)
 
static constexpr int TILE_SIZE = 100
 
static constexpr int TILE_GAP = 10
 
static const SkPoint CENTER = SkPoint::Make(TILE_SIZE / 2, TILE_SIZE / 2)
 

Typedef Documentation

◆ GradientFactory

typedef sk_sp< SkShader >(* GradientFactory) (SkTileMode tm)

Definition at line 46 of file gradients_degenerate.cpp.

Function Documentation

◆ draw_row()

static void draw_row ( SkCanvas canvas,
const char *  desc,
GradientFactory  factory 
)
static

Definition at line 63 of file gradients_degenerate.cpp.

63 {
64 canvas->save();
65
67 text.setAntiAlias(true);
68
70
71 canvas->translate(0, TILE_GAP);
72 canvas->drawString(desc, 0, 0, font, text);
73 canvas->translate(0, TILE_GAP);
74
76 paint.setColor(SK_ColorBLACK);
78 paint.setStrokeWidth(2.0f);
79
80 for (int i = 0; i < TILE_MODE_CT; ++i) {
81 paint.setShader(factory(TILE_MODES[i]));
83 canvas->translate(TILE_SIZE + TILE_GAP, 0);
84 }
85
86 canvas->restore();
87
88 // Now adjust to start the next row below this one (1 gap for text and 2 gap for margin)
89 canvas->translate(0, 3 * TILE_GAP + TILE_SIZE);
90}
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
void drawRect(const SkRect &rect, const SkPaint &paint)
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition SkCanvas.h:1803
void setAntiAlias(bool aa)
Definition SkPaint.h:170
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition SkPaint.h:195
const Paint & paint
static constexpr int TILE_SIZE
static const SkTileMode TILE_MODES[]
static constexpr int TILE_GAP
static const int TILE_MODE_CT
std::u16string text
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

◆ draw_tile_header()

static void draw_tile_header ( SkCanvas canvas)
static

Definition at line 48 of file gradients_degenerate.cpp.

48 {
49 canvas->save();
50
52 for (int i = 0; i < TILE_MODE_CT; ++i) {
53 canvas->drawString(TILE_NAMES[i], 0, 0, font, SkPaint());
54 canvas->translate(TILE_SIZE + TILE_GAP, 0);
55 }
56
57 canvas->restore();
58
59 // Now adjust to start at rows below the header
60 canvas->translate(0, 2 * TILE_GAP);
61}
static const char * TILE_NAMES[]

◆ make_2pt_conic()

static sk_sp< SkShader > make_2pt_conic ( SkTileMode  mode)
static

Definition at line 116 of file gradients_degenerate.cpp.

116 {
117 // Start and end radius = TILE_SIZE, same position
119 COLORS, POS, COLOR_CT, mode);
120}
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)
static const int COLOR_CT
static const SkColor COLORS[]
static const SkScalar POS[]
static const SkPoint CENTER

◆ make_2pt_conic_zero_rad()

static sk_sp< SkShader > make_2pt_conic_zero_rad ( SkTileMode  mode)
static

Definition at line 122 of file gradients_degenerate.cpp.

122 {
123 // Start and end radius = 0, same position
125 COLOR_CT, mode);
126}

◆ make_linear()

static sk_sp< SkShader > make_linear ( SkTileMode  mode)
static

Definition at line 92 of file gradients_degenerate.cpp.

92 {
93 // Same position
94 SkPoint pts[2] = {CENTER, CENTER};
96}
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)

◆ make_radial()

static sk_sp< SkShader > make_radial ( SkTileMode  mode)
static

Definition at line 98 of file gradients_degenerate.cpp.

98 {
99 // Radius = 0
101}
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)

◆ make_sweep()

static sk_sp< SkShader > make_sweep ( SkTileMode  mode)
static

Definition at line 103 of file gradients_degenerate.cpp.

103 {
104 // Start and end angles at 45
105 static constexpr SkScalar SWEEP_ANG = 45.0;
107 SWEEP_ANG, SWEEP_ANG, 0, nullptr);
108}
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)
float SkScalar
Definition extension.cpp:12
float fX
x-axis value
float fY
y-axis value

◆ make_sweep_zero_ang()

static sk_sp< SkShader > make_sweep_zero_ang ( SkTileMode  mode)
static

Definition at line 110 of file gradients_degenerate.cpp.

110 {
111 // Start and end angles at 0
113 0.0, 0.0, 0, nullptr);
114}

Variable Documentation

◆ CENTER

const SkPoint CENTER = SkPoint::Make(TILE_SIZE / 2, TILE_SIZE / 2)
static

Definition at line 44 of file gradients_degenerate.cpp.

◆ COLOR_CT

const int COLOR_CT = std::size(COLORS)
static

Definition at line 32 of file gradients_degenerate.cpp.

◆ COLORS

const SkColor COLORS[]
static
Initial value:
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122

Definition at line 29 of file gradients_degenerate.cpp.

◆ POS

const SkScalar POS[] = { 0.0, 0.0, 0.5, 1.0, 1.0 }
static

Definition at line 31 of file gradients_degenerate.cpp.

31{ 0.0, 0.0, 0.5, 1.0, 1.0 };

◆ TILE_GAP

constexpr int TILE_GAP = 10
staticconstexpr

Definition at line 42 of file gradients_degenerate.cpp.

◆ TILE_MODE_CT

const int TILE_MODE_CT = std::size(TILE_MODES)
static

Definition at line 39 of file gradients_degenerate.cpp.

◆ TILE_MODES

const SkTileMode TILE_MODES[]
static

◆ TILE_NAMES

const char* TILE_NAMES[] = { "decal", "repeat", "mirror", "clamp" }
static

Definition at line 38 of file gradients_degenerate.cpp.

38{ "decal", "repeat", "mirror", "clamp" };

◆ TILE_SIZE

constexpr int TILE_SIZE = 100
staticconstexpr

Definition at line 41 of file gradients_degenerate.cpp.