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

Public Member Functions

 ImageFilterMatrixWLocalMatrix ()
 
- 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
 
bool onAnimate (double nanos) 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 171 of file imagefilterstransformed.cpp.

Constructor & Destructor Documentation

◆ ImageFilterMatrixWLocalMatrix()

ImageFilterMatrixWLocalMatrix::ImageFilterMatrixWLocalMatrix ( )
inline

Definition at line 176 of file imagefilterstransformed.cpp.

176: fDegrees(132.f) {}

Member Function Documentation

◆ getISize()

SkISize ImageFilterMatrixWLocalMatrix::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 181 of file imagefilterstransformed.cpp.

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

◆ getName()

SkString ImageFilterMatrixWLocalMatrix::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 179 of file imagefilterstransformed.cpp.

179{ return SkString("imagefilter_matrix_localmatrix"); }

◆ onAnimate()

bool ImageFilterMatrixWLocalMatrix::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 183 of file imagefilterstransformed.cpp.

183 {
184 // Animate the rotation angle to ensure the local matrix bounds modifications work
185 // for a variety of transformations.
186 fDegrees = TimeUtils::Scaled(1e-9f * nanos, 360.f);
187 return true;
188 }
static float Scaled(float time, float speed, float period=0)
Definition: TimeUtils.h:27

◆ onDraw()

void ImageFilterMatrixWLocalMatrix::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 194 of file imagefilterstransformed.cpp.

194 {
195 SkMatrix localMatrix;
196 localMatrix.preTranslate(128, 128);
197 localMatrix.preScale(2.0f, 2.0f);
198
199 // This matrix applies a rotate around the center of the image (prior to the simulated
200 // hi-dpi 2x device scale).
201 SkMatrix filterMatrix;
202 filterMatrix.setRotate(fDegrees, 64, 64);
203
204 sk_sp<SkImageFilter> filter =
207 ->makeWithLocalMatrix(localMatrix);
208
209 SkPaint p;
210 p.setImageFilter(filter);
211 canvas->drawImage(fImage.get(), 128, 128, SkSamplingOptions(), &p);
212 }
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
sk_sp< SkImageFilter > makeWithLocalMatrix(const SkMatrix &matrix) const
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:452
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:263
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:315
T * get() const
Definition: SkRefCnt.h:303
SkSamplingOptions(SkFilterMode::kLinear))

◆ onOnceBeforeDraw()

void ImageFilterMatrixWLocalMatrix::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 190 of file imagefilterstransformed.cpp.

190 {
191 fImage = ToolUtils::GetResourceAsImage("images/mandrill_256.png");
192 }
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25

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