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

Public Member Functions

 ScaledEmojiPosGM (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 92 of file scaledemoji.cpp.

Constructor & Destructor Documentation

◆ ScaledEmojiPosGM()

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

Definition at line 94 of file scaledemoji.cpp.

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

Member Function Documentation

◆ getISize()

SkISize skiagm::ScaledEmojiPosGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 105 of file scaledemoji.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 101 of file scaledemoji.cpp.

101 {
102 return SkString("scaledemojipos_") += ToolUtils::NameForFontFormat(fFormat);
103 }
SkString NameForFontFormat(EmojiFontFormat format)

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 107 of file scaledemoji.cpp.

107 {
108 if (!fEmojiFont.typeface) {
109 *errorMsg = SkStringPrintf("Unable to instantiate emoji test font of format %s.",
110 ToolUtils::NameForFontFormat(fFormat).c_str());
111 return DrawResult::kSkip;
112 }
113
114 canvas->drawColor(SK_ColorGRAY);
115
118 const char* text = fEmojiFont.sampleText;
119
120 // draw text at different point sizes
121 // Testing GPU bitmap path, SDF path with no scaling,
122 // SDF path with scaling, path rendering with scaling
123 SkFontMetrics metrics;
124 SkScalar y = 0;
125 for (SkScalar textSize : {70, 180, 270, 340}) {
126 font.setSize(textSize);
127 font.getMetrics(&metrics);
128 y += -metrics.fAscent;
129
131 // Draw with an origin.
132 canvas->drawTextBlob(blob, 10, y, paint);
133
134 // Draw with shifted canvas.
135 canvas->save();
136 canvas->translate(750, 0);
137 canvas->drawTextBlob(blob, 10, y, paint);
138 canvas->restore();
139
140 y += metrics.fDescent + metrics.fLeading;
141 }
142
143 return DrawResult::kOk;
144 }
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
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 restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
int save()
Definition: SkCanvas.cpp:447
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
Definition: SkFont.h:35
ToolUtils::EmojiTestSample fEmojiFont
Definition: scaledemoji.cpp:97
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
font
Font Metadata and Metrics.
static sk_sp< SkTextBlob > make_hpos_test_blob_utf8(const char *text, const SkFont &font)
Definition: scaledemoji.cpp:28
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::ScaledEmojiPosGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 99 of file scaledemoji.cpp.

EmojiTestSample EmojiSample()

Member Data Documentation

◆ fEmojiFont

ToolUtils::EmojiTestSample skiagm::ScaledEmojiPosGM::fEmojiFont
protected

Definition at line 97 of file scaledemoji.cpp.


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