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

Public Member Functions

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

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 26 of file textblobuseaftergpufree.cpp.

Constructor & Destructor Documentation

◆ TextBlobUseAfterGpuFree()

skiagm::TextBlobUseAfterGpuFree::TextBlobUseAfterGpuFree ( )
inline

Definition at line 28 of file textblobuseaftergpufree.cpp.

28{ }

Member Function Documentation

◆ getISize()

SkISize skiagm::TextBlobUseAfterGpuFree::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 33 of file textblobuseaftergpufree.cpp.

33{ return SkISize::Make(kWidth, kHeight); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 31 of file textblobuseaftergpufree.cpp.

31{ return SkString("textblobuseaftergpufree"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 35 of file textblobuseaftergpufree.cpp.

35 {
36 auto dContext = GrAsDirectContext(canvas->recordingContext());
37
38 const char text[] = "Hamburgefons";
39
41 auto blob = SkTextBlob::MakeFromText(text, strlen(text), font);
42
43 // draw textblob
44 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight / 2.f);
45 SkPaint rectPaint;
46 rectPaint.setColor(0xffffffff);
47 canvas->drawRect(rect, rectPaint);
48 canvas->drawTextBlob(blob, 20, 60, SkPaint());
49
50 // This text should look fine
51 if (dContext) {
52 dContext->freeGpuResources();
53 }
54 canvas->drawTextBlob(blob, 20, 160, SkPaint());
55 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
Definition: SkFont.h:35
void setColor(SkColor color)
Definition: SkPaint.cpp:119
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition: SkTextBlob.cpp:788
std::u16string text
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

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