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

Public Member Functions

 ScaledEmojiPerspectiveGM (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
 
SkString fStripSpacesSampleText
 

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

Constructor & Destructor Documentation

◆ ScaledEmojiPerspectiveGM()

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

Definition at line 153 of file scaledemoji.cpp.

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

Member Function Documentation

◆ getISize()

SkISize skiagm::ScaledEmojiPerspectiveGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 178 of file scaledemoji.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 174 of file scaledemoji.cpp.

174 {
175 return SkString("scaledemojiperspective_") += ToolUtils::NameForFontFormat(fFormat);
176 }
SkString NameForFontFormat(EmojiFontFormat format)

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 180 of file scaledemoji.cpp.

180 {
181 if (!fEmojiFont.typeface) {
182 *errorMsg = SkStringPrintf("Unable to instantiate emoji test font of format %s.",
183 ToolUtils::NameForFontFormat(fFormat).c_str());
184 return DrawResult::kSkip;
185 }
186
187 canvas->drawColor(SK_ColorGRAY);
188 SkMatrix taper;
189 taper.setPerspY(-0.0025f);
190
194
195 // draw text at different point sizes
196 // Testing GPU bitmap path, SDF path with no scaling,
197 // SDF path with scaling, path rendering with scaling
198 SkFontMetrics metrics;
199 font.getMetrics(&metrics);
200 for (auto rotate : {0.0, 45.0, 90.0, 135.0, 180.0, 225.0, 270.0, 315.0}) {
201 canvas->save();
202 SkMatrix perspective;
203 perspective.postTranslate(-600, -600);
204 perspective.postConcat(taper);
205 perspective.postRotate(rotate);
206 perspective.postTranslate(600, 600);
207 canvas->concat(perspective);
208 SkScalar y = 670;
209 for (int i = 0; i < 5; i++) {
210
211 y += -metrics.fAscent;
212
213 // Draw with an origin.
214 canvas->drawTextBlob(blob, 565, y, paint);
215
216 y += metrics.fDescent + metrics.fLeading;
217 }
218 canvas->restore();
219 }
220
221 return DrawResult::kOk;
222 }
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
static bool rotate(const SkDCubic &cubic, int zero, int index, SkDCubic &rotPath)
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 drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
Definition: SkFont.h:35
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:281
SkMatrix & postRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:474
SkMatrix & postConcat(const SkMatrix &other)
Definition: SkMatrix.cpp:683
SkMatrix & setPerspY(SkScalar v)
Definition: SkMatrix.h:544
const char * c_str() const
Definition: SkString.h:133
ToolUtils::EmojiTestSample fEmojiFont
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
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::ScaledEmojiPerspectiveGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 159 of file scaledemoji.cpp.

159 {
161
162 int count = 0;
163 const char* ch_ptr = fEmojiFont.sampleText;
164 const char* ch_end = ch_ptr + strlen(ch_ptr);
165 while (ch_ptr < ch_end && count < 2) {
166 SkUnichar ch = SkUTF::NextUTF8(&ch_ptr, ch_end);
167 if (ch != ' ') {
169 ++count;
170 }
171 }
172 }
int count
Definition: FontMgrTest.cpp:50
int32_t SkUnichar
Definition: SkTypes.h:175
void appendUnichar(SkUnichar uni)
Definition: SkString.h:207
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
Definition: SkUTF.cpp:118
EmojiTestSample EmojiSample()

Member Data Documentation

◆ fEmojiFont

ToolUtils::EmojiTestSample skiagm::ScaledEmojiPerspectiveGM::fEmojiFont
protected

Definition at line 156 of file scaledemoji.cpp.

◆ fStripSpacesSampleText

SkString skiagm::ScaledEmojiPerspectiveGM::fStripSpacesSampleText
protected

Definition at line 157 of file scaledemoji.cpp.


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