Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Macros | Functions
gammatext.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/SkFontStyle.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/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Classes

class  GammaTextGM
 
class  GammaShaderTextGM
 

Macros

#define HEIGHT   480
 

Functions

static sk_sp< SkShadermake_heatGradient (const SkPoint pts[2])
 
static sk_sp< SkShadermake_gradient (SkColor c)
 
static void draw_pair (SkCanvas *canvas, const SkFont &font, SkColor color, const sk_sp< SkShader > &shader)
 
 DEF_SIMPLE_GM_BG (gammatext_color_shader, canvas, 300, 275, SK_ColorGRAY)
 

Macro Definition Documentation

◆ HEIGHT

#define HEIGHT   480

Test a set of clipping problems discovered while writing blitAntiRect, and test all the code paths through the clipping blitters. Each region should show as a blue center surrounded by a 2px green border, with no red.

Definition at line 40 of file gammatext.cpp.

Function Documentation

◆ DEF_SIMPLE_GM_BG()

DEF_SIMPLE_GM_BG ( gammatext_color_shader  ,
canvas  ,
300  ,
275  ,
SK_ColorGRAY   
)

Definition at line 160 of file gammatext.cpp.

160 {
161 const char* kText = "ABCDEFG";
163 SkASSERT(tf);
164 SkFont font(tf, 18);
166
167 canvas->translate(10, 30);
168 for (int i = 0; i < 256; i += 20) {
169 SkColor color = SkColorSetRGB(i, i, i);
171 paint.setColor(color);
172 canvas->drawString(kText, 0, 0, font, paint);
173 paint.setShader(SkShaders::Color(color));
174 canvas->drawString(kText, 100, 0, font, paint);
175 paint.setShader(SkShaders::Color(SkColor4f::FromColor(color), SkColorSpace::MakeSRGB()));
176 canvas->drawString(kText, 200, 0, font, paint);
177 canvas->translate(0, 20);
178 }
179}
SkColor4f color
#define SkASSERT(cond)
Definition SkAssert.h:116
uint32_t SkColor
Definition SkColor.h:37
#define SkColorSetRGB(r, g, b)
Definition SkColor.h:57
static sk_sp< SkColorSpace > MakeSRGB()
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
const Paint & paint
constexpr char kText[]
Definition glyph_pos.cpp:28
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)
font
Font Metadata and Metrics.
static SkRGBA4f FromColor(SkColor color)

◆ draw_pair()

static void draw_pair ( SkCanvas canvas,
const SkFont font,
SkColor  color,
const sk_sp< SkShader > &  shader 
)
static

Definition at line 105 of file gammatext.cpp.

106 {
107 static const char text[] = "Now is the time for all good";
109 paint.setColor(color);
110 canvas->drawString(text, 10, 20, font, paint);
111 paint.setShader(SkShaders::Color(paint.getColor()));
112 canvas->drawString(text, 10, 40, font, paint);
113 paint.setShader(shader);
114 canvas->drawString(text, 10, 60, font, paint);
115}
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition SkCanvas.h:1803
std::u16string text

◆ make_gradient()

static sk_sp< SkShader > make_gradient ( SkColor  c)
static

Definition at line 97 of file gammatext.cpp.

97 {
98 const SkPoint pts[] = { { 0, 0 }, { 240, 0 } };
99 SkColor colors[2];
100 colors[0] = c;
101 colors[1] = SkColorSetA(c, 0);
102 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kClamp);
103}
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
Definition SkColor.h:82
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)
PODArray< SkColor > colors
Definition SkRecords.h:276

◆ make_heatGradient()

static sk_sp< SkShader > make_heatGradient ( const SkPoint  pts[2])
static

Definition at line 27 of file gammatext.cpp.

27 {
28 const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE };
29
30 return SkGradientShader::MakeLinear(pts, bw, nullptr, std::size(bw), SkTileMode::kClamp);
31}
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122