Flutter Engine
The Flutter Engine
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 194 of file tilemodes_scaled.cpp.

Function Documentation

◆ make_bm()

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

Definition at line 168 of file tilemodes_scaled.cpp.

168 {
169 SkBitmap bm;
170 makebm(&bm, kN32_SkColorType, gWidth, gHeight);
171 return bm.makeShader(tx, ty, SkSamplingOptions());
172}
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
SkSamplingOptions(SkFilterMode::kLinear))
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 174 of file tilemodes_scaled.cpp.

174 {
175 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
178 SkColor colors[] = {0xFFFF0000, ToolUtils::color_to_565(0xFF0044FF)};
179
180 int index = (int)ty;
181 switch (index % 3) {
182 case 0:
183 return SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors), tx);
184 case 1:
185 return SkGradientShader::MakeRadial(center, rad, colors, nullptr, std::size(colors), tx);
186 case 2:
187 return SkGradientShader::MakeSweep(center.fX, center.fY, colors, nullptr,
188 std::size(colors), tx, 135, 225, 0, nullptr);
189 }
190
191 return nullptr;
192}
uint32_t SkColor
Definition: SkColor.h:37
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static SkScalar center(float pos0, float pos1)
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)
Definition: ToolUtils.cpp:139
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

◆ 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);
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
Definition: color_source.cc:38
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}
SkSamplingOptions sampling
Definition: SkRecords.h:337
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.

◆ gHeight

constexpr int gHeight = 32
constexpr

Definition at line 166 of file tilemodes_scaled.cpp.

◆ gSamplings

const SkSamplingOptions gSamplings[]

◆ gWidth

constexpr int gWidth = 32
constexpr

Definition at line 165 of file tilemodes_scaled.cpp.