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

Public Member Functions

 LocalMatrixOrder ()
 
- 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
 
bool onAnimate (double nanos) 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
 

Protected Attributes

sk_sp< SkShaderfShader
 
float fAngle = 0.f
 

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 222 of file localmatrixshader.cpp.

Constructor & Destructor Documentation

◆ LocalMatrixOrder()

skiagm::LocalMatrixOrder::LocalMatrixOrder ( )
inline

Definition at line 224 of file localmatrixshader.cpp.

224{}

Member Function Documentation

◆ getISize()

SkISize skiagm::LocalMatrixOrder::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 229 of file localmatrixshader.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 227 of file localmatrixshader.cpp.

227{ return SkString("localmatrix_order"); }

◆ onAnimate()

bool skiagm::LocalMatrixOrder::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 269 of file localmatrixshader.cpp.

269 {
270 fAngle = TimeUtils::NanosToSeconds(nanos) * 5.f;
271 return true;
272 }
static double NanosToSeconds(double nanos)
Definition: TimeUtils.h:22

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 252 of file localmatrixshader.cpp.

252 {
253 // Rotate fShader about the canvas center
254 auto center = SkRect::Make(canvas->imageInfo().bounds()).center();
255
256 // viewer can insert a dpi scaling matrix. Make the animation always rotate about the device
257 // center.
258 if (auto ictm = canvas->getTotalMatrix(); ictm.invert(&ictm)) {
259 center = ictm.mapPoint(center);
260 }
261
262 auto shader = fShader->makeWithLocalMatrix(SkMatrix::RotateDeg(fAngle, center));
263
265 paint.setShader(shader);
266 canvas->drawPaint(paint);
267 }
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
SkMatrix getTotalMatrix() const
Definition: SkCanvas.cpp:1629
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
static SkMatrix RotateDeg(SkScalar deg)
Definition: SkMatrix.h:104
bool invert(SkMatrix *inverse) const
Definition: SkMatrix.h:1206
sk_sp< SkShader > makeWithLocalMatrix(const SkMatrix &) const
Definition: SkShader.cpp:26
const Paint & paint
Definition: color_source.cc:38
SkIRect bounds() const
Definition: SkImageInfo.h:427
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
constexpr SkPoint center() const
Definition: SkRect.h:792

◆ onOnceBeforeDraw()

void skiagm::LocalMatrixOrder::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 231 of file localmatrixshader.cpp.

231 {
232 auto mandrill = ToolUtils::GetResourceAsImage("images/mandrill_256.png"); // 256x256
233 auto example5 = ToolUtils::GetResourceAsImage("images/example_5.png"); // 128x128
234
235 auto mshader = mandrill->makeShader(
239 SkMatrix::RotateDeg(45, {128, 128})); // rotate about center
240 auto eshader = example5->makeShader(
244 SkMatrix::Scale(2, 2)); // make same size as mandrill and...
245 // ... rotate about center
246 eshader = eshader->makeWithLocalMatrix(SkMatrix::RotateDeg(45, {128, 128}));
247
248 // blend the two rotated and aligned images.
250 }
@ kModulate
r = s*d
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25

Member Data Documentation

◆ fAngle

float skiagm::LocalMatrixOrder::fAngle = 0.f
protected

Definition at line 275 of file localmatrixshader.cpp.

◆ fShader

sk_sp<SkShader> skiagm::LocalMatrixOrder::fShader
protected

Definition at line 274 of file localmatrixshader.cpp.


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