Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
UserFontGM Class Reference
Inheritance diagram for UserFontGM:
skiagm::GM

Public Member Functions

 UserFontGM ()
 
void onOnceBeforeDraw () override
 
bool runAsBench () const override
 
SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Static Public Member Functions

static sk_sp< SkTextBlobmake_blob (sk_sp< SkTypeface > tf, float size, float *spacing)
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Detailed Description

Definition at line 89 of file userfont.cpp.

Constructor & Destructor Documentation

◆ UserFontGM()

UserFontGM::UserFontGM ( )
inline

Definition at line 93 of file userfont.cpp.

93{}

Member Function Documentation

◆ getISize()

SkISize UserFontGM::getISize ( )
inlineoverridevirtual

Implements skiagm::GM.

Definition at line 113 of file userfont.cpp.

113{ return {810, 452}; }

◆ getName()

SkString UserFontGM::getName ( ) const
inlineoverridevirtual

Implements skiagm::GM.

Definition at line 111 of file userfont.cpp.

111{ return SkString("user_typeface"); }

◆ make_blob()

static sk_sp< SkTextBlob > UserFontGM::make_blob ( sk_sp< SkTypeface tf,
float  size,
float *  spacing 
)
inlinestatic

Definition at line 101 of file userfont.cpp.

101 {
102 SkFont font(tf);
103 font.setSize(size);
105 *spacing = font.getMetrics(nullptr);
106 return SkTextBlob::MakeFromString("Typeface", font);
107 }
@ kAntiAlias
may have transparent pixels on glyph edges
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition SkTextBlob.h:115
font
Font Metadata and Metrics.

◆ onDraw()

void UserFontGM::onDraw ( SkCanvas canvas)
inlineoverridevirtual

Reimplemented from skiagm::GM.

Definition at line 115 of file userfont.cpp.

115 {
116 auto waterfall = [&](sk_sp<SkTypeface> tf, bool defaultFace) {
118 paint.setAntiAlias(true);
119
120 float spacing;
121 float x = 20,
122 y = 16;
123 for (float size = 9; size <= 100; size *= 1.25f) {
124 auto blob = make_blob(tf, size, &spacing);
125
126 // shared baseline
127 if (defaultFace) {
128 paint.setColor(0xFFDDDDDD);
129 canvas->drawRect({0, y, 810, y+1}, paint);
130 }
131
132 paint.setColor(0xFFCCCCCC);
134 canvas->drawRect(blob->bounds().makeOffset(x, y), paint);
135
136 paint.setStyle(SkPaint::kFill_Style);
137 paint.setColor(SK_ColorBLACK);
138 canvas->drawTextBlob(blob, x, y, paint);
139
140 y += SkScalarRoundToInt(spacing * 1.25f + 2);
141 }
142 };
143
144 waterfall(ToolUtils::DefaultTypeface(), true);
145 canvas->translate(400, 0);
146 waterfall(fTF, false);
147 }
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
#define SkScalarRoundToInt(x)
Definition SkScalar.h:37
static sk_sp< SkTextBlob > make_blob()
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
const Paint & paint
double y
double x
sk_sp< SkTypeface > DefaultTypeface()
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

◆ onOnceBeforeDraw()

void UserFontGM::onOnceBeforeDraw ( )
inlineoverridevirtual

Reimplemented from skiagm::GM.

Definition at line 95 of file userfont.cpp.

95 {
96 fTF = make_tf();
97 // test serialization
98 fTF = round_trip(fTF);
99 }
static sk_sp< SkTypeface > make_tf()
Definition userfont.cpp:38
static sk_sp< SkTypeface > round_trip(sk_sp< SkTypeface > tf)
Definition userfont.cpp:81

◆ runAsBench()

bool UserFontGM::runAsBench ( ) const
inlineoverridevirtual

Reimplemented from skiagm::GM.

Definition at line 109 of file userfont.cpp.

109{ return true; }

The documentation for this class was generated from the following file: