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

Public Member Functions

 ScaledTilingGM (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 = 4 , kNPOTSize = 3 }
 

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 64 of file tilemodes_scaled.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
kPOTSize 
kNPOTSize 

Definition at line 73 of file tilemodes_scaled.cpp.

73 {
74 kPOTSize = 4,
75 kNPOTSize = 3,
76 };

Constructor & Destructor Documentation

◆ ScaledTilingGM()

ScaledTilingGM::ScaledTilingGM ( bool  powerOfTwoSize)
inline

Definition at line 66 of file tilemodes_scaled.cpp.

67 : fPowerOfTwoSize(powerOfTwoSize) {
68 }

Member Function Documentation

◆ getISize()

SkISize ScaledTilingGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 86 of file tilemodes_scaled.cpp.

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

◆ getName()

SkString ScaledTilingGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 78 of file tilemodes_scaled.cpp.

78 {
79 SkString name("scaled_tilemodes");
80 if (!fPowerOfTwoSize) {
81 name.append("_npot");
82 }
83 return name;
84 }
const char * name
Definition fuchsia.cc:50

◆ onDraw()

void ScaledTilingGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 95 of file tilemodes_scaled.cpp.

95 {
96 SkPaint textPaint;
98
99 float scale = 32.f/kPOTSize;
100
101 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
102
103 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
104
105 const char* gColorTypeNames[] = { "8888", "565" };
106
107 const char* gFilterNames[] = { "Nearest", "Linear", "Trilinear", "Mitchell", "Aniso" };
108
109 constexpr SkTileMode gModes[] = {
111 const char* gModeNames[] = { "C", "R", "M" };
112
115
116 for (size_t kx = 0; kx < std::size(gModes); kx++) {
117 for (size_t ky = 0; ky < std::size(gModes); ky++) {
118 SkString str;
119 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
120
121 SkTextUtils::DrawString(canvas, str.c_str(), scale*(x + r.width()/2), y, font, SkPaint(),
123
124 x += r.width() * 4 / 3;
125 }
126 }
127
128 y = SkIntToScalar(40) / scale;
129
130 for (size_t i = 0; i < std::size(gColorTypes); i++) {
131 for (size_t j = 0; j < std::size(gSamplings); j++) {
132 x = SkIntToScalar(10)/scale;
133 for (size_t kx = 0; kx < std::size(gModes); kx++) {
134 for (size_t ky = 0; ky < std::size(gModes); ky++) {
136#if 1 // Temporary change to regen bitmap before each draw. This may help tracking down an issue
137 // on SGX where resizing NPOT textures to POT textures exhibits a driver bug.
138 if (!fPowerOfTwoSize) {
139 makebm(&fTexture[i], gColorTypes[i], size, size);
140 }
141#endif
142 setup(&paint, fTexture[i], gSamplings[j], gModes[kx], gModes[ky]);
143 paint.setDither(true);
144
145 canvas->save();
146 canvas->scale(scale,scale);
147 canvas->translate(x, y);
148 canvas->drawRect(r, paint);
149 canvas->restore();
150
151 x += r.width() * 4 / 3;
152 }
153 }
154 canvas->drawString(SkStringPrintf("%s, %s", gColorTypeNames[i], gFilterNames[j]),
155 scale * x, scale * (y + r.height() * 2 / 3), font, textPaint);
156
157 y += r.height() * 4 / 3;
158 }
159 }
160 }
#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[]
SkBitmap fTexture[std::size(gColorTypes)]
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 scale(SkScalar sx, SkScalar sy)
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
const Paint & paint
float SkScalar
Definition extension.cpp:12
double y
double x
sk_sp< SkTypeface > DefaultPortableTypeface()
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
const Scalar scale
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)
constexpr SkColorType gColorTypes[]
const SkSamplingOptions gSamplings[]

◆ onOnceBeforeDraw()

void ScaledTilingGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 88 of file tilemodes_scaled.cpp.

88 {
89 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
90 for (size_t i = 0; i < std::size(gColorTypes); i++) {
91 makebm(&fTexture[i], gColorTypes[i], size, size);
92 }
93 }

Member Data Documentation

◆ fTexture

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

Definition at line 70 of file tilemodes_scaled.cpp.


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