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

Public Member Functions

 PerspImages ()=default
 
- 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 39 of file perspimages.cpp.

Constructor & Destructor Documentation

◆ PerspImages()

skiagm::PerspImages::PerspImages ( )
default

Member Function Documentation

◆ getISize()

SkISize skiagm::PerspImages::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 46 of file perspimages.cpp.

46{ return SkISize::Make(1150, 1280); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 44 of file perspimages.cpp.

44{ return SkString("persp_images"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 53 of file perspimages.cpp.

53 {
54 SkTDArray<SkMatrix> matrices;
55 matrices.append()->setAll(1.f, 0.f, 0.f,
56 0.f, 1.f, 0.f,
57 0.f, 0.005f, 1.f);
58 matrices.append()->setAll(1.f, 0.f, 0.f,
59 0.f, 1.f, 0.f,
60 0.007f, -0.005f, 1.f);
61 matrices[1].preSkew(0.2f, -0.1f);
62 matrices[1].preRotate(-65.f);
63 matrices[1].preScale(1.2f, .8f);
64 matrices[1].postTranslate(0.f, 60.f);
66 int n = 0;
68 for (const auto& img : fImages) {
69 SkRect imgB = SkRect::MakeWH(img->width(), img->height());
70 for (const auto& m : matrices) {
71 SkRect temp;
72 m.mapRect(&temp, imgB);
73 bounds.join(temp);
74 }
75 }
76 canvas->translate(-bounds.fLeft + 10.f, -bounds.fTop + 10.f);
77 canvas->save();
78 enum class DrawType {
80 kDrawImageRectStrict,
81 kDrawImageRectFast,
82 };
83 for (auto type :
84 {DrawType::kDrawImage, DrawType::kDrawImageRectStrict, DrawType::kDrawImageRectFast}) {
85 for (const auto& m : matrices) {
86 for (auto aa : {false, true}) {
87 paint.setAntiAlias(aa);
88 for (auto sampling : {
93 for (const auto& origImage : fImages) {
94 sk_sp<SkImage> img = ToolUtils::MakeTextureImage(canvas, origImage);
95 if (img) {
96 canvas->save();
97 canvas->concat(m);
98 SkRect src = { img->width() / 4.f, img->height() / 4.f,
99 3.f * img->width() / 4.f, 3.f * img->height() / 4 };
100 SkRect dst = { 0, 0,
101 3.f / 4.f * img->width(), 3.f / 4.f * img->height()};
102 switch (type) {
103 case DrawType::kDrawImage:
104 canvas->drawImage(img, 0, 0, sampling, &paint);
105 break;
106 case DrawType::kDrawImageRectStrict:
107 canvas->drawImageRect(img, src, dst, sampling, &paint,
109 break;
110 case DrawType::kDrawImageRectFast:
111 canvas->drawImageRect(img, src, dst, sampling, &paint,
113 break;
114 }
115 canvas->restore();
116 }
117 ++n;
118 if (n < 8) {
119 canvas->translate(bounds.width() + 10.f, 0);
120 } else {
121 canvas->restore();
122 canvas->translate(0, bounds.height() + 10.f);
123 canvas->save();
124 n = 0;
125 }
126 }
127 }
128 }
129 }
130 }
131 canvas->restore();
132 }
GLenum type
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1542
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
int save()
Definition: SkCanvas.cpp:447
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
T * append()
Definition: SkTDArray.h:191
const Paint & paint
Definition: color_source.cc:38
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkSamplingOptions sampling
Definition: SkRecords.h:337
sk_sp< SkImage > MakeTextureImage(SkCanvas *canvas, sk_sp< SkImage > orig)
dst
Definition: cp.py:12
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkCubicResampler Mitchell()
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onOnceBeforeDraw()

void skiagm::PerspImages::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 48 of file perspimages.cpp.

48 {
49 fImages.push_back(make_image1());
50 fImages.push_back(make_image2());
51 }
static sk_sp< SkImage > make_image2()
Definition: perspimages.cpp:32
static sk_sp< SkImage > make_image1()
Definition: perspimages.cpp:28

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