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

Public Member Functions

 ImageSourceGM (const char *suffix, const SkSamplingOptions &sampling)
 
- 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 27 of file imagesource2.cpp.

Constructor & Destructor Documentation

◆ ImageSourceGM()

skiagm::ImageSourceGM::ImageSourceGM ( const char *  suffix,
const SkSamplingOptions sampling 
)
inline

Definition at line 29 of file imagesource2.cpp.

30 : fSuffix(suffix), fSampling(sampling) {
31 this->setBGColor(0xFFFFFFFF);
32 }
void setBGColor(SkColor)
Definition: gm.cpp:159
SkSamplingOptions sampling
Definition: SkRecords.h:337

Member Function Documentation

◆ getISize()

SkISize skiagm::ImageSourceGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 41 of file imagesource2.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 35 of file imagesource2.cpp.

35 {
36 SkString name("imagesrc2_");
37 name.append(fSuffix);
38 return name;
39 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 73 of file imagesource2.cpp.

73 {
74 const SkRect srcRect = SkRect::MakeLTRB(0, 0,
75 SkIntToScalar(kImageSize),
76 SkIntToScalar(kImageSize));
77 const SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f);
78
79 SkPaint p;
80 p.setImageFilter(SkImageFilters::Image(fImage, srcRect, dstRect, fSampling));
81
82 canvas->saveLayer(nullptr, &p);
83 canvas->restore();
84 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void restore()
Definition: SkCanvas.cpp:461
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ onOnceBeforeDraw()

void skiagm::ImageSourceGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 44 of file imagesource2.cpp.

44 {
45 constexpr SkPMColor gColors[] = {
53 };
54
55 auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(kImageSize, kImageSize)));
56 SkCanvas* canvas = surface->getCanvas();
57
58 int curColor = 0;
59
60 for (int x = 0; x < kImageSize; x += 3) {
62 SkIntToScalar(3), SkIntToScalar(kImageSize));
63 SkPaint p;
64 p.setColor(gColors[curColor]);
65 canvas->drawRect(r, p);
66
67 curColor = (curColor+1) % std::size(gColors);
68 }
69
70 fImage = surface->makeImageSnapshot();
71 }
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
uint32_t SkPMColor
Definition: SkColor.h:205
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
VkSurfaceKHR surface
Definition: main.cc:49
double x
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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 SkColor gColors[]
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

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