Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
DrawAtlasGM Class Reference
Inheritance diagram for DrawAtlasGM:
skiagm::GM

Public Member Functions

 DrawAtlasGM ()
 
- 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 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 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 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 49 of file drawatlas.cpp.

Constructor & Destructor Documentation

◆ DrawAtlasGM()

DrawAtlasGM::DrawAtlasGM ( )
inline

Definition at line 72 of file drawatlas.cpp.

72{}

Member Function Documentation

◆ getISize()

SkISize DrawAtlasGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 77 of file drawatlas.cpp.

77{ return SkISize::Make(640, 480); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString DrawAtlasGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 75 of file drawatlas.cpp.

75{ return SkString("draw-atlas"); }

◆ onDraw()

void DrawAtlasGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 79 of file drawatlas.cpp.

79 {
80 const SkRect target = { 50, 50, 80, 90 };
81 auto atlas = MakeAtlas(canvas, target);
82
83 const struct {
84 SkScalar fScale;
85 SkScalar fDegrees;
86 SkScalar fTx;
87 SkScalar fTy;
88
89 void apply(SkRSXform* xform) const {
90 const SkScalar rad = SkDegreesToRadians(fDegrees);
91 xform->fSCos = fScale * SkScalarCos(rad);
92 xform->fSSin = fScale * SkScalarSin(rad);
93 xform->fTx = fTx;
94 xform->fTy = fTy;
95 }
96 } rec[] = {
97 { 1, 0, 10, 10 }, // just translate
98 { 2, 0, 110, 10 }, // scale + translate
99 { 1, 30, 210, 10 }, // rotate + translate
100 { 2, -30, 310, 30 }, // scale + rotate + translate
101 };
102
103 const int N = std::size(rec);
104 SkRSXform xform[N];
105 SkRect tex[N];
107
108 for (int i = 0; i < N; ++i) {
109 rec[i].apply(&xform[i]);
110 tex[i] = target;
111 colors[i] = 0x80FF0000 + (i * 40 * 256);
112 }
113
115 paint.setAntiAlias(true);
117
118 canvas->drawAtlas(atlas.get(), xform, tex, nullptr, N, SkBlendMode::kDst,
119 sampling, nullptr, &paint);
120 canvas->translate(0, 100);
121 canvas->drawAtlas(atlas.get(), xform, tex, colors, N, SkBlendMode::kSrcIn,
122 sampling, nullptr, &paint);
123 }
@ kSrcIn
r = s * da
uint32_t SkColor
Definition SkColor.h:37
static bool apply(Pass *pass, SkRecord *record)
#define SkDegreesToRadians(degrees)
Definition SkScalar.h:77
#define SkScalarSin(radians)
Definition SkScalar.h:45
#define SkScalarCos(radians)
Definition SkScalar.h:46
#define N
Definition beziers.cpp:19
void translate(SkScalar dx, SkScalar dy)
void drawAtlas(const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint)
T * get() const
Definition SkRefCnt.h:303
const Paint & paint
float SkScalar
Definition extension.cpp:12
uint32_t * target
sk_sp< const SkImage > atlas
Definition SkRecords.h:331
PODArray< SkColor > colors
Definition SkRecords.h:276
SkSamplingOptions sampling
Definition SkRecords.h:337
SkScalar fTy
Definition SkRSXform.h:45
SkScalar fSCos
Definition SkRSXform.h:42
SkScalar fTx
Definition SkRSXform.h:44
SkScalar fSSin
Definition SkRSXform.h:43

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