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

Public Member Functions

 FontMgrBoundsGM (float scale, float skew)
 
- 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 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
 

Private Member Functions

SkString getName () const override
 
void onOnceBeforeDraw () override
 
bool onGetControls (SkMetaData *controls) override
 
void onSetControls (const SkMetaData &controls) override
 
SkISize getISize () override
 
DrawResult onDraw (SkCanvas *canvas, SkString *errorMsg) override
 

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 void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
GraphiteTestContextgraphiteTestContext () const
 

Detailed Description

Definition at line 208 of file fontmgr.cpp.

Constructor & Destructor Documentation

◆ FontMgrBoundsGM()

FontMgrBoundsGM::FontMgrBoundsGM ( float  scale,
float  skew 
)
inline

Definition at line 210 of file fontmgr.cpp.

210: fScaleX(scale) , fSkewX(skew) {}
const Scalar scale

Member Function Documentation

◆ getISize()

SkISize FontMgrBoundsGM::getISize ( )
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 331 of file fontmgr.cpp.

331{ return {1024, 850}; }

◆ getName()

SkString FontMgrBoundsGM::getName ( ) const
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 213 of file fontmgr.cpp.

213 {
214 if (fScaleX != 1 || fSkewX != 0) {
215 return SkStringPrintf("fontmgr_bounds_%g_%g", fScaleX, fSkewX);
216 }
217 return SkString("fontmgr_bounds");
218 }
SK_API SkString static SkString SkStringPrintf()
Definition SkString.h:287

◆ onDraw()

DrawResult FontMgrBoundsGM::onDraw ( SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 333 of file fontmgr.cpp.

333 {
336 font.setSubpixel(true);
337 font.setSize(100);
338 font.setScaleX(fScaleX);
339 font.setSkewX(fSkewX);
340
341 const SkColor boundsColors[2] = { SK_ColorRED, SK_ColorBLUE };
342
343 SkFontMgr* fm = fFM.get();
344 int count = std::min(fm->countFamilies(), 32);
345 if (count == 0) {
346 *errorMsg = "No families in SkFontMgr under test.";
347 return DrawResult::kSkip;
348 }
349
350 int index = 0;
351 SkScalar x = 0, y = 0;
352
353 canvas->translate(10, 120);
354
355 for (int i = 0; i < count; ++i) {
357 for (int j = 0; j < set->count() && j < 3; ++j) {
358 font.setTypeface(sk_sp<SkTypeface>(set->createTypeface(j)));
359 // Fonts with lots of glyphs are interesting, but can take a long time to find
360 // the glyphs which make up the maximum extent.
361 SkTypeface* typeface = font.getTypeface();
362 if (typeface && 0 < typeface->countGlyphs() && typeface->countGlyphs() < 1000) {
363 SkColor color = boundsColors[index & 1];
364 SkRect drawBounds = show_bounds(canvas, font, x, y, color, fLabelBounds);
365 x += drawBounds.width() + 20;
366 index += 1;
367 if (x > 900) {
368 x = 0;
369 y += 160;
370 }
371 if (y >= 700) {
372 return DrawResult::kOk;
373 }
374 }
375 }
376 }
377 return DrawResult::kOk;
378 }
int count
SkColor4f color
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
void translate(SkScalar dx, SkScalar dy)
sk_sp< SkFontStyleSet > createStyleSet(int index) const
int countFamilies() const
Definition SkFontMgr.cpp:93
@ kAntiAlias
may have transparent pixels on glyph edges
int countGlyphs() const
T * get() const
Definition SkRefCnt.h:303
float SkScalar
Definition extension.cpp:12
double y
double x
SkFont DefaultFont()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition switches.h:76
font
Font Metadata and Metrics.
constexpr float width() const
Definition SkRect.h:762

◆ onGetControls()

bool FontMgrBoundsGM::onGetControls ( SkMetaData controls)
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 222 of file fontmgr.cpp.

222 {
223 controls->setBool("Label Bounds", fLabelBounds);
224 return true;
225 }
void setBool(const char name[], bool value)

◆ onOnceBeforeDraw()

void FontMgrBoundsGM::onOnceBeforeDraw ( )
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 220 of file fontmgr.cpp.

220{ fFM = ToolUtils::TestFontMgr(); }
sk_sp< SkFontMgr > TestFontMgr()

◆ onSetControls()

void FontMgrBoundsGM::onSetControls ( const SkMetaData controls)
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 227 of file fontmgr.cpp.

227 {
228 controls.findBool("Label Bounds", &fLabelBounds);
229 }
bool findBool(const char name[], bool *value=nullptr) const

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