Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
hello_bazel_world.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2023 Google LLC
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
// The purpose of this Bazel-only GM is to experiment with a task driver that uploads PNGs produced
9
// by GMs executed via Bazel. By creating a GM specific for these experiments, we avoid uploading
10
// spurious digests with potentially incorrect keys that would be grouped with existing digests.
11
//
12
// Based on //gm/bigtext.cpp.
13
//
14
// TODO(lovisolo): Delete once we migrate other GMs to Bazel.
15
16
#include "
gm/gm.h
"
17
#include "
include/core/SkCanvas.h
"
18
#include "
include/core/SkColor.h
"
19
#include "
include/core/SkFont.h
"
20
#include "
include/core/SkFontTypes.h
"
21
#include "
include/core/SkPaint.h
"
22
#include "
include/core/SkPoint.h
"
23
#include "
include/core/SkRect.h
"
24
#include "
include/core/SkSize.h
"
25
#include "
include/core/SkString.h
"
26
#include "
include/core/SkTypeface.h
"
27
#include "
tools/Resources.h
"
28
#include "
tools/ToolUtils.h
"
29
#include "
tools/fonts/FontToolUtils.h
"
30
31
class
HelloBazelWorldGM
:
public
skiagm::GM
{
32
public
:
33
HelloBazelWorldGM
() {}
34
35
protected
:
36
SkString
getName
()
const override
{
return
SkString
(
"HelloBazelWorld"
); }
37
38
SkISize
getISize
()
override
{
return
SkISize::Make
(500, 500); }
39
40
bool
isBazelOnly
()
const override
{
return
true
; }
41
42
void
onDraw
(
SkCanvas
* canvas)
override
{
43
SkPaint
paint
;
44
paint
.setAntiAlias(
true
);
45
SkFont
font(
ToolUtils::DefaultPortableTypeface
(), 50);
46
47
const
char
*
text
=
"Hello, Bazel world!"
;
48
size_t
text_length = strlen(
text
);
49
50
SkRect
r;
51
(void)font.measureText(
text
, text_length,
SkTextEncoding::kUTF8
, &r);
52
SkPoint
pos
= {this->
width
() / 2 - r.
centerX
(), this->
height
() / 2 - r.
centerY
()};
53
54
paint
.setColor(
SK_ColorRED
);
55
canvas->
drawSimpleText
(
56
text
, text_length,
SkTextEncoding::kUTF8
,
pos
.
fX
,
pos
.
fY
, font,
paint
);
57
}
58
};
59
60
DEF_GM
(
return
new
HelloBazelWorldGM
;)
FontToolUtils.h
pos
SkPoint pos
Definition
ImageShaderTest.cpp:27
Resources.h
SkCanvas.h
SkColor.h
SK_ColorRED
constexpr SkColor SK_ColorRED
Definition
SkColor.h:126
SkFontTypes.h
SkTextEncoding::kUTF8
@ kUTF8
uses bytes to represent UTF-8 or ASCII
SkFont.h
SkPaint.h
SkPoint.h
SkRect.h
SkSize.h
SkString.h
SkTypeface.h
ToolUtils.h
HelloBazelWorldGM
Definition
hello_bazel_world.cpp:31
HelloBazelWorldGM::getName
SkString getName() const override
Definition
hello_bazel_world.cpp:36
HelloBazelWorldGM::onDraw
void onDraw(SkCanvas *canvas) override
Definition
hello_bazel_world.cpp:42
HelloBazelWorldGM::isBazelOnly
bool isBazelOnly() const override
Definition
hello_bazel_world.cpp:40
HelloBazelWorldGM::getISize
SkISize getISize() override
Definition
hello_bazel_world.cpp:38
HelloBazelWorldGM::HelloBazelWorldGM
HelloBazelWorldGM()
Definition
hello_bazel_world.cpp:33
SkCanvas
Definition
SkCanvas.h:106
SkCanvas::drawSimpleText
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition
SkCanvas.cpp:2840
SkFont
Definition
SkFont.h:35
SkPaint
Definition
SkPaint.h:44
SkString
Definition
SkString.h:118
skiagm::GM
Definition
gm.h:110
skiagm::GM::width
SkScalar width()
Definition
gm.h:159
skiagm::GM::height
SkScalar height()
Definition
gm.h:162
paint
const Paint & paint
Definition
color_source.cc:38
gm.h
DEF_GM
#define DEF_GM(CODE)
Definition
gm.h:40
text
std::u16string text
Definition
keyboard_unittests.cc:332
ToolUtils::DefaultPortableTypeface
sk_sp< SkTypeface > DefaultPortableTypeface()
Definition
FontToolUtils.cpp:195
SkISize
Definition
SkSize.h:16
SkISize::Make
static constexpr SkISize Make(int32_t w, int32_t h)
Definition
SkSize.h:20
SkPoint
Definition
SkPoint_impl.h:163
SkPoint::fX
float fX
x-axis value
Definition
SkPoint_impl.h:164
SkPoint::fY
float fY
y-axis value
Definition
SkPoint_impl.h:165
SkRect
Definition
extension.cpp:13
SkRect::centerX
constexpr float centerX() const
Definition
SkRect.h:776
SkRect::centerY
constexpr float centerY() const
Definition
SkRect.h:785
Generated on Fri Apr 26 2024 06:16:05 for Flutter Engine by
1.9.8