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

Public Member Functions

 TilingGM (bool powerOfTwoSize)
 
- 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
 

Public Attributes

SkBitmap fTexture [std::size(gColorTypes)]
 

Protected Types

enum  { kPOTSize = 32 , kNPOTSize = 21 }
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () override
 
void onDraw (SkCanvas *canvas) 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

Definition at line 67 of file tilemodes.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
kPOTSize 
kNPOTSize 

Definition at line 77 of file tilemodes.cpp.

77 {
78 kPOTSize = 32,
79 kNPOTSize = 21,
80 };

Constructor & Destructor Documentation

◆ TilingGM()

TilingGM::TilingGM ( bool  powerOfTwoSize)
inline

Definition at line 69 of file tilemodes.cpp.

70 : fPowerOfTwoSize(powerOfTwoSize) {
71 }

Member Function Documentation

◆ getISize()

SkISize TilingGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 90 of file tilemodes.cpp.

90{ return SkISize::Make(880, 560); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString TilingGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 82 of file tilemodes.cpp.

82 {
83 SkString name("tilemodes");
84 if (!fPowerOfTwoSize) {
85 name.append("_npot");
86 }
87 return name;
88 }
const char * name
Definition fuchsia.cc:50

◆ onDraw()

void TilingGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 99 of file tilemodes.cpp.

99 {
100 SkPaint textPaint;
102
103 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
104
105 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
106
107 const char* gConfigNames[] = { "8888", "565" };
108
110 static const char* gFilterNames[] = { "point", "bilinear" };
111
112 constexpr SkTileMode gModes[] = {
114 static const char* gModeNames[] = { "C", "R", "M" };
115
118
119 for (size_t kx = 0; kx < std::size(gModes); kx++) {
120 for (size_t ky = 0; ky < std::size(gModes); ky++) {
121 SkPaint p;
122 p.setDither(true);
123 SkString str;
124 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
125
126 SkTextUtils::DrawString(canvas, str.c_str(), x + r.width()/2, y, font, p,
128
129 x += r.width() * 4 / 3;
130 }
131 }
132
133 y += SkIntToScalar(16);
134
135 for (size_t i = 0; i < std::size(gColorTypes); i++) {
136 for (size_t j = 0; j < std::size(gFilters); j++) {
137 x = SkIntToScalar(10);
138 for (size_t kx = 0; kx < std::size(gModes); kx++) {
139 for (size_t ky = 0; ky < std::size(gModes); ky++) {
141#if 1 // Temporary change to regen bitmap before each draw. This may help tracking down an issue
142 // on SGX where resizing NPOT textures to POT textures exhibits a driver bug.
143 if (!fPowerOfTwoSize) {
144 makebm(&fTexture[i], gColorTypes[i], size, size);
145 }
146#endif
147 setup(canvas, &paint, fTexture[i], gFilters[j], gModes[kx], gModes[ky]);
148 paint.setDither(true);
149
150 canvas->save();
151 canvas->translate(x, y);
152 canvas->drawRect(r, paint);
153 canvas->restore();
154
155 x += r.width() * 4 / 3;
156 }
157 }
158 canvas->drawString(SkStringPrintf("%s, %s", gConfigNames[i], gFilterNames[j]),
159 x, y + r.height() * 2 / 3, font, textPaint);
160
161 y += r.height() * 4 / 3;
162 }
163 }
164 }
SkFilterMode
#define SkIntToScalar(x)
Definition SkScalar.h:57
SK_API SkString static SkString SkStringPrintf()
Definition SkString.h:287
SkTileMode
Definition SkTileMode.h:13
constexpr SkBlendMode gModes[]
void drawRect(const SkRect &rect, const SkPaint &paint)
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition SkCanvas.h:1803
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
const char * c_str() const
Definition SkString.h:133
static void DrawString(SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
Definition SkTextUtils.h:34
SkBitmap fTexture[std::size(gColorTypes)]
Definition tilemodes.cpp:73
const Paint & paint
float SkScalar
Definition extension.cpp:12
double y
double x
SkFont DefaultPortableFont()
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
font
Font Metadata and Metrics.
Definition setup.py:1
constexpr float height() const
Definition SkRect.h:769
constexpr float width() const
Definition SkRect.h:762
static void makebm(SkBitmap *bm, SkColorType ct, int w, int h)
Definition tilemodes.cpp:36
constexpr SkColorType gColorTypes[]
Definition tilemodes.cpp:62

◆ onOnceBeforeDraw()

void TilingGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 92 of file tilemodes.cpp.

92 {
93 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
94 for (size_t i = 0; i < std::size(gColorTypes); i++) {
95 makebm(&fTexture[i], gColorTypes[i], size, size);
96 }
97 }

Member Data Documentation

◆ fTexture

SkBitmap TilingGM::fTexture[std::size(gColorTypes)]

Definition at line 73 of file tilemodes.cpp.


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