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

Public Member Functions

 DrawMiniBitmapRectGM (bool antiAlias)
 
- 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 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 79 of file drawminibitmaprect.cpp.

Constructor & Destructor Documentation

◆ DrawMiniBitmapRectGM()

DrawMiniBitmapRectGM::DrawMiniBitmapRectGM ( bool  antiAlias)
inline

Definition at line 81 of file drawminibitmaprect.cpp.

81 : fAA(antiAlias) {
82 fName.set("drawminibitmaprect");
83 if (fAA) {
84 fName.appendf("_aa");
85 }
86 }
void set(const SkString &src)
Definition: SkString.h:186
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550

Member Function Documentation

◆ getISize()

SkISize DrawMiniBitmapRectGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 91 of file drawminibitmaprect.cpp.

91{ return SkISize::Make(gSize, gSize); }
constexpr int gSize
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString DrawMiniBitmapRectGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 89 of file drawminibitmaprect.cpp.

89{ return fName; }

◆ onDraw()

void DrawMiniBitmapRectGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 93 of file drawminibitmaprect.cpp.

93 {
94 if (nullptr == fImage) {
96 }
97
98 const SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)};
99 const int kMaxSrcRectSize = 1 << (SkNextLog2(gSurfaceSize) + 2);
100
101 constexpr int kPadX = 30;
102 constexpr int kPadY = 40;
103
104 int rowCount = 0;
105 canvas->translate(SkIntToScalar(kPadX), SkIntToScalar(kPadY));
106 canvas->save();
107 SkRandom random;
108
110 paint.setAntiAlias(fAA);
111 for (int w = 1; w <= kMaxSrcRectSize; w *= 3) {
112 for (int h = 1; h <= kMaxSrcRectSize; h *= 3) {
113
114 const SkIRect srcRect =
115 SkIRect::MakeXYWH((gSurfaceSize - w) / 2, (gSurfaceSize - h) / 2, w, h);
116 canvas->save();
117 switch (random.nextU() % 3) {
118 case 0:
119 canvas->rotate(random.nextF() * 10.f);
120 break;
121 case 1:
122 canvas->rotate(-random.nextF() * 10.f);
123 break;
124 case 2:
125 // rect stays rect
126 break;
127 }
128 canvas->drawImageRect(fImage.get(), SkRect::Make(srcRect), dstRect,
131 canvas->restore();
132
133 canvas->translate(dstRect.width() + SK_Scalar1 * kPadX, 0);
134 ++rowCount;
135 if ((dstRect.width() + 2 * kPadX) * rowCount > gSize) {
136 canvas->restore();
137 canvas->translate(0, dstRect.height() + SK_Scalar1 * kPadY);
138 canvas->save();
139 rowCount = 0;
140 }
141 }
142 }
143 canvas->restore();
144 }
static int SkNextLog2(uint32_t value)
Definition: SkMathPriv.h:238
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543
void rotate(SkScalar degrees)
Definition: SkCanvas.cpp:1300
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
uint32_t nextU()
Definition: SkRandom.h:42
float nextF()
Definition: SkRandom.h:55
T * get() const
Definition: SkRefCnt.h:303
const Paint & paint
Definition: color_source.cc:38
constexpr int gSurfaceSize
static sk_sp< SkImage > makebm(int w, int h)
sk_sp< SkImage > MakeTextureImage(SkCanvas *canvas, sk_sp< SkImage > orig)
SkScalar w
SkScalar h
Definition: SkRect.h:32
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762

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