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

Public Member Functions

 EncodeSRGBGM (SkEncodedImageFormat format)
 
- 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 89 of file encode_srgb.cpp.

Constructor & Destructor Documentation

◆ EncodeSRGBGM()

skiagm::EncodeSRGBGM::EncodeSRGBGM ( SkEncodedImageFormat  format)
inline

Definition at line 91 of file encode_srgb.cpp.

92 : fEncodedFormat(format)
93 {}
uint32_t uint32_t * format

Member Function Documentation

◆ getISize()

SkISize skiagm::EncodeSRGBGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 114 of file encode_srgb.cpp.

114{ return SkISize::Make(imageWidth * 2, imageHeight * 15); }
static const int imageHeight
static const int imageWidth
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 96 of file encode_srgb.cpp.

96 {
97 const char* format = nullptr;
98 switch (fEncodedFormat) {
100 format = "png";
101 break;
103 format = "webp";
104 break;
106 format = "jpg";
107 break;
108 default:
109 break;
110 }
111 return SkStringPrintf("encode-srgb-%s", format);
112 }
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 116 of file encode_srgb.cpp.

116 {
117 const SkColorType colorTypes[] = {
118 kN32_SkColorType, kRGBA_F16_SkColorType,
119#if !defined(SK_ENABLE_NDK_IMAGES)
120 // These fail with the NDK encoders because there is a mismatch between
121 // Gray_8 and Alpha_8
123#endif
125 };
126 const SkAlphaType alphaTypes[] = {
128 };
129 const sk_sp<SkColorSpace> colorSpaces[] = {
130 nullptr, SkColorSpace::MakeSRGB(),
131 };
132
134 for (SkColorType colorType : colorTypes) {
135 for (SkAlphaType alphaType : alphaTypes) {
136 canvas->save();
137 for (const sk_sp<SkColorSpace>& colorSpace : colorSpaces) {
138 make(&bitmap, colorType, alphaType, colorSpace);
139 auto data = encode_data(bitmap, fEncodedFormat);
141 canvas->drawImage(image.get(), 0.0f, 0.0f);
142 canvas->translate((float) imageWidth, 0.0f);
143 }
144 canvas->restore();
145 canvas->translate(0.0f, (float) imageHeight);
146 }
147 }
148 }
kUnpremul_SkAlphaType
SkAlphaType
Definition: SkAlphaType.h:26
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Definition: SkColorType.h:19
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkColorSpace > MakeSRGB()
T * get() const
Definition: SkRefCnt.h:303
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
Definition: bitmap.py:1
static void make(SkBitmap *bitmap, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace)
Definition: encode_srgb.cpp:35
static sk_sp< SkData > encode_data(const SkBitmap &bitmap, SkEncodedImageFormat format)
Definition: encode_srgb.cpp:65
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

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