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

Public Member Functions

 DFTextBlobPerspGM ()
 
- 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 onOnceBeforeDraw () 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

This GM tests reusing the same text blobs with distance fields rendering using various combinations of perspective and non-perspetive matrices, scissor clips, and different x,y params passed to the draw.

Definition at line 40 of file dftext_blob_persp.cpp.

Constructor & Destructor Documentation

◆ DFTextBlobPerspGM()

DFTextBlobPerspGM::DFTextBlobPerspGM ( )
inline

Definition at line 42 of file dftext_blob_persp.cpp.

42{ this->setBGColor(0xFFFFFFFF); }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize DFTextBlobPerspGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 47 of file dftext_blob_persp.cpp.

47{ return SkISize::Make(900, 350); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString DFTextBlobPerspGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 45 of file dftext_blob_persp.cpp.

45{ return SkString("dftext_blob_persp"); }

◆ onDraw()

void DFTextBlobPerspGM::onDraw ( SkCanvas inputCanvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 63 of file dftext_blob_persp.cpp.

63 {
64 // set up offscreen rendering with distance field text
65 auto ctx = inputCanvas->recordingContext();
66 SkISize size = this->getISize();
67 if (!inputCanvas->getBaseLayerSize().isEmpty()) {
68 size = inputCanvas->getBaseLayerSize();
69 }
71 inputCanvas->imageInfo().refColorSpace());
72 SkSurfaceProps inputProps;
73 inputCanvas->getProps(&inputProps);
75 inputProps.pixelGeometry());
77 SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
78 // init our new canvas with the old canvas's matrix
79 canvas->setMatrix(inputCanvas->getLocalToDeviceAs3x3());
80 SkScalar x = 0, y = 0;
81 SkScalar maxH = 0;
82 for (auto twm : {TranslateWithMatrix::kNo, TranslateWithMatrix::kYes}) {
83 for (auto pm : {PerspMode::kNone, PerspMode::kX, PerspMode::kY, PerspMode::kXY}) {
84 for (auto& blob : fBlobs) {
85 for (bool clip : {false, true}) {
86 SkAutoCanvasRestore acr(canvas, true);
87 SkScalar w = blob->bounds().width();
88 SkScalar h = blob->bounds().height();
89 if (clip) {
90 auto rect =
91 SkRect::MakeXYWH(x + 5, y + 5, w * 3.f / 4.f, h * 3.f / 4.f);
92 canvas->clipRect(rect, false);
93 }
94 this->drawBlob(canvas, blob.get(), SK_ColorBLACK, x, y + h, pm, twm);
95 x += w + 20.f;
96 maxH = std::max(h, maxH);
97 }
98 }
99 x = 0;
100 y += maxH + 20.f;
101 maxH = 0;
102 }
103 }
104 // render offscreen buffer
105 if (surface) {
106 SkAutoCanvasRestore acr(inputCanvas, true);
107 // since we prepended this matrix already, we blit using identity
108 inputCanvas->resetMatrix();
109 inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0);
110 }
111 }
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
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
SkISize getISize() override
bool getProps(SkSurfaceProps *props) const
Definition: SkCanvas.cpp:1214
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
SkMatrix getLocalToDeviceAs3x3() const
Definition: SkCanvas.h:2222
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
virtual SkISize getBaseLayerSize() const
Definition: SkCanvas.cpp:369
void resetMatrix()
Definition: SkCanvas.cpp:1355
void setMatrix(const SkM44 &matrix)
Definition: SkCanvas.cpp:1349
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
@ kUseDeviceIndependentFonts_Flag
uint32_t flags() const
SkPixelGeometry pixelGeometry() const
VkSurfaceKHR surface
Definition: main.cc:49
float SkScalar
Definition: extension.cpp:12
static float max(float r, float g, float b)
Definition: hsl.cpp:49
double y
double x
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
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
SkScalar w
SkScalar h
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)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ onOnceBeforeDraw()

void DFTextBlobPerspGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 49 of file dftext_blob_persp.cpp.

49 {
50 for (int i = 0; i < 3; ++i) {
52 font.setSize(32);
53 font.setEdging(i == 0 ? SkFont::Edging::kAlias :
56 font.setSubpixel(true);
58 ToolUtils::add_to_text_blob(&builder, "SkiaText", font, 0, 0);
59 fBlobs.emplace_back(builder.make());
60 }
61 }
Definition: SkFont.h:35
@ kAntiAlias
may have transparent pixels on glyph edges
@ kAlias
no transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
T & emplace_back(Args &&... args)
Definition: SkTArray.h:248
SkFont DefaultPortableFont()
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: