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

Public Member Functions

 TextBlobColorTrans ()
 
- 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 textblobcolortrans.cpp.

Constructor & Destructor Documentation

◆ TextBlobColorTrans()

skiagm::TextBlobColorTrans::TextBlobColorTrans ( )
inline

Definition at line 33 of file textblobcolortrans.cpp.

33{ }

Member Function Documentation

◆ getISize()

SkISize skiagm::TextBlobColorTrans::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 63 of file textblobcolortrans.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 61 of file textblobcolortrans.cpp.

61{ return SkString("textblobcolortrans"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 65 of file textblobcolortrans.cpp.

65 {
66
67 canvas->drawColor(SK_ColorGRAY);
68
70 canvas->translate(10, 40);
71
72 SkRect bounds = fBlob->bounds();
73
74 // Colors were chosen to map to pairs of canonical colors. The GPU Backend will cache A8
75 // Texture Blobs based on the canonical color they map to. Canonical colors are used to
76 // create masks. For A8 there are 8 of them.
78
79 size_t count = std::size(colors);
80 size_t colorIndex = 0;
81 for (int y = 0; y + SkScalarFloorToInt(bounds.height()) < kHeight;
82 y += SkScalarFloorToInt(bounds.height())) {
83 paint.setColor(colors[colorIndex++ % count]);
84 canvas->save();
85 canvas->translate(0, SkIntToScalar(y));
86 canvas->drawTextBlob(fBlob, 0, 0, paint);
87 canvas->restore();
88 }
89 }
int count
Definition: FontMgrTest.cpp:50
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorLTGRAY
Definition: SkColor.h:118
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkIntToScalar(x)
Definition: SkScalar.h:57
#define SkScalarFloorToInt(x)
Definition: SkScalar.h:35
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
int save()
Definition: SkCanvas.cpp:447
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
const SkRect & bounds() const
Definition: SkTextBlob.h:53
const Paint & paint
Definition: color_source.cc:38
double y
Optional< SkRect > bounds
Definition: SkRecords.h:189
PODArray< SkColor > colors
Definition: SkRecords.h:276
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

◆ onOnceBeforeDraw()

void skiagm::TextBlobColorTrans::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 36 of file textblobcolortrans.cpp.

36 {
38
39 // make textblob
40 // Large text is used to trigger atlas eviction
43 const char* text = "AB";
44
46 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
47
48 SkScalar yOffset = bounds.height();
49 ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);
50
51 // A8
52 font.setSize(28);
53 text = "The quick brown fox jumps over the lazy dog.";
54 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
55 ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 8);
56
57 // build
58 fBlob = builder.make();
59 }
@ 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: