Flutter Engine
The Flutter Engine
Classes | Typedefs | Functions
AtlasSlide.cpp File Reference
#include "include/core/SkCanvas.h"
#include "include/core/SkDrawable.h"
#include "include/core/SkFont.h"
#include "include/core/SkPath.h"
#include "include/core/SkRSXform.h"
#include "include/core/SkSurface.h"
#include "include/utils/SkTextUtils.h"
#include "src/base/SkRandom.h"
#include "src/core/SkPaintPriv.h"
#include "tools/fonts/FontToolUtils.h"
#include "tools/viewer/Slide.h"

Go to the source code of this file.

Classes

class  DrawAtlasDrawable
 
class  DrawAtlasSlide
 

Typedefs

typedef void(* DrawAtlasProc) (SkCanvas *, SkImage *, const SkRSXform[], const SkRect[], const SkColor[], int, const SkRect *, const SkSamplingOptions &, const SkPaint *)
 

Functions

static void draw_atlas (SkCanvas *canvas, SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, const SkRect *cull, const SkSamplingOptions &sampling, const SkPaint *paint)
 
static void draw_atlas_sim (SkCanvas *canvas, SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, const SkRect *cull, const SkSamplingOptions &sampling, const SkPaint *paint)
 
static sk_sp< SkImagemake_atlas (int atlasSize, int cellSize)
 

Typedef Documentation

◆ DrawAtlasProc

typedef void(* DrawAtlasProc) (SkCanvas *, SkImage *, const SkRSXform[], const SkRect[], const SkColor[], int, const SkRect *, const SkSamplingOptions &, const SkPaint *)

Definition at line 20 of file AtlasSlide.cpp.

Function Documentation

◆ draw_atlas()

static void draw_atlas ( SkCanvas canvas,
SkImage atlas,
const SkRSXform  xform[],
const SkRect  tex[],
const SkColor  colors[],
int  count,
const SkRect cull,
const SkSamplingOptions sampling,
const SkPaint paint 
)
static

Definition at line 24 of file AtlasSlide.cpp.

26 {
27 canvas->drawAtlas(atlas, xform, tex, colors, count, SkBlendMode::kModulate,
28 sampling, cull, paint);
29}
int count
Definition: FontMgrTest.cpp:50
@ kModulate
r = s*d
void drawAtlas(const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint)
Definition: SkCanvas.cpp:1810
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337

◆ draw_atlas_sim()

static void draw_atlas_sim ( SkCanvas canvas,
SkImage atlas,
const SkRSXform  xform[],
const SkRect  tex[],
const SkColor  colors[],
int  count,
const SkRect cull,
const SkSamplingOptions sampling,
const SkPaint paint 
)
static

Definition at line 31 of file AtlasSlide.cpp.

33 {
34 for (int i = 0; i < count; ++i) {
36 matrix.setRSXform(xform[i]);
37
38 canvas->save();
39 canvas->concat(matrix);
40 canvas->drawImageRect(atlas, tex[i], tex[i].makeOffset(-tex[i].x(), -tex[i].y()),
42 canvas->restore();
43 }
44}
void restore()
Definition: SkCanvas.cpp:461
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
double y
double x
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ make_atlas()

static sk_sp< SkImage > make_atlas ( int  atlasSize,
int  cellSize 
)
static

Definition at line 46 of file AtlasSlide.cpp.

46 {
47 SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize);
49 SkCanvas* canvas = surface->getCanvas();
50
52 SkRandom rand;
53
54 const SkScalar half = cellSize * SK_ScalarHalf;
55 const char* s = "01234567890!@#$%^&*=+<>?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
57
58 int i = 0;
59 for (int y = 0; y < atlasSize; y += cellSize) {
60 for (int x = 0; x < atlasSize; x += cellSize) {
61 paint.setColor(rand.nextU());
62 paint.setAlpha(0xFF);
63 int index = i % strlen(s);
64 SkTextUtils::Draw(canvas, &s[index], 1, SkTextEncoding::kUTF8,
65 x + half, y + half + half/2, font, paint,
67 i += 1;
68 }
69 }
70 return surface->makeImageSnapshot();
71}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SK_ScalarHalf
Definition: SkScalar.h:19
Definition: SkFont.h:35
uint32_t nextU()
Definition: SkRandom.h:42
static void Draw(SkCanvas *, const void *text, size_t size, SkTextEncoding, SkScalar x, SkScalar y, const SkFont &, const SkPaint &, Align=kLeft_Align)
Definition: SkTextUtils.cpp:24
VkSurfaceKHR surface
Definition: main.cc:49
float SkScalar
Definition: extension.cpp:12
struct MyStruct s
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< SkTypeface > DefaultTypeface()
font
Font Metadata and Metrics.
static SkImageInfo MakeN32Premul(int width, int height)