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

Public Member Functions

 ImageFiltersScaledGM ()
 
- 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 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

- 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 57 of file imagefiltersscaled.cpp.

Constructor & Destructor Documentation

◆ ImageFiltersScaledGM()

skiagm::ImageFiltersScaledGM::ImageFiltersScaledGM ( )
inline

Definition at line 59 of file imagefiltersscaled.cpp.

59 {
60 this->setBGColor(0x00000000);
61 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize skiagm::ImageFiltersScaledGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 66 of file imagefiltersscaled.cpp.

66{ return SkISize::Make(1428, 500); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 64 of file imagefiltersscaled.cpp.

64{ return SkString("imagefiltersscaled"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 73 of file imagefiltersscaled.cpp.

73 {
74 canvas->clear(SK_ColorBLACK);
75
76 sk_sp<SkImageFilter> gradient(SkImageFilters::Image(fGradientCircle,
80
81 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10));
82 SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10),
83 SkIntToScalar(-10),
84 SkIntToScalar(20));
85 SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40), 0);
86 SkScalar spotExponent = SK_Scalar1;
87 SkScalar cutoffAngle = SkIntToScalar(15);
88 SkScalar kd = SkIntToScalar(2);
89 SkScalar surfaceScale = SkIntToScalar(1);
90 SkColor white(0xFFFFFFFF);
91 SkMatrix resizeMatrix;
93
94 sk_sp<SkImageFilter> filters[] = {
96 SkImageFilters::DropShadow(5, 10, 3, 3, SK_ColorYELLOW, nullptr),
99 12,
100 std::move(gradient),
104 SkImageFilters::Offset(SkIntToScalar(32), 0, nullptr),
105 SkImageFilters::MatrixTransform(resizeMatrix, SkSamplingOptions(), nullptr),
107 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)),
108 SkImageFilters::PointLitDiffuse(pointLocation, white, surfaceScale, kd, nullptr),
110 spotTarget,
111 spotExponent,
112 cutoffAngle,
113 white,
114 surfaceScale,
115 kd,
116 nullptr),
117 };
118
119 SkVector scales[] = {
125 };
126
128 SkScalar margin = SkIntToScalar(16);
129 SkRect bounds = r;
130 bounds.outset(margin, margin);
131
132 for (size_t j = 0; j < std::size(scales); ++j) {
133 canvas->save();
134 for (size_t i = 0; i < std::size(filters); ++i) {
136 paint.setColor(SK_ColorBLUE);
137 paint.setImageFilter(filters[i]);
138 paint.setAntiAlias(true);
139 canvas->save();
140 canvas->scale(scales[j].fX, scales[j].fY);
141 canvas->clipRect(r);
142 if (5 == i) {
143 canvas->translate(SkIntToScalar(-32), 0);
144 } else if (6 == i) {
147 }
148 canvas->drawCircle(r.centerX(), r.centerY(), r.width()*2/5, paint);
149 canvas->restore();
150 canvas->translate(r.width() * scales[j].fX + margin, 0);
151 }
152 canvas->restore();
153 canvas->translate(0, r.height() * scales[j].fY + margin);
154 }
155 }
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
#define SkScalarInvert(x)
Definition: SkScalar.h:73
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkDoubleToScalar(x)
Definition: SkScalar.h:64
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
static sk_sp< SkImageFilter > PointLitDiffuse(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DropShadow(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DisplacementMap(SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale, sk_sp< SkImageFilter > displacement, sk_sp< SkImageFilter > color, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Shader(sk_sp< SkShader > shader, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > SpotLitDiffuse(const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:296
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
#define RESIZE_FACTOR
Optional< SkRect > bounds
Definition: SkRecords.h:189
SK_API sk_sp< SkShader > MakeFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize *tileSize=nullptr)
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
SkSamplingOptions(SkFilterMode::kLinear))
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
Definition: SkPoint3.h:18
float fX
x-axis value
Definition: SkPoint_impl.h:164
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
float fY
y-axis value
Definition: SkPoint_impl.h:165
constexpr float centerX() const
Definition: SkRect.h:776
constexpr float height() const
Definition: SkRect.h:769
constexpr float centerY() const
Definition: SkRect.h:785
constexpr float width() const
Definition: SkRect.h:762
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static void checkerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)

◆ onOnceBeforeDraw()

void skiagm::ImageFiltersScaledGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 68 of file imagefiltersscaled.cpp.

68 {
69 fCheckerboard = ToolUtils::create_checkerboard_image(64, 64, 0xFFA0A0A0, 0xFF404040, 8);
70 fGradientCircle = make_gradient_circle(64, 64);
71 }
sk_sp< SkImage > create_checkerboard_image(int w, int h, SkColor c1, SkColor c2, int checkSize)
Definition: ToolUtils.cpp:168
static sk_sp< SkImage > make_gradient_circle(int width, int height)

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