Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 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 DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
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 canvas->save();
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 canvas->restore();
98 }
99 }
100 x = 0;
101 y += maxH + 20.f;
102 maxH = 0;
103 }
104 }
105 // render offscreen buffer
106 if (surface) {
107 SkAutoCanvasRestore acr(inputCanvas, true);
108 // since we prepended this matrix already, we blit using identity
109 inputCanvas->resetMatrix();
110 inputCanvas->drawImage(surface->makeImageSnapshot().get(), 0, 0);
111 }
112 }
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:3824
SkISize getISize() override
bool getProps(SkSurfaceProps *props) const
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restore()
Definition SkCanvas.cpp:465
SkMatrix getLocalToDeviceAs3x3() const
Definition SkCanvas.h:2222
virtual GrRecordingContext * recordingContext() const
virtual SkISize getBaseLayerSize() const
Definition SkCanvas.cpp:373
void resetMatrix()
int save()
Definition SkCanvas.cpp:451
void setMatrix(const SkM44 &matrix)
SkImageInfo imageInfo() const
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
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
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 :
54 (i == 1 ? SkFont::Edging::kAntiAlias :
55 SkFont::Edging::kSubpixelAntiAlias));
56 font.setSubpixel(true);
58 ToolUtils::add_to_text_blob(&builder, "SkiaText", font, 0, 0);
59 fBlobs.emplace_back(builder.make());
60 }
61 }
@ kAlias
no transparent pixels on glyph edges
T & emplace_back(Args &&... args)
Definition SkTArray.h:243
SkFont DefaultPortableFont()
void add_to_text_blob(SkTextBlobBuilder *builder, const char *text, const SkFont &font, SkScalar x, SkScalar y)
@ kAntiAlias
Definition layer.h:52
font
Font Metadata and Metrics.

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