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

Public Member Functions

 ExoticFormatsGM ()
 
- 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
 
bool loadImages (GrDirectContext *direct)
 
void drawImage (SkCanvas *canvas, SkImage *image, int x, int y)
 
DrawResult onGpuSetup (SkCanvas *canvas, SkString *errorMsg, GraphiteTestContext *) override
 
void onGpuTeardown () 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 330 of file exoticformats.cpp.

Constructor & Destructor Documentation

◆ ExoticFormatsGM()

skiagm::ExoticFormatsGM::ExoticFormatsGM ( )
inline

Definition at line 332 of file exoticformats.cpp.

332 {
334 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ drawImage()

void skiagm::ExoticFormatsGM::drawImage ( SkCanvas canvas,
SkImage image,
int  x,
int  y 
)
inlineprotected

Definition at line 379 of file exoticformats.cpp.

379 {
380 if (!image) {
381 return;
382 }
383
384 bool isCompressed = false;
385 if (image->isTextureBacked()) {
386 const GrCaps* caps = as_IB(image)->context()->priv().caps();
388 canvas->recordingContext());
389 isCompressed = caps->isFormatCompressed(proxy->backendFormat());
390 }
391
392 canvas->drawImage(image, x, y);
393
394 if (!isCompressed) {
395 // Make it obvious which drawImages used decompressed images
396 SkRect r = SkRect::MakeXYWH(x, y, kImgWidthHeight, kImgWidthHeight);
398 paint.setColor(SK_ColorRED);
400 paint.setStrokeWidth(2.0f);
401 canvas->drawRect(r, paint);
402 }
403 }
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
const GrCaps * caps() const
Definition: GrCaps.h:57
bool isFormatCompressed(const GrBackendFormat &format) const
Definition: GrCaps.cpp:457
GrImageContextPriv priv()
const GrBackendFormat & backendFormat() const
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
virtual GrImageContext * context() const
Definition: SkImage_Base.h:112
virtual bool isTextureBacked() const =0
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38
double y
double x
sk_sp< const SkImage > image
Definition: SkRecords.h:269
GrTextureProxy * GetTextureImageProxy(SkImage *image, GrRecordingContext *rContext)
Definition: ProxyUtils.cpp:32
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ getISize()

SkISize skiagm::ExoticFormatsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 339 of file exoticformats.cpp.

339 {
340 return SkISize::Make(2*kImgWidthHeight + 3 * kPad, kImgWidthHeight + 2 * kPad);
341 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 337 of file exoticformats.cpp.

337{ return SkString("exoticformats"); }

◆ loadImages()

bool skiagm::ExoticFormatsGM::loadImages ( GrDirectContext direct)
inlineprotected

Definition at line 343 of file exoticformats.cpp.

343 {
344 SkASSERT(!fETC1Image && !fBC1Image);
345
346 {
348 sk_sp<SkData> data = load_ktx(GetResourcePath("images/flower-etc1.ktx").c_str(), &info);
349 if (data) {
350 SkASSERT(info.fDim.equals(kImgWidthHeight, kImgWidthHeight));
351 SkASSERT(info.fMipmapped == skgpu::Mipmapped::kNo);
353
354 fETC1Image = data_to_img(direct, std::move(data), info);
355 } else {
356 SkDebugf("failed to load flower-etc1.ktx\n");
357 return false;
358 }
359 }
360
361 {
363 sk_sp<SkData> data = load_dds(GetResourcePath("images/flower-bc1.dds").c_str(), &info);
364 if (data) {
365 SkASSERT(info.fDim.equals(kImgWidthHeight, kImgWidthHeight));
366 SkASSERT(info.fMipmapped == skgpu::Mipmapped::kNo);
368
369 fBC1Image = data_to_img(direct, std::move(data), info);
370 } else {
371 SkDebugf("failed to load flower-bc1.dds\n");
372 return false;
373 }
374 }
375
376 return true;
377 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkString GetResourcePath(const char *resource)
Definition: Resources.cpp:23
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static sk_sp< SkImage > data_to_img(GrDirectContext *direct, sk_sp< SkData > data, const ImageInfo &info)
static sk_sp< SkData > load_dds(const char *filename, ImageInfo *imageInfo)
static sk_sp< SkData > load_ktx(const char *filename, ImageInfo *imageInfo)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 426 of file exoticformats.cpp.

426 {
427 SkASSERT(fETC1Image && fBC1Image);
428
429 this->drawImage(canvas, fETC1Image.get(), kPad, kPad);
430 this->drawImage(canvas, fBC1Image.get(), kImgWidthHeight + 2 * kPad, kPad);
431 }
T * get() const
Definition: SkRefCnt.h:303
void drawImage(SkCanvas *canvas, SkImage *image, int x, int y)

◆ onGpuSetup()

DrawResult skiagm::ExoticFormatsGM::onGpuSetup ( SkCanvas canvas,
SkString errorMsg,
GraphiteTestContext  
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 405 of file exoticformats.cpp.

405 {
406 auto dContext = GrAsDirectContext(canvas->recordingContext());
407 if (dContext && dContext->abandoned()) {
408 // This isn't a GpuGM so a null 'context' is okay but an abandoned context
409 // if forbidden.
410 return DrawResult::kSkip;
411 }
412
413 if (!this->loadImages(dContext)) {
414 *errorMsg = "Failed to create images.";
415 return DrawResult::kFail;
416 }
417
418 return DrawResult::kOk;
419 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
bool loadImages(GrDirectContext *direct)

◆ onGpuTeardown()

void skiagm::ExoticFormatsGM::onGpuTeardown ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 421 of file exoticformats.cpp.

421 {
422 fETC1Image = nullptr;
423 fBC1Image = nullptr;
424 }

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