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

Public Member Functions

 ReadPixelsGM ()
 
- 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 129 of file readpixels.cpp.

Constructor & Destructor Documentation

◆ ReadPixelsGM()

ReadPixelsGM::ReadPixelsGM ( )
inline

Definition at line 131 of file readpixels.cpp.

131{}

Member Function Documentation

◆ getISize()

SkISize ReadPixelsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 136 of file readpixels.cpp.

136{ return SkISize::Make(6 * kWidth, 9 * kHeight); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString ReadPixelsGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 134 of file readpixels.cpp.

134{ return SkString("readpixels"); }

◆ onDraw()

void ReadPixelsGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 138 of file readpixels.cpp.

138 {
139 const SkAlphaType alphaTypes[] = {
142 };
143 const SkColorType colorTypes[] = {
147 };
148 const sk_sp<SkColorSpace> colorSpaces[] = {
152 };
153
154 for (const sk_sp<SkColorSpace>& dstColorSpace : colorSpaces) {
155 for (SkColorType srcColorType : colorTypes) {
156 canvas->save();
157 sk_sp<SkImage> image = make_raster_image(srcColorType);
158 if (!image) {
159 continue;
160 }
161 auto dContext = GrAsDirectContext(canvas->recordingContext());
162 if (dContext) {
164 }
165 if (image) {
166 for (SkColorType dstColorType : colorTypes) {
167 for (SkAlphaType dstAlphaType : alphaTypes) {
168 draw_image(dContext, canvas, image.get(), dstColorType, dstAlphaType,
169 dstColorSpace, SkImage::kAllow_CachingHint);
170 canvas->translate((float)kWidth, 0.0f);
171 }
172 }
173 }
174 canvas->restore();
175 canvas->translate(0.0f, (float) kHeight);
176 }
177 }
178 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
kUnpremul_SkAlphaType
SkAlphaType
Definition: SkAlphaType.h:26
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Definition: SkColorType.h:19
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
int save()
Definition: SkCanvas.cpp:447
static sk_sp< SkColorSpace > MakeSRGB()
@ kAllow_CachingHint
allows internally caching decoded and copied pixels
Definition: SkImage.h:464
T * get() const
Definition: SkRefCnt.h:303
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
static void draw_image(GrDirectContext *dContext, SkCanvas *canvas, SkImage *image, SkColorType dstColorType, SkAlphaType dstAlphaType, sk_sp< SkColorSpace > dstColorSpace, SkImage::CachingHint hint)
Definition: readpixels.cpp:112
static sk_sp< SkColorSpace > make_wide_gamut()
Definition: readpixels.cpp:85
static sk_sp< SkImage > make_raster_image(SkColorType colorType)
Definition: readpixels.cpp:37
static sk_sp< SkColorSpace > make_small_gamut()
Definition: readpixels.cpp:99

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