Flutter Engine
The Flutter Engine
purplestamp.cpp
Go to the documentation of this file.
1// Copyright 2020 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(purplestamp, 256, 256, false, 0) {
5// purplestamp
6
7// Whether to use a separate bitmap (with a color type) at all.
8bool drawWithRasterImage = true;
9
10// This works with either kN32_SkColorType or kAlpha_8_SkColorType.
11// Applies only if drawWithRasterImage is true.
12SkColorType colorType = kN32_SkColorType;
13
14void drawStamp(SkCanvas* canvas, int size) {
15 canvas->save();
17
18 canvas->clear(0x3F000000 /* translucent black */);
19
21 paint.setAntiAlias(true);
22 paint.setColor(SK_ColorBLACK);
23 canvas->drawRRect(
25
27 paint.setStrokeWidth(20);
29
30 canvas->restore();
31}
32
33sk_sp<SkImage> stampImage(int size) {
36 drawStamp(surface->getCanvas(), size);
37 return surface->makeImageSnapshot();
38}
39
40void draw(SkCanvas* canvas) {
42 paint.setColorFilter(SkColorFilters::Blend(0xFF7F00FF, SkBlendMode::kSrcIn));
43 paint.setAntiAlias(true);
44
46
47 canvas->rotate(30);
48 canvas->translate(60, 0);
49
50 int stampSize = 200;
51 if (drawWithRasterImage) {
52 canvas->drawImage(stampImage(stampSize), 0, 0, sampling, &paint);
53 } else {
54 canvas->saveLayer(nullptr, &paint);
55 drawStamp(canvas, stampSize);
56 canvas->restore();
57 }
58}
59} // END FIDDLE
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kSrcIn
r = s * da
SkColorType
Definition: SkColorType.h:19
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
int save()
Definition: SkCanvas.cpp:447
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
static SkRRect MakeOval(const SkRect &oval)
Definition: SkRRect.h:162
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
SkSamplingOptions sampling
Definition: SkRecords.h:337
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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
REG_FIDDLE(purplestamp, 256, 256, false, 0)
Definition: purplestamp.cpp:4
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609