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

Public Member Functions

 EncodePlatformGM ()
 
- 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
 
DrawResult onDraw (SkCanvas *canvas, SkString *errorMsg) 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 74 of file encode_platform.cpp.

Constructor & Destructor Documentation

◆ EncodePlatformGM()

skiagm::EncodePlatformGM::EncodePlatformGM ( )
inline

Definition at line 76 of file encode_platform.cpp.

76{}

Member Function Documentation

◆ getISize()

SkISize skiagm::EncodePlatformGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 81 of file encode_platform.cpp.

81{ return SkISize::Make(256 * std::size(gRecs), 256 * 3); }
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
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 79 of file encode_platform.cpp.

79{ return SkString("encode-platform"); }

◆ onDraw()

DrawResult skiagm::EncodePlatformGM::onDraw ( SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 83 of file encode_platform.cpp.

83 {
84 SkBitmap opaqueBm, premulBm, unpremulBm;
85
86 if (!ToolUtils::GetResourceAsBitmap("images/mandrill_256.png", &opaqueBm)) {
87 *errorMsg = "Could not load images/mandrill_256.png.png. "
88 "Did you forget to set the resourcePath?";
89 return DrawResult::kFail;
90 }
91 SkBitmap tmp;
92 if (!ToolUtils::GetResourceAsBitmap("images/yellow_rose.png", &tmp)) {
93 *errorMsg = "Could not load images/yellow_rose.png. "
94 "Did you forget to set the resourcePath?";
95 return DrawResult::kFail;
96 }
97 tmp.extractSubset(&premulBm, SkIRect::MakeWH(256, 256));
98 tmp.reset();
100 SkAssertResult(premulBm.readPixels(unpremulBm.pixmap()));
101
102 for (const auto& rec : gRecs) {
103 auto fmt = rec.format; int q = rec.quality;
104 auto opaqueImage = SkImages::DeferredFromEncodedData(encode_data(fmt, opaqueBm, q));
105 auto premulImage = SkImages::DeferredFromEncodedData(encode_data(fmt, premulBm, q));
106 auto unpremulImage = SkImages::DeferredFromEncodedData(encode_data(fmt, unpremulBm, q));
107
108 canvas->drawImage(opaqueImage.get(), 0.0f, 0.0f);
109 canvas->drawImage(premulImage.get(), 0.0f, 256.0f);
110 canvas->drawImage(unpremulImage.get(), 0.0f, 512.0f);
111
112 canvas->translate(256.0f, 0.0f);
113 }
114 return DrawResult::kOk;
115 }
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
kUnpremul_SkAlphaType
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
Definition: SkBitmap.cpp:453
const SkPixmap & pixmap() const
Definition: SkBitmap.h:133
void reset()
Definition: SkBitmap.cpp:92
const SkImageInfo & info() const
Definition: SkBitmap.h:139
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
Definition: SkBitmap.cpp:488
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
bool GetResourceAsBitmap(const char *resource, SkBitmap *dst)
Definition: DecodeUtils.h:21
static sk_sp< SkData > encode_data(const SkBitmap &bitmap, SkEncodedImageFormat format)
Definition: encode_srgb.cpp:65
static SkString fmt(SkColor4f c)
Definition: p3.cpp:43
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.h:466

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