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

Public Member Functions

 EncodeJpegAlphaOptsGM ()
 
- 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 44 of file encode_alpha_jpeg.cpp.

Constructor & Destructor Documentation

◆ EncodeJpegAlphaOptsGM()

skiagm::EncodeJpegAlphaOptsGM::EncodeJpegAlphaOptsGM ( )
inline

Definition at line 46 of file encode_alpha_jpeg.cpp.

46{}

Member Function Documentation

◆ getISize()

SkISize skiagm::EncodeJpegAlphaOptsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 51 of file encode_alpha_jpeg.cpp.

51{ return SkISize::Make(400, 200); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 49 of file encode_alpha_jpeg.cpp.

49{ return SkString("encode-alpha-jpeg"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 53 of file encode_alpha_jpeg.cpp.

53 {
54 sk_sp<SkImage> srcImg = ToolUtils::GetResourceAsImage("images/rainbow-gradient.png");
55 if (!srcImg) {
56 *errorMsg = "Could not load images/rainbow-gradient.png. "
57 "Did you forget to set the resourcePath?";
58 return DrawResult::kFail;
59 }
60 fStorage.reset(srcImg->width() * srcImg->height() *
62
65 canvas->imageInfo().colorSpace() ? SkColorSpace::MakeSRGB() : nullptr);
66 read_into_pixmap(&src, info, fStorage.get(), srcImg);
67
68 // Encode 8888 premul.
71 canvas->drawImage(img0, 0.0f, 0.0f);
72 canvas->drawImage(img1, 0.0f, 100.0f);
73
74 // Encode 8888 unpremul
75 info = info.makeAlphaType(kUnpremul_SkAlphaType);
76 read_into_pixmap(&src, info, fStorage.get(), srcImg);
79 canvas->drawImage(img0, 100.0f, 0.0f);
80 canvas->drawImage(img1, 100.0f, 100.0f);
81
82 // Encode F16 premul
85 read_into_pixmap(&src, info, fStorage.get(), srcImg);
88 canvas->drawImage(img0, 200.0f, 0.0f);
89 canvas->drawImage(img1, 200.0f, 100.0f);
90
91 // Encode F16 unpremul
92 info = info.makeAlphaType(kUnpremul_SkAlphaType);
93 read_into_pixmap(&src, info, fStorage.get(), srcImg);
96 canvas->drawImage(img0, 300.0f, 0.0f);
97 canvas->drawImage(img1, 300.0f, 100.0f);
98
99 return DrawResult::kOk;
100 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
kUnpremul_SkAlphaType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
Definition: SkImageInfo.cpp:16
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkColorSpace > MakeSRGB()
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
T * reset(size_t count=0)
Definition: SkTemplates.h:296
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25
static sk_sp< SkImage > encode_pixmap_and_make_image(const SkPixmap &src, SkJpegEncoder::AlphaOption alphaOption)
static void read_into_pixmap(SkPixmap *dst, SkImageInfo dstInfo, void *dstPixels, sk_sp< SkImage > src)
static SkImageInfo MakeN32Premul(int width, int height)
SkColorSpace * colorSpace() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

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