Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Member Functions | List of all members
skiagm::AnisotropicGM Class Reference
Inheritance diagram for skiagm::AnisotropicGM:
skiagm::GM

Public Types

enum class  Mode { kLinear , kMip , kAniso }
 
- 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

 AnisotropicGM (Mode mode)
 
- 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
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () override
 
void draw (SkCanvas *canvas, int x, int y, int xSize, int ySize)
 
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
 

Additional Inherited Members

- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 26 of file anisotropic.cpp.

Member Enumeration Documentation

◆ Mode

enum class skiagm::AnisotropicGM::Mode
strong
Enumerator
kLinear 
kMip 
kAniso 

Definition at line 28 of file anisotropic.cpp.

28{ kLinear, kMip, kAniso };

Constructor & Destructor Documentation

◆ AnisotropicGM()

skiagm::AnisotropicGM::AnisotropicGM ( Mode  mode)
inline

Definition at line 30 of file anisotropic.cpp.

30 : fMode(mode) {
31 switch (fMode) {
32 case Mode::kLinear:
34 break;
35 case Mode::kMip:
37 break;
38 case Mode::kAniso:
39 fSampling = SkSamplingOptions::Aniso(16);
40 break;
41 }
42 this->setBGColor(0xFFCCCCCC);
43 }
void setBGColor(SkColor)
Definition: gm.cpp:159
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 mode
Definition: switches.h:228
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkSamplingOptions Aniso(int maxAniso)

Member Function Documentation

◆ draw()

void skiagm::AnisotropicGM::draw ( SkCanvas canvas,
int  x,
int  y,
int  xSize,
int  ySize 
)
inlineprotected

Definition at line 94 of file anisotropic.cpp.

94 {
96 SkIntToScalar(xSize), SkIntToScalar(ySize));
97 canvas->drawImageRect(fImage, r, fSampling);
98 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
double y
double x
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ getISize()

SkISize skiagm::AnisotropicGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 62 of file anisotropic.cpp.

62 {
63 return SkISize::Make(2*kImageSize + 3*kSpacer,
64 kNumVertImages*kImageSize + (kNumVertImages+1)*kSpacer);
65 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 46 of file anisotropic.cpp.

46 {
47 SkString name("anisotropic_image_scale_");
48 switch (fMode) {
49 case Mode::kLinear:
50 name += "linear";
51 break;
52 case Mode::kMip:
53 name += "mip";
54 break;
55 case Mode::kAniso:
56 name += "aniso";
57 break;
58 }
59 return name;
60 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 100 of file anisotropic.cpp.

100 {
101 SkScalar gScales[] = { 0.9f, 0.8f, 0.75f, 0.6f, 0.5f, 0.4f, 0.25f, 0.2f, 0.1f };
102
103 SkASSERT(kNumVertImages-1 == (int)std::size(gScales)/2);
104
105 // Minimize vertically
106 for (int i = 0; i < (int)std::size(gScales); ++i) {
107 int height = SkScalarFloorToInt(fImage->height() * gScales[i]);
108
109 int yOff;
110 if (i <= (int)std::size(gScales)/2) {
111 yOff = kSpacer + i * (fImage->height() + kSpacer);
112 } else {
113 // Position the more highly squashed images with their less squashed counterparts
114 yOff = (std::size(gScales) - i) * (fImage->height() + kSpacer) - height;
115 }
116
117 this->draw(canvas, kSpacer, yOff, fImage->width(), height);
118 }
119
120 // Minimize horizontally
121 for (int i = 0; i < (int)std::size(gScales); ++i) {
122 int width = SkScalarFloorToInt(fImage->width() * gScales[i]);
123
124 int xOff, yOff;
125 if (i <= (int)std::size(gScales)/2) {
126 xOff = fImage->width() + 2*kSpacer;
127 yOff = kSpacer + i * (fImage->height() + kSpacer);
128 } else {
129 // Position the more highly squashed images with their less squashed counterparts
130 xOff = fImage->width() + 2*kSpacer + fImage->width() - width;
131 yOff = kSpacer + (std::size(gScales) - i - 1) * (fImage->height() + kSpacer);
132 }
133
134 this->draw(canvas, xOff, yOff, width, fImage->height());
135 }
136 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkScalarFloorToInt(x)
Definition: SkScalar.h:35
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
void draw(SkCanvas *canvas, int x, int y, int xSize, int ySize)
Definition: anisotropic.cpp:94
SkScalar width()
Definition: gm.h:159
SkScalar height()
Definition: gm.h:162
float SkScalar
Definition: extension.cpp:12
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

◆ onOnceBeforeDraw()

void skiagm::AnisotropicGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 68 of file anisotropic.cpp.

68 {
69 constexpr int kNumLines = 100;
70 constexpr SkScalar kAngleStep = 360.0f / kNumLines;
71 constexpr int kInnerOffset = 10;
72
73 auto info = SkImageInfo::MakeN32(kImageSize, kImageSize, kOpaque_SkAlphaType);
74 auto surf = SkSurfaces::Raster(info);
75 auto canvas = surf->getCanvas();
76
77 canvas->clear(SK_ColorWHITE);
78
79 SkPaint p;
80 p.setAntiAlias(true);
81
82 SkScalar angle = 0.0f, sin, cos;
83
84 canvas->translate(kImageSize/2.0f, kImageSize/2.0f);
85 for (int i = 0; i < kNumLines; ++i, angle += kAngleStep) {
86 sin = SkScalarSin(angle);
87 cos = SkScalarCos(angle);
88 canvas->drawLine(cos * kInnerOffset, sin * kInnerOffset,
89 cos * kImageSize/2, sin * kImageSize/2, p);
90 }
91 fImage = surf->makeImageSnapshot();
92 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkScalarSin(radians)
Definition: SkScalar.h:45
#define SkScalarCos(radians)
Definition: SkScalar.h:46
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)

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