Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
tilemodes_scaled.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkImageInfo.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 "include/utils/SkTextUtils.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Classes

class  ScaledTilingGM
 
class  ScaledTiling2GM
 

Typedefs

typedef sk_sp< SkShader >(* ShaderProc) (SkTileMode, SkTileMode)
 

Functions

static void makebm (SkBitmap *bm, SkColorType ct, int w, int h)
 
static void setup (SkPaint *paint, const SkBitmap &bm, const SkSamplingOptions &sampling, SkTileMode tmx, SkTileMode tmy)
 
static sk_sp< SkShadermake_bm (SkTileMode tx, SkTileMode ty)
 
static sk_sp< SkShadermake_grad (SkTileMode tx, SkTileMode ty)
 

Variables

const SkSamplingOptions gSamplings []
 
constexpr SkColorType gColorTypes []
 
constexpr int gWidth = 32
 
constexpr int gHeight = 32
 

Typedef Documentation

◆ ShaderProc

typedef sk_sp< SkShader >(* ShaderProc) (SkTileMode, SkTileMode)

Definition at line 195 of file tilemodes_scaled.cpp.

Function Documentation

◆ make_bm()

static sk_sp< SkShader > make_bm ( SkTileMode  tx,
SkTileMode  ty 
)
static

Definition at line 170 of file tilemodes_scaled.cpp.

170 {
171 SkBitmap bm;
172 makebm(&bm, kN32_SkColorType, gWidth, gHeight);
173 return bm.makeShader(tx, ty, SkSamplingOptions());
174}
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkBitmap.cpp:669
static void makebm(SkBitmap *bm, SkColorType ct, int w, int h)
constexpr int gHeight
constexpr int gWidth

◆ make_grad()

static sk_sp< SkShader > make_grad ( SkTileMode  tx,
SkTileMode  ty 
)
static

Definition at line 176 of file tilemodes_scaled.cpp.

176 {
177 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
180 SkColor colors[] = {0xFFFF0000, ToolUtils::color_to_565(0xFF0044FF)};
181
182 int index = (int)ty;
183 switch (index % 3) {
184 case 0:
185 return SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors), tx);
186 case 1:
187 return SkGradientShader::MakeRadial(center, rad, colors, nullptr, std::size(colors), tx);
188 case 2:
189 return SkGradientShader::MakeSweep(center.fX, center.fY, colors, nullptr, std::size(colors));
190 }
191
192 return nullptr;
193}
uint32_t SkColor
Definition SkColor.h:37
#define SkIntToScalar(x)
Definition SkScalar.h:57
static SkScalar center(float pos0, float pos1)
Type::kYUV Type::kRGBA() int(0.7 *637)
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)
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)
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)
float SkScalar
Definition extension.cpp:12
PODArray< SkColor > colors
Definition SkRecords.h:276
SkColor color_to_565(SkColor color)

◆ makebm()

static void makebm ( SkBitmap bm,
SkColorType  ct,
int  w,
int  h 
)
static

Definition at line 38 of file tilemodes_scaled.cpp.

38 {
41
42 SkCanvas canvas(*bm);
43 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} };
45 SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
47
48 paint.setDither(true);
49 paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos,
50 std::size(colors), SkTileMode::kClamp));
51 canvas.drawPaint(paint);
52}
SkPoint pos
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
constexpr SkColor SK_ColorTRANSPARENT
Definition SkColor.h:99
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
#define SK_Scalar1
Definition SkScalar.h:18
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition SkBitmap.cpp:258
void eraseColor(SkColor4f) const
Definition SkBitmap.cpp:442
const Paint & paint
SkScalar w
SkScalar h
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ setup()

static void setup ( SkPaint paint,
const SkBitmap bm,
const SkSamplingOptions sampling,
SkTileMode  tmx,
SkTileMode  tmy 
)
static

Definition at line 54 of file tilemodes_scaled.cpp.

55 {
56 paint->setShader(bm.makeShader(tmx, tmy, sampling));
57}
SkTileMode tmy
SkTileMode tmx

Variable Documentation

◆ gColorTypes

constexpr SkColorType gColorTypes[]
constexpr
Initial value:
= {
kN32_SkColorType,
}
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22

Definition at line 59 of file tilemodes_scaled.cpp.

59 {
60 kN32_SkColorType,
62};

◆ gHeight

constexpr int gHeight = 32
constexpr

Definition at line 168 of file tilemodes_scaled.cpp.

◆ gSamplings

const SkSamplingOptions gSamplings[]

◆ gWidth

constexpr int gWidth = 32
constexpr

Definition at line 167 of file tilemodes_scaled.cpp.