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

Public Member Functions

 TextBlobMixedSizes (bool useDFT)
 
- 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 *inputCanvas) 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 42 of file textblobmixedsizes.cpp.

Constructor & Destructor Documentation

◆ TextBlobMixedSizes()

skiagm::TextBlobMixedSizes::TextBlobMixedSizes ( bool  useDFT)
inline

Definition at line 45 of file textblobmixedsizes.cpp.

45: fUseDFT(useDFT) {}

Member Function Documentation

◆ getISize()

SkISize skiagm::TextBlobMixedSizes::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 109 of file textblobmixedsizes.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 104 of file textblobmixedsizes.cpp.

104 {
105 return SkStringPrintf("textblobmixedsizes%s",
106 fUseDFT ? "_df" : "");
107 }
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.

◆ onDraw()

void skiagm::TextBlobMixedSizes::onDraw ( SkCanvas inputCanvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 111 of file textblobmixedsizes.cpp.

111 {
112 SkCanvas* canvas = inputCanvas;
114 if (fUseDFT) {
115 // Create a new Canvas to enable DFT
116 auto ctx = inputCanvas->recordingContext();
117#if defined(SK_GRAPHITE)
118 auto recorder = inputCanvas->recorder();
119#endif
120 SkISize size = this->getISize();
121 if (!inputCanvas->getBaseLayerSize().isEmpty()) {
122 size = inputCanvas->getBaseLayerSize();
123 }
124 sk_sp<SkColorSpace> colorSpace = inputCanvas->imageInfo().refColorSpace();
125 SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(),
126 kPremul_SkAlphaType, colorSpace);
127 SkSurfaceProps inputProps;
128 inputCanvas->getProps(&inputProps);
129 SkSurfaceProps props(
131 inputProps.pixelGeometry());
132#if defined(SK_GRAPHITE)
133 if (recorder) {
135 } else
136#endif
137 {
139 }
140 canvas = surface ? surface->getCanvas() : inputCanvas;
141 // init our new canvas with the old canvas's matrix
142 canvas->setMatrix(inputCanvas->getTotalMatrix());
143 }
144 canvas->drawColor(SK_ColorWHITE);
145
146 SkRect bounds = fBlob->bounds();
147
148 const int kPadX = SkScalarFloorToInt(bounds.width() / 3);
149 const int kPadY = SkScalarFloorToInt(bounds.height() / 3);
150
151 int rowCount = 0;
152 canvas->translate(SkIntToScalar(kPadX), SkIntToScalar(kPadY));
153 canvas->save();
154 SkRandom random;
155
157 if (!fUseDFT) {
158 paint.setColor(SK_ColorWHITE);
159 }
160 paint.setAntiAlias(false);
161
163
164 // setup blur paint
165 SkPaint blurPaint(paint);
166 blurPaint.setColor(SK_ColorBLACK);
167 blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma));
168
169 for (int i = 0; i < 4; i++) {
170 canvas->save();
171 switch (i % 2) {
172 case 0:
173 canvas->rotate(random.nextF() * 45.f);
174 break;
175 case 1:
176 canvas->rotate(-random.nextF() * 45.f);
177 break;
178 }
179 if (!fUseDFT) {
180 canvas->drawTextBlob(fBlob, 0, 0, blurPaint);
181 }
182 canvas->drawTextBlob(fBlob, 0, 0, paint);
183 canvas->restore();
184 canvas->translate(bounds.width() + SK_Scalar1 * kPadX, 0);
185 ++rowCount;
186 if ((bounds.width() + 2 * kPadX) * rowCount > kWidth) {
187 canvas->restore();
188 canvas->translate(0, bounds.height() + SK_Scalar1 * kPadY);
189 canvas->save();
190 rowCount = 0;
191 }
192 }
193 canvas->restore();
194
195 // render offscreen buffer
196 if (surface) {
197 SkAutoCanvasRestore acr(inputCanvas, true);
198 // since we prepended this matrix already, we blit using identity
199 inputCanvas->resetMatrix();
200 inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0);
201 }
202 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition: SkBlurTypes.h:12
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
#define SkScalarFloorToInt(x)
Definition: SkScalar.h:35
static SkScalar SK_SPI ConvertRadiusToSigma(SkScalar radius)
Definition: SkBlurMask.cpp:39
bool getProps(SkSurfaceProps *props) const
Definition: SkCanvas.cpp:1214
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
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
virtual skgpu::graphite::Recorder * recorder() const
Definition: SkCanvas.cpp:1641
virtual SkISize getBaseLayerSize() const
Definition: SkCanvas.cpp:369
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
SkMatrix getTotalMatrix() const
Definition: SkCanvas.cpp:1629
void resetMatrix()
Definition: SkCanvas.cpp:1355
int save()
Definition: SkCanvas.cpp:447
void setMatrix(const SkM44 &matrix)
Definition: SkCanvas.cpp:1349
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
float nextF()
Definition: SkRandom.h:55
@ kUseDeviceIndependentFonts_Flag
uint32_t flags() const
SkPixelGeometry pixelGeometry() const
const SkRect & bounds() const
Definition: SkTextBlob.h:53
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
float SkScalar
Definition: extension.cpp:12
Optional< SkRect > bounds
Definition: SkRecords.h:189
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
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
Definition: SkSize.h:16
bool isEmpty() const
Definition: SkSize.h:31
sk_sp< SkColorSpace > refColorSpace() const
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)

◆ onOnceBeforeDraw()

void skiagm::TextBlobMixedSizes::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 48 of file textblobmixedsizes.cpp.

48 {
50
51 // make textblob. To stress distance fields, we choose sizes appropriately
53 if (!tf) {
55 }
56 SkFont font(tf, 262);
57 font.setSubpixel(true);
59
60 const char* text = "Skia";
61
63
64 // large
66 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
67 SkScalar yOffset = bounds.height();
68 font.setSize(162);
69
71
72 // Medium
73 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
74 yOffset += bounds.height();
75 font.setSize(72);
76
78
79 // Small
80 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
81 yOffset += bounds.height();
82 font.setSize(32);
83
85
86 // micro (will fall out of distance field text even if distance field text is enabled)
87 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
88 yOffset += bounds.height();
89 font.setSize(14);
90
92
93 // Zero size.
94 font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
95 yOffset += bounds.height();
96 font.setSize(0);
97
99
100 // build
101 fBlob = builder.make();
102 }
@ kUTF8
uses bytes to represent UTF-8 or ASCII
Definition: SkFont.h:35
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
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
sk_sp< SkTypeface > CreateTypefaceFromResource(const char *resource, int ttcIndex)
font
Font Metadata and Metrics.

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