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

Public Member Functions

 TypefaceStylesGM (bool applyKerning)
 
- 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

void onOnceBeforeDraw () override
 
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 99 of file typeface.cpp.

Constructor & Destructor Documentation

◆ TypefaceStylesGM()

TypefaceStylesGM::TypefaceStylesGM ( bool  applyKerning)
inline

Definition at line 104 of file typeface.cpp.

104: fApplyKerning(applyKerning) {}
static void applyKerning(SkPoint pos[], const int32_t adjustments[], int count, const SkFont &font)
Definition: typeface.cpp:46

Member Function Documentation

◆ getISize()

SkISize TypefaceStylesGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 121 of file typeface.cpp.

121{ return SkISize::Make(640, 480); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString TypefaceStylesGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 113 of file typeface.cpp.

113 {
114 SkString name("typefacestyles");
115 if (fApplyKerning) {
116 name.append("_kerning");
117 }
118 return name;
119 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ onDraw()

void TypefaceStylesGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 123 of file typeface.cpp.

123 {
124 // Need to use a font to get dy below.
126 font.setSize(30);
127
128 const char* text = fApplyKerning ? "Type AWAY" : "Hamburgefons";
129 const size_t textLen = strlen(text);
130
132 SkScalar dy = font.getMetrics(nullptr);
133 SkASSERT(dy > 0);
134 SkScalar y = dy;
135
136 if (fApplyKerning) {
137 font.setSubpixel(true);
138 } else {
139 font.setLinearMetrics(true);
140 }
141
143 for (int i = 0; i < gStylesCount; i++) {
144 SkASSERT(fFaces[i]);
145 font.setTypeface(fFaces[i]);
146 canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, paint);
147 if (fApplyKerning) {
148 drawKernText(canvas, text, textLen, x + 240, y, font, paint);
149 }
150 y += dy;
151 }
152 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.cpp:2413
Definition: SkFont.h:35
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
double x
SkFont DefaultFont()
font
Font Metadata and Metrics.
constexpr int gStylesCount
Definition: typeface.cpp:96
static void drawKernText(SkCanvas *canvas, const void *text, size_t len, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: typeface.cpp:57

◆ onOnceBeforeDraw()

void TypefaceStylesGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 107 of file typeface.cpp.

107 {
108 for (int i = 0; i < gStylesCount; i++) {
109 fFaces[i] = ToolUtils::CreateTestTypeface(nullptr, gStyles[i]);
110 }
111 }
sk_sp< SkTypeface > CreateTestTypeface(const char *name, SkFontStyle style)
static constexpr SkFontStyle gStyles[]
Definition: typeface.cpp:89

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