Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
skiagm::FontScalerGM Class Reference
Inheritance diagram for skiagm::FontScalerGM:
skiagm::GM

Public Member Functions

 FontScalerGM ()
 
- 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)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
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
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

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 []
 

Detailed Description

Definition at line 23 of file fontscaler.cpp.

Constructor & Destructor Documentation

◆ FontScalerGM()

skiagm::FontScalerGM::FontScalerGM ( )
inline

Definition at line 25 of file fontscaler.cpp.

25 {
26 this->setBGColor(0xFFFFFFFF);
27 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize skiagm::FontScalerGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 32 of file fontscaler.cpp.

32{ return SkISize::Make(1450, 750); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::FontScalerGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 30 of file fontscaler.cpp.

30{ return SkString("fontscaler"); }

◆ onDraw()

void skiagm::FontScalerGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 34 of file fontscaler.cpp.

34 {
37 //With freetype the default (normal hinting) can be really ugly.
38 //Most distros now set slight (vertical hinting only) in any event.
39 font.setHinting(SkFontHinting::kSlight);
40
41 const char* text = "Hamburgefons ooo mmm";
42 const size_t textLen = strlen(text);
43
44 for (int j = 0; j < 2; ++j) {
45 // This used to do 6 iterations but it causes the N4 to crash in the MSAA4 config.
46 for (int i = 0; i < 5; ++i) {
47 SkScalar x = 10;
48 SkScalar y = 20;
49
50 SkAutoCanvasRestore acr(canvas, true);
51 canvas->translate(SkIntToScalar(50 + i * 230),
52 SkIntToScalar(20));
53 canvas->rotate(SkIntToScalar(i * 5), x, y * 10);
54
55 {
56 SkPaint p;
57 p.setAntiAlias(true);
58 SkRect r;
59 r.setLTRB(x - 3, 15, x - 1, 280);
60 canvas->drawRect(r, p);
61 }
62
63 for (int ps = 6; ps <= 22; ps++) {
64 font.setSize(SkIntToScalar(ps));
65 canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, SkPaint());
66 y += font.getMetrics(nullptr);
67 }
68 }
69 canvas->translate(0, SkIntToScalar(360));
70 font.setSubpixel(true);
71 font.setLinearMetrics(true);
72 font.setBaselineSnap(false);
73 }
74 }
@ kSlight
minimal modification to improve constrast
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.cpp:2413
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
Definition: SkFont.h:35
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
double x
SkFont DefaultPortableFont()
font
Font Metadata and Metrics.
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

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