Flutter Engine
The Flutter Engine
Functions | Variables
gradient_matrix.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkMatrix.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/SkTileMode.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"

Go to the source code of this file.

Functions

static sk_sp< SkShadermake_linear_gradient (const SkPoint pts[2], const SkMatrix &localMatrix)
 
static sk_sp< SkShadermake_radial_gradient (const SkPoint pts[2], const SkMatrix &localMatrix)
 
static void draw_gradients (SkCanvas *canvas, sk_sp< SkShader >(*makeShader)(const SkPoint[2], const SkMatrix &), const SkPoint ptsArray[][2], int numImages)
 
 DEF_SIMPLE_GM_BG (gradient_matrix, canvas, 800, 800, 0xFFDDDDDD)
 

Variables

constexpr SkColor gColors []
 
constexpr SkScalar sZero = 0
 
constexpr SkScalar sHalf = SK_ScalarHalf
 
constexpr SkScalar sOne = SK_Scalar1
 
constexpr SkPoint linearPts [][2]
 
constexpr SkPoint radialPts [][2]
 
constexpr SkScalar TESTGRID_X = SkIntToScalar(200)
 
constexpr SkScalar TESTGRID_Y = SkIntToScalar(200)
 
constexpr int IMAGES_X = 4
 

Function Documentation

◆ DEF_SIMPLE_GM_BG()

DEF_SIMPLE_GM_BG ( gradient_matrix  ,
canvas  ,
800  ,
800  ,
0xFFDDDDDD   
)

Definition at line 111 of file gradient_matrix.cpp.

111 {
114
115 canvas->translate(0, TESTGRID_Y);
116
119}
constexpr SkPoint linearPts[][2]
constexpr SkPoint radialPts[][2]
constexpr SkScalar TESTGRID_Y
static sk_sp< SkShader > make_linear_gradient(const SkPoint pts[2], const SkMatrix &localMatrix)
static void draw_gradients(SkCanvas *canvas, sk_sp< SkShader >(*makeShader)(const SkPoint[2], const SkMatrix &), const SkPoint ptsArray[][2], int numImages)
static sk_sp< SkShader > make_radial_gradient(const SkPoint pts[2], const SkMatrix &localMatrix)
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

◆ draw_gradients()

static void draw_gradients ( SkCanvas canvas,
sk_sp< SkShader >(*)(const SkPoint[2], const SkMatrix &)  makeShader,
const SkPoint  ptsArray[][2],
int  numImages 
)
static

Definition at line 78 of file gradient_matrix.cpp.

80 {
81 // Use some nice prime numbers for the rectangle and matrix with
82 // different scaling along the x and y axes (which is the bug this
83 // test addresses, where incorrect order of operations mixed up the axes)
84 SkRect rectGrad = {
86 SkIntToScalar(181), SkIntToScalar(167) };
87 SkMatrix shaderMat;
88 shaderMat.setScale(rectGrad.width(), rectGrad.height());
89 shaderMat.postTranslate(rectGrad.left(), rectGrad.top());
90
91 canvas->save();
92 for (int i = 0; i < numImages; i++) {
93 // Advance line downwards if necessary.
94 if (i % IMAGES_X == 0 && i != 0) {
95 canvas->restore();
96 canvas->translate(0, TESTGRID_Y);
97 canvas->save();
98 }
99
101 paint.setShader(makeShader(*ptsArray, shaderMat));
102 canvas->drawRect(rectGrad, paint);
103
104 // Advance to next position.
105 canvas->translate(TESTGRID_X, 0);
106 ptsArray++;
107 }
108 canvas->restore();
109}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:281
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:296
const Paint & paint
Definition: color_source.cc:38
constexpr SkScalar TESTGRID_X
constexpr int IMAGES_X
constexpr float left() const
Definition: SkRect.h:734
constexpr float top() const
Definition: SkRect.h:741
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762

◆ make_linear_gradient()

static sk_sp< SkShader > make_linear_gradient ( const SkPoint  pts[2],
const SkMatrix localMatrix 
)
static

Definition at line 64 of file gradient_matrix.cpp.

64 {
66 SkTileMode::kClamp, 0, &localMatrix);
67}
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)
constexpr SkColor gColors[]

◆ make_radial_gradient()

static sk_sp< SkShader > make_radial_gradient ( const SkPoint  pts[2],
const SkMatrix localMatrix 
)
static

Definition at line 69 of file gradient_matrix.cpp.

69 {
71 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
72 SkScalarAve(pts[0].fY, pts[1].fY));
73 float radius = (center - pts[0]).length();
75 SkTileMode::kClamp, 0, &localMatrix);
76}
#define SkScalarAve(a, b)
Definition: SkScalar.h:74
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)
size_t length

Variable Documentation

◆ gColors

constexpr SkColor gColors[]
constexpr
Initial value:
= {
}
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126

Definition at line 22 of file gradient_matrix.cpp.

◆ IMAGES_X

constexpr int IMAGES_X = 4
constexpr

Definition at line 62 of file gradient_matrix.cpp.

◆ linearPts

constexpr SkPoint linearPts[][2]
constexpr
Initial value:
= {
{{sZero, sZero}, {sOne, sZero}},
{{sZero, sZero}, {sZero, sOne}},
{{sOne, sZero}, {sZero, sZero}},
{{sZero, sOne}, {sZero, sZero}},
{{sZero, sZero}, {sOne, sOne}},
{{sOne, sOne}, {sZero, sZero}},
{{sOne, sZero}, {sZero, sOne}},
{{sZero, sOne}, {sOne, sZero}}
}
constexpr SkScalar sZero
constexpr SkScalar sOne

Definition at line 34 of file gradient_matrix.cpp.

◆ radialPts

constexpr SkPoint radialPts[][2]
constexpr
Initial value:
= {
{{sZero, sHalf}, {sOne, sHalf}},
{{sHalf, sZero}, {sHalf, sOne}},
{{sOne, sHalf}, {sZero, sHalf}},
{{sHalf, sOne}, {sHalf, sZero}},
{{sZero, sZero}, {sOne, sOne}},
{{sOne, sOne}, {sZero, sZero}},
{{sOne, sZero}, {sZero, sOne}},
{{sZero, sOne}, {sOne, sZero}}
}
constexpr SkScalar sHalf

Definition at line 46 of file gradient_matrix.cpp.

◆ sHalf

constexpr SkScalar sHalf = SK_ScalarHalf
constexpr

Definition at line 29 of file gradient_matrix.cpp.

◆ sOne

constexpr SkScalar sOne = SK_Scalar1
constexpr

Definition at line 30 of file gradient_matrix.cpp.

◆ sZero

constexpr SkScalar sZero = 0
constexpr

Definition at line 28 of file gradient_matrix.cpp.

◆ TESTGRID_X

constexpr SkScalar TESTGRID_X = SkIntToScalar(200)
constexpr

Definition at line 59 of file gradient_matrix.cpp.

◆ TESTGRID_Y

constexpr SkScalar TESTGRID_Y = SkIntToScalar(200)
constexpr

Definition at line 60 of file gradient_matrix.cpp.