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

Public Member Functions

 ScaledEmojiGM (ToolUtils::EmojiFontFormat format)
 
- 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
 
DrawResult onDraw (SkCanvas *canvas, SkString *errorMsg) 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
 

Protected Attributes

ToolUtils::EmojiTestSample fEmojiFont
 

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 41 of file scaledemoji.cpp.

Constructor & Destructor Documentation

◆ ScaledEmojiGM()

skiagm::ScaledEmojiGM::ScaledEmojiGM ( ToolUtils::EmojiFontFormat  format)
inline

Definition at line 43 of file scaledemoji.cpp.

43: fFormat(format) {}
uint32_t uint32_t * format

Member Function Documentation

◆ getISize()

SkISize skiagm::ScaledEmojiGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 54 of file scaledemoji.cpp.

54{ return SkISize::Make(1200, 1200); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 50 of file scaledemoji.cpp.

50 {
51 return SkString("scaledemoji_") += ToolUtils::NameForFontFormat(fFormat);
52 }
SkString NameForFontFormat(EmojiFontFormat format)

◆ onDraw()

DrawResult skiagm::ScaledEmojiGM::onDraw ( SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 56 of file scaledemoji.cpp.

56 {
57 if (!fEmojiFont.typeface) {
58 *errorMsg = SkStringPrintf("Unable to instantiate emoji test font of format %s.",
59 ToolUtils::NameForFontFormat(fFormat).c_str());
60 return DrawResult::kSkip;
61 }
62
63 canvas->drawColor(SK_ColorGRAY);
64
68
69 const char* text = fEmojiFont.sampleText;
70
71 // draw text at different point sizes
72 // Testing GPU bitmap path, SDF path with no scaling,
73 // SDF path with scaling, path rendering with scaling
74 SkFontMetrics metrics;
75 SkScalar y = 0;
76 for (SkScalar textSize : {70, 180, 270, 340}) {
77 font.setSize(textSize);
78 font.getMetrics(&metrics);
79 y += -metrics.fAscent;
80 canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 10, y, font, paint);
81 y += metrics.fDescent + metrics.fLeading;
82 }
83
84 return DrawResult::kOk;
85 }
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
@ kUTF8
uses bytes to represent UTF-8 or ASCII
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
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 drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
Definition: SkFont.h:35
@ kAlias
no transparent pixels on glyph edges
ToolUtils::EmojiTestSample fEmojiFont
Definition: scaledemoji.cpp:46
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
font
Font Metadata and Metrics.
SkScalar fLeading
distance to add between lines, typically positive or zero
Definition: SkFontMetrics.h:57
SkScalar fAscent
distance to reserve above baseline, typically negative
Definition: SkFontMetrics.h:54
SkScalar fDescent
distance to reserve below baseline, typically positive
Definition: SkFontMetrics.h:55
sk_sp< SkTypeface > typeface
Definition: FontToolUtils.h:48

◆ onOnceBeforeDraw()

void skiagm::ScaledEmojiGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 48 of file scaledemoji.cpp.

EmojiTestSample EmojiSample()

Member Data Documentation

◆ fEmojiFont

ToolUtils::EmojiTestSample skiagm::ScaledEmojiGM::fEmojiFont
protected

Definition at line 46 of file scaledemoji.cpp.


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