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

Public Member Functions

 ScaledEmojiRenderingGM ()
 
- 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
 

Protected Attributes

ToolUtils::EmojiTestSample fontSamples [std::size(formatsToTest)]
 

Static Protected Attributes

static constexpr ToolUtils::EmojiFontFormat formatsToTest []
 

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 30 of file scaledemoji_rendering.cpp.

Constructor & Destructor Documentation

◆ ScaledEmojiRenderingGM()

skiagm::ScaledEmojiRenderingGM::ScaledEmojiRenderingGM ( )
inline

Definition at line 32 of file scaledemoji_rendering.cpp.

32{}

Member Function Documentation

◆ getISize()

SkISize skiagm::ScaledEmojiRenderingGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 54 of file scaledemoji_rendering.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 52 of file scaledemoji_rendering.cpp.

52{ return SkString("scaledemoji_rendering"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 56 of file scaledemoji_rendering.cpp.

56 {
57
58 canvas->drawColor(SK_ColorGRAY);
59 SkPaint textPaint;
60 textPaint.setColor(SK_ColorCYAN);
61
62 SkPaint boundsPaint;
63 boundsPaint.setStrokeWidth(2);
65 boundsPaint.setColor(SK_ColorGREEN);
66
67 SkPaint advancePaint;
68 advancePaint.setColor(SK_ColorRED);
69
70 SkScalar y = 0;
71 for (auto& sample : fontSamples) {
72 SkFont font(sample.typeface);
74
75 const char* text = sample.sampleText;
76 SkFontMetrics metrics;
77
78 for (SkScalar textSize : { 70, 150 }) {
79 font.setSize(textSize);
80 font.getMetrics(&metrics);
81 // All typefaces should support subpixel mode
82 font.setSubpixel(true);
83
84 y += -metrics.fAscent;
85
86 SkScalar x = 0;
87 for (bool fakeBold : { false, true }) {
88 font.setEmbolden(fakeBold);
90 SkScalar advance = font.measureText(text, strlen(text), SkTextEncoding::kUTF8,
91 &bounds, &textPaint);
93 x, y, font, textPaint);
94 if ((false)) {
95 bounds.offset(x, y);
96 canvas->drawRect(bounds, boundsPaint);
97 SkRect advanceRect = SkRect::MakeLTRB(x, y + 2, x + advance, y + 4);
98 canvas->drawRect(advanceRect, advancePaint);
99 }
100 x += bounds.width() * 1.2;
101 }
102 y += metrics.fDescent + metrics.fLeading;
103 x = 0;
104 }
105 }
106 }
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
@ kUTF8
uses bytes to represent UTF-8 or ASCII
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 drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
Definition: SkFont.h:35
@ kAlias
no transparent pixels on glyph edges
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
ToolUtils::EmojiTestSample fontSamples[std::size(formatsToTest)]
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
double x
Optional< SkRect > bounds
Definition: SkRecords.h:189
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
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ onOnceBeforeDraw()

void skiagm::ScaledEmojiRenderingGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 43 of file scaledemoji_rendering.cpp.

43 {
44 for (auto&& [i, format] : SkMakeEnumerate(formatsToTest)) {
46 if (!fontSamples[i].typeface) {
48 }
49 }
50 }
constexpr SkEnumerate< Iter > SkMakeEnumerate(C &c)
Definition: SkEnumerate.h:102
static constexpr ToolUtils::EmojiFontFormat formatsToTest[]
uint32_t uint32_t * format
EmojiTestSample EmojiSample()
sk_sp< SkTypeface > DefaultTypeface()
sk_sp< SkTypeface > typeface
Definition: FontToolUtils.h:48

Member Data Documentation

◆ fontSamples

ToolUtils::EmojiTestSample skiagm::ScaledEmojiRenderingGM::fontSamples[std::size(formatsToTest)]
protected

Definition at line 42 of file scaledemoji_rendering.cpp.

◆ formatsToTest

constexpr ToolUtils::EmojiFontFormat skiagm::ScaledEmojiRenderingGM::formatsToTest[]
staticconstexprprotected

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