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

Public Member Functions

 FontPaletteGM (const char *test_name, const SkFontArguments::Palette &paletteOverride)
 
- 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

sk_sp< SkTypefacefTypefaceDefault
 
sk_sp< SkTypefacefTypefaceFromStream
 
sk_sp< SkTypefacefTypefaceCloned
 

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 85 of file palette.cpp.

Constructor & Destructor Documentation

◆ FontPaletteGM()

skiagm::FontPaletteGM::FontPaletteGM ( const char *  test_name,
const SkFontArguments::Palette paletteOverride 
)
inline

Definition at line 87 of file palette.cpp.

88 : fName(test_name), fPalette(paletteOverride) {}

Member Function Documentation

◆ getISize()

SkISize skiagm::FontPaletteGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 111 of file palette.cpp.

111{ return SkISize::Make(1000, 400); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 106 of file palette.cpp.

106 {
107 SkString gm_name = SkStringPrintf("font_palette_%s", fName.c_str());
108 return gm_name;
109 }
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
const char * c_str() const
Definition: SkString.h:133

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 113 of file palette.cpp.

113 {
114 canvas->drawColor(SK_ColorWHITE);
116
117 canvas->translate(10, 20);
118
120 *errorMsg = "Did not recognize COLR v1 test font format.";
121 return DrawResult::kSkip;
122 }
123
124 SkFontMetrics metrics;
125 SkScalar y = 0;
126 SkScalar textSize = 200;
127 for (auto& typeface : {fTypefaceFromStream, fTypefaceCloned}) {
128 SkFont defaultFont(fTypefaceDefault);
129 SkFont paletteFont(typeface);
130 defaultFont.setSize(textSize);
131 paletteFont.setSize(textSize);
132
133 defaultFont.getMetrics(&metrics);
134 y += -metrics.fAscent;
135 // Set a recognizable foreground color which is not to be overriden.
136 paint.setColor(SK_ColorGRAY);
137 // Draw the default palette on the left, for COLRv0 and COLRv1.
138 canvas->drawSimpleText(
142 0,
143 y,
144 defaultFont,
145 paint);
146 // Draw the overriden palette on the right.
147 canvas->drawSimpleText(
151 440,
152 y,
153 paletteFont,
154 paint);
155 y += metrics.fDescent + metrics.fLeading;
156 }
157 return DrawResult::kOk;
158 }
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
@ kUTF32
uses four byte words to represent all of Unicode
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.cpp:2413
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
Definition: SkFont.h:35
sk_sp< SkTypeface > fTypefaceDefault
Definition: palette.cpp:91
sk_sp< SkTypeface > fTypefaceCloned
Definition: palette.cpp:93
sk_sp< SkTypeface > fTypefaceFromStream
Definition: palette.cpp:92
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
double y
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
const uint32_t color_circles_palette[]
Definition: palette.cpp:37
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

◆ onOnceBeforeDraw()

void skiagm::FontPaletteGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 95 of file palette.cpp.

95 {
96 SkFontArguments paletteArguments;
97 paletteArguments.setPalette(fPalette);
98
99 fTypefaceDefault = MakeTypefaceFromResource(kColrCpalTestFontPath, SkFontArguments());
101 fTypefaceDefault ? fTypefaceDefault->makeClone(paletteArguments) : nullptr;
102
103 fTypefaceFromStream = MakeTypefaceFromResource(kColrCpalTestFontPath, paletteArguments);
104 }
sk_sp< SkTypeface > makeClone(const SkFontArguments &) const
Definition: SkTypeface.cpp:190
SkFontArguments & setPalette(Palette palette)

Member Data Documentation

◆ fTypefaceCloned

sk_sp<SkTypeface> skiagm::FontPaletteGM::fTypefaceCloned
protected

Definition at line 93 of file palette.cpp.

◆ fTypefaceDefault

sk_sp<SkTypeface> skiagm::FontPaletteGM::fTypefaceDefault
protected

Definition at line 91 of file palette.cpp.

◆ fTypefaceFromStream

sk_sp<SkTypeface> skiagm::FontPaletteGM::fTypefaceFromStream
protected

Definition at line 92 of file palette.cpp.


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