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

Public Member Functions

 TextBlobBlockReordering ()
 
- 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 28 of file textblobblockreordering.cpp.

Constructor & Destructor Documentation

◆ TextBlobBlockReordering()

skiagm::TextBlobBlockReordering::TextBlobBlockReordering ( )
inline

Definition at line 32 of file textblobblockreordering.cpp.

32{ }

Member Function Documentation

◆ getISize()

SkISize skiagm::TextBlobBlockReordering::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 56 of file textblobblockreordering.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 54 of file textblobblockreordering.cpp.

54{ return SkString("textblobblockreordering"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 61 of file textblobblockreordering.cpp.

61 {
62 canvas->drawColor(SK_ColorGRAY);
63
65 canvas->translate(10, 40);
66
67 SkRect bounds = fBlob->bounds();
68 const int yDelta = SkScalarFloorToInt(bounds.height()) + 20;
69 const int xDelta = SkScalarFloorToInt(bounds.width());
70
71 canvas->drawTextBlob(fBlob, 0, 0, paint);
72
73 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta));
74
75 // Draw a rect where the text should be, and then twiddle the xfermode so we don't combine.
76 SkPaint redPaint;
77 redPaint.setColor(SK_ColorRED);
78 canvas->drawRect(bounds, redPaint);
79 SkPaint srcInPaint(paint);
80 srcInPaint.setBlendMode(SkBlendMode::kSrcIn);
81 canvas->drawTextBlob(fBlob, 0, 0, srcInPaint);
82
83 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta));
84 canvas->drawTextBlob(fBlob, 0, 0, paint);
85 }
@ kSrcIn
r = s * da
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
#define SkIntToScalar(x)
Definition: SkScalar.h:57
#define SkScalarFloorToInt(x)
Definition: SkScalar.h:35
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
void setColor(SkColor color)
Definition: SkPaint.cpp:119
const SkRect & bounds() const
Definition: SkTextBlob.h:53
const Paint & paint
Definition: color_source.cc:38
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ onOnceBeforeDraw()

void skiagm::TextBlobBlockReordering::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 35 of file textblobblockreordering.cpp.

35 {
37
38 // make textblob
39 // Large text is used to trigger atlas eviction
42 const char* text = "AB";
43
45 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
46
47 SkScalar yOffset = bounds.height();
48 ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);
49
50 // build
51 fBlob = builder.make();
52 }
@ kUTF8
uses bytes to represent UTF-8 or ASCII
Definition: SkFont.h:35
@ kAlias
no transparent pixels on glyph edges
float SkScalar
Definition: extension.cpp:12
std::u16string text
sk_sp< SkTypeface > DefaultPortableTypeface()
void add_to_text_blob(SkTextBlobBuilder *builder, const char *text, const SkFont &font, SkScalar x, SkScalar y)
Definition: ToolUtils.cpp:228
font
Font Metadata and Metrics.

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