Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | List of all members
TextBlobGM Class Reference
Inheritance diagram for TextBlobGM:
skiagm::GM

Public Member Functions

 TextBlobGM (const char *txt)
 
- 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
 

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 82 of file textblob.cpp.

Constructor & Destructor Documentation

◆ TextBlobGM()

TextBlobGM::TextBlobGM ( const char *  txt)
inline

Definition at line 84 of file textblob.cpp.

85 : fText(txt) {
86 }

Member Function Documentation

◆ getISize()

SkISize TextBlobGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 101 of file textblob.cpp.

101{ return SkISize::Make(640, 480); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString TextBlobGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 99 of file textblob.cpp.

99{ return SkString("textblob"); }

◆ onDraw()

void TextBlobGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 103 of file textblob.cpp.

103 {
104 for (unsigned b = 0; b < std::size(blobConfigs); ++b) {
105 sk_sp<SkTextBlob> blob(this->makeBlob(b));
106
107 SkPaint p;
108 p.setAntiAlias(true);
109 SkPoint offset = SkPoint::Make(SkIntToScalar(10 + 300 * (b % 2)),
110 SkIntToScalar(20 + 150 * (b / 2)));
111
112 canvas->drawTextBlob(blob, offset.x(), offset.y(), p);
113
114 p.setColor(SK_ColorBLUE);
115 p.setStyle(SkPaint::kStroke_Style);
116 SkRect box = blob->bounds();
117 box.offset(offset);
118 p.setAntiAlias(false);
119 canvas->drawRect(box, p);
120
121 }
122 }
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
static bool b
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SeparatedVector2 offset
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
void offset(float dx, float dy)
Definition: SkRect.h:1016

◆ onOnceBeforeDraw()

void TextBlobGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 89 of file textblob.cpp.

89 {
90 fTypeface = ToolUtils::CreatePortableTypeface("serif", SkFontStyle());
91 SkFont font(fTypeface);
92 size_t txtLen = strlen(fText);
93 int glyphCount = font.countText(fText, txtLen, SkTextEncoding::kUTF8);
94
95 fGlyphs.append(glyphCount);
96 font.textToGlyphs(fText, txtLen, SkTextEncoding::kUTF8, fGlyphs.begin(), glyphCount);
97 }
@ kUTF8
uses bytes to represent UTF-8 or ASCII
Definition: SkFont.h:35
T * begin()
Definition: SkTDArray.h:150
T * append()
Definition: SkTDArray.h:191
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)
font
Font Metadata and Metrics.

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