Flutter Engine
The Flutter Engine
Modulate.cpp
Go to the documentation of this file.
1// Copyright 2019 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(Modulate, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 auto drawSquare = [=](int dx, int dy, SkBlendMode mode, const char* label) -> void {
8 const SkPoint horz[] = { { 0, 0 }, { 128, 0 } };
10 paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors),
12 paint.setBlendMode(mode);
13 canvas->translate(dx, dy);
14 canvas->drawRect({0, 0, 128, 128}, paint);
15 paint.setBlendMode(SkBlendMode::kXor);
16 SkFont font = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
17 canvas->drawString(label, 40, 100, font, paint);
18 };
19 drawSquare(0, 0, SkBlendMode::kSrc, "destination");
20 drawSquare(128, 0, SkBlendMode::kSrc, "");
21 drawSquare(0, 128, SkBlendMode::kSrc, "");
22 canvas->translate(-128, -128);
23 canvas->rotate(90, 0, 128);
24 drawSquare(0, 0, SkBlendMode::kSrc, "source");
25 drawSquare(0, -128, SkBlendMode::kModulate, "modulate");
26 drawSquare(-128, 0, SkBlendMode::kMultiply, "multiply");
27}
28} // END FIDDLE
REG_FIDDLE(Modulate, 256, 256, false, 0)
Definition: Modulate.cpp:4
SkBlendMode
Definition: SkBlendMode.h:38
@ kModulate
r = s*d
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kXor
r = s*(1-da) + d*(1-sa)
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
Definition: SkFont.h:35
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)
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
PODArray< SkColor > colors
Definition: SkRecords.h:276
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
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 mode
Definition: switches.h:228
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
font
Font Metadata and Metrics.