28 fDrawTexturesToScreen = !fDrawTexturesToScreen;
30 }
else if (
'>' == uni) {
31 fTileSize =
std::min(kMaxTileSize, 2*fTileSize);
32 fTileRows = kMaxTileSize/fTileSize;
33 fTileCols = kMaxTileSize/fTileSize;
34 fCachedContext =
nullptr;
35 }
else if (
'<' == uni) {
36 fTileSize =
std::max(kMinTileSize, fTileSize/2);
37 fTileRows = kMaxTileSize/fTileSize;
38 fTileCols = kMaxTileSize/fTileSize;
39 fCachedContext =
nullptr;
47 canvas->
clear(0xFFFFFFFF);
52 if (direct != fCachedContext) {
53 fCachedContext = direct;
54 this->initializeTextures(direct);
59 int textureCount = fTileRows * fTileCols;
60 for (
int i = 0;
i < textureCount;
i++) {
61 fTextures[
i]->uploadRasterSurface(
i == fActiveTileIndex ? fBlueSurface
66 canvas->
scale(kGridScale, kGridScale);
68 if (fDrawTexturesToScreen) {
69 for (
int y = 0;
y < fTileRows;
y++) {
70 for (
int x = 0;
x < fTileCols;
x++) {
71 int currentIndex =
y * fTileCols +
x;
72 canvas->
drawImage(fTextures[currentIndex]->getImage(),
73 x * fTileSize,
y * fTileSize);
82 constexpr SkScalar kDesiredDurationSecs = 16.0f;
83 float numTiles = fTileRows*fTileCols;
85 numTiles/kDesiredDurationSecs, numTiles));
90 class RenderTargetTexture :
public SkRefCnt {
101 return fSurface->makeImageSnapshot();
107 fSurface->writePixels(pixmap, 0, 0);
115 inline static constexpr int kMinTileSize = 128;
116 inline static constexpr int kMaxTileSize = 2048;
117 inline static constexpr float kGridScale = 0.25f;
119 bool fDrawTexturesToScreen =
true;
141 int textureCount = fTileRows * fTileCols;
142 for (
int i = 0;
i < textureCount;
i++) {
143 fTextures.
emplace_back(
new RenderTargetTexture(direct, fTileSize));
148 fBlueSurface = this->getFilledRasterSurface(
SK_ColorBLUE, fTileSize);
149 fGraySurface = this->getFilledRasterSurface(
SK_ColorGRAY, fTileSize);
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorGRAY
constexpr SkColor SK_ColorBLUE
virtual GrRecordingContext * recordingContext() const
void clear(SkColor color)
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
bool peekPixels(SkPixmap *pixmap)
bool onChar(SkUnichar uni) override
bool animate(double nanos) override
void draw(SkCanvas *canvas) override
SkISize getDimensions() const override
T & emplace_back(Args &&... args)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static float Scaled(float time, float speed, float period=0)
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
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)