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

Public Member Functions

 SamplerStressGM ()
 
- 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 createTexture ()
 
void createShader ()
 
void createMaskFilter ()
 
void onDraw (SkCanvas *canvas) 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 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

Stress test the GPU samplers by rendering a textured glyph with a mask and an AA clip

Definition at line 34 of file samplerstress.cpp.

Constructor & Destructor Documentation

◆ SamplerStressGM()

skiagm::SamplerStressGM::SamplerStressGM ( )
inline

Definition at line 36 of file samplerstress.cpp.

37 : fTextureCreated(false)
38 , fMaskFilter(nullptr) {
39 }

Member Function Documentation

◆ createMaskFilter()

void skiagm::SamplerStressGM::createMaskFilter ( )
inlineprotected

Definition at line 87 of file samplerstress.cpp.

87 {
88 if (fMaskFilter) {
89 return;
90 }
91
92 const SkScalar sigma = 1;
93 fMaskFilter = SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma);
94 }
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition SkBlurTypes.h:12
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
float SkScalar
Definition extension.cpp:12

◆ createShader()

void skiagm::SamplerStressGM::createShader ( )
inlineprotected

Definition at line 76 of file samplerstress.cpp.

76 {
77 if (fShader) {
78 return;
79 }
80
82
85 }
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkBitmap.cpp:669

◆ createTexture()

void skiagm::SamplerStressGM::createTexture ( )
inlineprotected

Create a red & green stripes on black texture

Definition at line 49 of file samplerstress.cpp.

49 {
50 if (fTextureCreated) {
51 return;
52 }
53
54 constexpr int xSize = 16;
55 constexpr int ySize = 16;
56
57 fTexture.allocN32Pixels(xSize, ySize);
58 SkPMColor* addr = fTexture.getAddr32(0, 0);
59
60 for (int y = 0; y < ySize; ++y) {
61 for (int x = 0; x < xSize; ++x) {
63
64 if ((y % 5) == 0) {
66 }
67 if ((x % 7) == 0) {
69 }
70 }
71 }
72
73 fTextureCreated = true;
74 }
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
Definition SkColor.cpp:21
uint32_t SkPMColor
Definition SkColor.h:205
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition SkBitmap.cpp:232
uint32_t * getAddr32(int x, int y) const
Definition SkBitmap.h:1260
double y
double x

◆ getISize()

SkISize skiagm::SamplerStressGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 44 of file samplerstress.cpp.

44{ return SkISize::Make(640, 480); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 42 of file samplerstress.cpp.

42{ return SkString("gpusamplerstress"); }

◆ onDraw()

void skiagm::SamplerStressGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 96 of file samplerstress.cpp.

96 {
99
100 canvas->save();
101
102 // draw a letter "M" with a green & red striped texture and a
103 // stipple mask with a round rect soft clip
105 paint.setAntiAlias(true);
106 paint.setShader(fShader);
107 paint.setMaskFilter(fMaskFilter);
109
110 SkRect temp;
111 temp.setLTRB(115, 75, 144, 110);
112
113 SkPath path;
114 path.addRoundRect(temp, SkIntToScalar(5), SkIntToScalar(5));
115
116 canvas->clipPath(path, true); // AA is on
117
118 canvas->drawString("M", 100.0f, 100.0f, font, paint);
119
120 canvas->restore();
121
122 // Now draw stroked versions of the "M" and the round rect so we can
123 // see what is going on
124 SkPaint paint2;
125 paint2.setColor(SK_ColorBLACK);
126 paint2.setAntiAlias(true);
128 paint2.setStrokeWidth(1);
129 canvas->drawString("M", 100.0f, 100.0f, font, paint2);
130
131 paint2.setColor(SK_ColorGRAY);
132
133 canvas->drawPath(path, paint2);
134 }
constexpr SkColor SK_ColorGRAY
Definition SkColor.h:113
#define SkIntToScalar(x)
Definition SkScalar.h:57
void restore()
Definition SkCanvas.cpp:465
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
int save()
Definition SkCanvas.cpp:451
void drawPath(const SkPath &path, const SkPaint &paint)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition SkCanvas.h:1803
void setStyle(Style style)
Definition SkPaint.cpp:105
void setColor(SkColor color)
Definition SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition SkPaint.cpp:159
const Paint & paint
sk_sp< SkTypeface > DefaultPortableTypeface()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57
font
Font Metadata and Metrics.
void setLTRB(float left, float top, float right, float bottom)
Definition SkRect.h:865

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