Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Attributes | 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 SkISize getISize ()=0
 
virtual SkString getName () const =0
 
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 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 void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Static Protected Attributes

static constexpr int kPOTSize = 4
 
static constexpr int kNPOTSize = 3
 

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.

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

84{ 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 76 of file tilemodes_scaled.cpp.

76 {
77 SkString name("scaled_tilemodes");
78 if (!fPowerOfTwoSize) {
79 name.append("_npot");
80 }
81 return name;
82 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ onDraw()

void ScaledTilingGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 93 of file tilemodes_scaled.cpp.

93 {
94 SkPaint textPaint;
96
97 float scale = 32.f/kPOTSize;
98
99 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
100
101 SkRect r = { 0, 0, SkIntToScalar(size*2), SkIntToScalar(size*2) };
102
103 const char* gColorTypeNames[] = { "8888", "565" };
104
105 const char* gFilterNames[] = { "Nearest", "Linear", "Trilinear", "Mitchell", "Aniso" };
106
107 constexpr SkTileMode gModes[] = {
109 const char* gModeNames[] = { "C", "R", "M" };
110
113
114 for (size_t kx = 0; kx < std::size(gModes); kx++) {
115 for (size_t ky = 0; ky < std::size(gModes); ky++) {
116 SkString str;
117 str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]);
118
119 SkTextUtils::DrawString(canvas, str.c_str(), scale*(x + r.width()/2), y, font, SkPaint(),
121
122 x += r.width() * 4 / 3;
123 }
124 }
125
126 y = SkIntToScalar(40) / scale;
127
128 for (size_t i = 0; i < std::size(gColorTypes); i++) {
129 for (size_t j = 0; j < std::size(gSamplings); j++) {
130 x = SkIntToScalar(10)/scale;
131 for (size_t kx = 0; kx < std::size(gModes); kx++) {
132 for (size_t ky = 0; ky < std::size(gModes); ky++) {
134#if 1 // Temporary change to regen bitmap before each draw. This may help tracking down an issue
135 // on SGX where resizing NPOT textures to POT textures exhibits a driver bug.
136 if (!fPowerOfTwoSize) {
138 }
139#endif
140 setup(&paint, fTexture[i], gSamplings[j], gModes[kx], gModes[ky]);
141 paint.setDither(true);
142
143 canvas->save();
144 canvas->scale(scale,scale);
145 canvas->translate(x, y);
146 canvas->drawRect(r, paint);
147 canvas->restore();
148
149 x += r.width() * 4 / 3;
150 }
151 }
152 canvas->drawString(SkStringPrintf("%s, %s", gColorTypeNames[i], gFilterNames[j]),
153 scale * x, scale * (y + r.height() * 2 / 3), font, textPaint);
154
155 y += r.height() * 4 / 3;
156 }
157 }
158 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
SkTileMode
Definition: SkTileMode.h:13
constexpr SkBlendMode gModes[]
Definition: aarectmodes.cpp:73
static constexpr int kPOTSize
SkBitmap fTexture[std::size(gColorTypes)]
static constexpr int kNPOTSize
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
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
Definition: color_source.cc:38
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.
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[]
static void setup(SkPaint *paint, const SkBitmap &bm, const SkSamplingOptions &sampling, SkTileMode tmx, SkTileMode tmy)
const SkSamplingOptions gSamplings[]

◆ onOnceBeforeDraw()

void ScaledTilingGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 86 of file tilemodes_scaled.cpp.

86 {
87 int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
88 for (size_t i = 0; i < std::size(gColorTypes); i++) {
90 }
91 }

Member Data Documentation

◆ fTexture

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

Definition at line 70 of file tilemodes_scaled.cpp.

◆ kNPOTSize

constexpr int ScaledTilingGM::kNPOTSize = 3
staticconstexprprotected

Definition at line 74 of file tilemodes_scaled.cpp.

◆ kPOTSize

constexpr int ScaledTilingGM::kPOTSize = 4
staticconstexprprotected

Definition at line 73 of file tilemodes_scaled.cpp.


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