Flutter Engine
The Flutter Engine
lcdoverlap.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm/gm.h"
12#include "include/core/SkFont.h"
14#include "include/core/SkRect.h"
17#include "include/core/SkSize.h"
22#include "tools/ToolUtils.h"
24
25namespace skiagm {
26
27constexpr int kWidth = 750;
28constexpr int kHeight = 750;
29
30class LcdOverlapGM : public skiagm::GM {
31public:
33 const int kPointSize = 25;
34 fTextHeight = SkIntToScalar(kPointSize);
35 }
36
37protected:
38 SkString getName() const override { return SkString("lcdoverlap"); }
39
40 void onOnceBeforeDraw() override {
41 // build text blob
43
45 const char* text = "able was I ere I saw elba";
46 font.setSubpixel(true);
49 fBlob = builder.make();
50 }
51
52 SkISize getISize() override { return SkISize::Make(kWidth, kHeight); }
53
55 SkBlendMode mode2) {
56 const SkColor colors[] {
63 };
64
65 for (size_t i = 0; i < std::size(colors); i++) {
66 canvas->save();
67 canvas->translate(x, y);
68 canvas->rotate(360.0f / std::size(colors) * i);
69 canvas->translate(-fBlob->bounds().width() / 2.0f - fBlob->bounds().left() + 0.5f, 0);
70
71 SkPaint textPaint;
72 textPaint.setColor(colors[i]);
73 textPaint.setBlendMode(i % 2 == 0 ? mode : mode2);
74 canvas->drawTextBlob(fBlob, 0, 0, textPaint);
75 canvas->restore();
76 }
77 }
78
79 void onDraw(SkCanvas* canvas) override {
80 SkScalar offsetX = kWidth / 4.0f;
81 SkScalar offsetY = kHeight / 4.0f;
87 }
88
89private:
90 SkScalar fTextHeight;
92 using INHERITED = skiagm::GM;
93};
94
95//////////////////////////////////////////////////////////////////////////////
96
97DEF_GM( return new LcdOverlapGM; )
98} // namespace skiagm
SkBlendMode
Definition: SkBlendMode.h:38
@ kSrcOver
r = s + (1-sa)*d
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kHardLight
multiply or screen, depending on source
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
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 SkIntToScalar(x)
Definition: SkScalar.h:57
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
int save()
Definition: SkCanvas.cpp:447
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
Definition: SkFont.h:35
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setBlendMode(SkBlendMode mode)
Definition: SkPaint.cpp:151
const SkRect & bounds() const
Definition: SkTextBlob.h:53
Definition: gm.h:110
void onOnceBeforeDraw() override
Definition: lcdoverlap.cpp:40
void drawTestCase(SkCanvas *canvas, SkScalar x, SkScalar y, SkBlendMode mode, SkBlendMode mode2)
Definition: lcdoverlap.cpp:54
SkISize getISize() override
Definition: lcdoverlap.cpp:52
void onDraw(SkCanvas *canvas) override
Definition: lcdoverlap.cpp:79
SkString getName() const override
Definition: lcdoverlap.cpp:38
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
double x
PODArray< SkColor > colors
Definition: SkRecords.h:276
sk_sp< SkTypeface > DefaultPortableTypeface()
void add_to_text_blob(SkTextBlobBuilder *builder, const char *text, const SkFont &font, SkScalar x, SkScalar y)
Definition: ToolUtils.cpp: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 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.
constexpr int kPointSize
Definition: shaderpath.cpp:61
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
constexpr int kWidth
constexpr int kHeight
SkScalar offsetX
SkScalar offsetY
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
constexpr float left() const
Definition: SkRect.h:734
constexpr float width() const
Definition: SkRect.h:762