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

Public Types

enum class  Type { kNormal , kNonPowerOfTwo , kNonMultipleOfFour }
 
- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 

Public Member Functions

 CompressedTexturesGM (Type type)
 
- 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 onGpuSetup (SkCanvas *canvas, SkString *errorMsg, GraphiteTestContext *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

- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 216 of file compressed_textures.cpp.

Member Enumeration Documentation

◆ Type

enum class CompressedTexturesGM::Type
strong
Enumerator
kNormal 
kNonPowerOfTwo 
kNonMultipleOfFour 

Definition at line 218 of file compressed_textures.cpp.

218 {
219 kNormal,
220 kNonPowerOfTwo,
221 kNonMultipleOfFour
222 };
@ kNormal
Default priority level.
Definition: embedder.h:262

Constructor & Destructor Documentation

◆ CompressedTexturesGM()

CompressedTexturesGM::CompressedTexturesGM ( Type  type)
inline

Definition at line 224 of file compressed_textures.cpp.

224 : fType(type) {
225 this->setBGColor(0xFFCCCCCC);
226
227 switch (fType) {
229 // These dimensions force the top two mip levels to be 1x3 and 1x1
230 fImgDimensions.set(20, 60);
231 break;
233 // These dimensions force the top three mip levels to be 1x7, 1x3 and 1x1
234 fImgDimensions.set(13, 61); // prime numbers - just bc
235 break;
236 default:
237 fImgDimensions.set(kBaseTexWidth, kBaseTexHeight);
238 break;
239 }
240
241 }
GLenum type
void setBGColor(SkColor)
Definition: gm.cpp:159
void set(int32_t w, int32_t h)
Definition: SkSize.h:24

Member Function Documentation

◆ getISize()

SkISize CompressedTexturesGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 256 of file compressed_textures.cpp.

256 {
257 return SkISize::Make(2*kCellWidth + 3*kPad, 2*kBaseTexHeight + 3*kPad);
258 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString CompressedTexturesGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 244 of file compressed_textures.cpp.

244 {
245 SkString name("compressed_textures");
246
247 if (fType == Type::kNonPowerOfTwo) {
248 name.append("_npot");
249 } else if (fType == Type::kNonMultipleOfFour) {
250 name.append("_nmof");
251 }
252
253 return name;
254 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ onDraw()

void CompressedTexturesGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 304 of file compressed_textures.cpp.

304 {
305 this->drawCell(canvas, fOpaqueETC2Image.fImage.get(), { kPad, kPad });
306
307 this->drawCell(canvas, fOpaqueBC1Image.fImage.get(), { 2*kPad + kCellWidth, kPad });
308
309 this->drawCell(canvas, fTransparentBC1Image.fImage.get(),
310 { 2*kPad + kCellWidth, 2*kPad + kBaseTexHeight });
311 }
T * get() const
Definition: SkRefCnt.h:303

◆ onGpuSetup()

DrawResult CompressedTexturesGM::onGpuSetup ( SkCanvas canvas,
SkString errorMsg,
GraphiteTestContext graphiteTestContext 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 260 of file compressed_textures.cpp.

261 {
262 auto dContext = GrAsDirectContext(canvas->recordingContext());
263 if (dContext && dContext->abandoned()) {
264 // This isn't a GpuGM so a null 'context' is okay but an abandoned context
265 // if forbidden.
266 return DrawResult::kSkip;
267 }
268
269 if (dContext &&
270 dContext->backend() == GrBackendApi::kDirect3D && fType == Type::kNonMultipleOfFour) {
271 // skbug.com/10541 - Are non-multiple-of-four BC1 textures supported in D3D?
272 return DrawResult::kSkip;
273 }
274
275 fOpaqueETC2Image = make_compressed_image(canvas, fImgDimensions,
278
279 fOpaqueBC1Image = make_compressed_image(canvas, fImgDimensions,
282
283 fTransparentBC1Image = make_compressed_image(canvas, fImgDimensions,
286
287 if (!fOpaqueETC2Image.fImage || !fOpaqueBC1Image.fImage || !fTransparentBC1Image.fImage) {
288 *errorMsg = "Failed to create compressed images.";
289 return DrawResult::kFail;
290 }
291
292 return DrawResult::kOk;
293 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
static CompressedImageObjects make_compressed_image(SkCanvas *canvas, const SkISize dimensions, SkColorType colorType, bool opaque, SkTextureCompressionType compression)

◆ onGpuTeardown()

void CompressedTexturesGM::onGpuTeardown ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 295 of file compressed_textures.cpp.

295 {
296 fOpaqueETC2Image.fImage = nullptr;
297 fOpaqueBC1Image.fImage = nullptr;
298 fTransparentBC1Image.fImage = nullptr;
299 fOpaqueETC2Image.fGraphiteTexture = nullptr;
300 fOpaqueBC1Image.fGraphiteTexture = nullptr;
301 fTransparentBC1Image.fGraphiteTexture = nullptr;
302 }

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