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

Public Member Functions

 NinePatchStretchGM ()
 
- 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
 

Public Attributes

sk_sp< SkImagefImage
 
SkIRect fCenter
 

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 56 of file ninepatchstretch.cpp.

Constructor & Destructor Documentation

◆ NinePatchStretchGM()

NinePatchStretchGM::NinePatchStretchGM ( )
inline

Definition at line 61 of file ninepatchstretch.cpp.

61{}

Member Function Documentation

◆ getISize()

SkISize NinePatchStretchGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 66 of file ninepatchstretch.cpp.

66{ return SkISize::Make(760, 800); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString NinePatchStretchGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 64 of file ninepatchstretch.cpp.

64{ return SkString("ninepatch-stretch"); }

◆ onDraw()

void NinePatchStretchGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 68 of file ninepatchstretch.cpp.

68 {
69 if (!fImage || !fImage->isValid(canvas->recordingContext())) {
70 fImage = make_image(canvas, &fCenter);
71 }
72
73 // amount of bm that should not be stretched (unless we have to)
74 const SkScalar fixed = SkIntToScalar(fImage->width() - fCenter.width());
75
76 const SkSize size[] = {
77 { fixed * 4 / 5, fixed * 4 / 5 }, // shrink in both axes
78 { fixed * 4 / 5, fixed * 4 }, // shrink in X
79 { fixed * 4, fixed * 4 / 5 }, // shrink in Y
80 { fixed * 4, fixed * 4 }
81 };
82
83 canvas->drawImage(fImage, 10, 10);
84
87
90 for (int iy = 0; iy < 2; ++iy) {
91 for (int ix = 0; ix < 2; ++ix) {
92 int i = ix * 2 + iy;
93 SkRect r = SkRect::MakeXYWH(x + ix * fixed, y + iy * fixed,
94 size[i].width(), size[i].height());
95 canvas->drawImageNine(fImage.get(), fCenter, r, fm);
96 }
97 }
98 canvas->translate(0, 400);
99 }
100 }
#define SkIntToScalar(x)
Definition SkScalar.h:57
sk_sp< SkImage > fImage
void translate(SkScalar dx, SkScalar dy)
void drawImageNine(const SkImage *image, const SkIRect &center, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr)
virtual GrRecordingContext * recordingContext() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
int width() const
Definition SkImage.h:285
virtual bool isValid(GrRecordingContext *context) const =0
T * get() const
Definition SkRefCnt.h:303
SkScalar width()
Definition gm.h:159
SkScalar height()
Definition gm.h:162
const Paint & paint
float SkScalar
Definition extension.cpp:12
static sk_sp< SkImage > make_image()
Definition mipmap.cpp:21
double y
double x
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
constexpr int32_t width() const
Definition SkRect.h:158
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

Member Data Documentation

◆ fCenter

SkIRect NinePatchStretchGM::fCenter

Definition at line 59 of file ninepatchstretch.cpp.

◆ fImage

sk_sp<SkImage> NinePatchStretchGM::fImage

Definition at line 58 of file ninepatchstretch.cpp.


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