Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Private Member Functions | List of all members
RSXShaderGM Class Reference
Inheritance diagram for RSXShaderGM:
skiagm::GM

Private Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () override
 
void onDraw (SkCanvas *canvas) override
 

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
 
- 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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 
- 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
 

Detailed Description

Definition at line 20 of file rsxtext.cpp.

Member Function Documentation

◆ getISize()

SkISize RSXShaderGM::getISize ( )
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 25 of file rsxtext.cpp.

25{ return SkISize::Make(kSZ * kScale * 2.1f, kSZ * kScale * 2.1f); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString RSXShaderGM::getName ( ) const
inlineoverrideprivatevirtual

Implements skiagm::GM.

Definition at line 23 of file rsxtext.cpp.

23{ return SkString("rsx_blob_shader"); }

◆ onDraw()

void RSXShaderGM::onDraw ( SkCanvas canvas)
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 57 of file rsxtext.cpp.

57 {
58 canvas->scale(kScale, kScale);
59 this->draw_one(canvas,
60 {0, 0}, SkMatrix::I(), SkMatrix::I());
61 this->draw_one(canvas,
62 {kSZ*1.1f, 0}, SkMatrix::Scale(2, 2), SkMatrix::I());
63 this->draw_one(canvas,
64 {0, kSZ*1.1f}, SkMatrix::I(), SkMatrix::RotateDeg(45));
65 this->draw_one(canvas,
66 {kSZ*1.1f, kSZ*1.1f}, SkMatrix::Scale(2, 2), SkMatrix::RotateDeg(45));
67 }
void scale(SkScalar sx, SkScalar sy)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition SkMatrix.h:75
static SkMatrix RotateDeg(SkScalar deg)
Definition SkMatrix.h:104
static const SkMatrix & I()

◆ onOnceBeforeDraw()

void RSXShaderGM::onOnceBeforeDraw ( )
inlineoverrideprivatevirtual

Reimplemented from skiagm::GM.

Definition at line 27 of file rsxtext.cpp.

27 {
31 SkFont font(ToolUtils::CreatePortableTypeface("Sans", style), kFontSZ);
33
34 static constexpr char txt[] = "TEST";
35 SkGlyphID glyphs[16];
36 float widths[16];
37 const auto glyph_count = font.textToGlyphs(txt, strlen(txt), SkTextEncoding::kUTF8,
38 glyphs, std::size(glyphs));
39 font.getWidths(glyphs, glyph_count, widths);
40
42 const auto& buf = builder.allocRunRSXform(font, glyph_count);
43 std::copy(glyphs, glyphs + glyph_count, buf.glyphs);
44
45 float x = 0;
46 for (int i = 0; i < glyph_count; ++i) {
47 buf.xforms()[i] = {
48 1, 0,
49 x, 0,
50 };
51 x += widths[i];
52 }
53
54 fBlob = builder.make();
55 }
uint16_t glyphs[5]
@ kUTF8
uses bytes to represent UTF-8 or ASCII
uint16_t SkGlyphID
Definition SkTypes.h:179
const SkScalar widths[]
@ kAntiAlias
may have transparent pixels on glyph edges
double x
sk_sp< SkTypeface > CreatePortableTypeface(const char *name, SkFontStyle style)
font
Font Metadata and Metrics.

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