Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Member Functions | List of all members
ImageCacheBudgetDynamicBench Class Reference
Inheritance diagram for ImageCacheBudgetDynamicBench:
Benchmark SkRefCnt SkRefCntBase

Public Types

enum class  Mode { kPingPong , kFlipFlop }
 
- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 

Public Member Functions

 ImageCacheBudgetDynamicBench (Mode mode)
 
bool isSuitableFor (Backend backend) override
 
- Public Member Functions inherited from Benchmark
 Benchmark ()
 
const char * getName ()
 
const char * getUniqueName ()
 
SkISize getSize ()
 
virtual bool isSuitableFor (Backend backend)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual bool shouldLoop () const
 
void delayedSetup ()
 
void perCanvasPreDraw (SkCanvas *)
 
void perCanvasPostDraw (SkCanvas *)
 
void preDraw (SkCanvas *)
 
void postDraw (SkCanvas *)
 
void draw (int loops, SkCanvas *)
 
virtual void getGpuStats (SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values)
 
virtual bool getDMSAAStats (GrRecordingContext *)
 
int getUnits () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

const char * onGetName () override
 
void onPerCanvasPreDraw (SkCanvas *canvas) override
 
void onPerCanvasPostDraw (SkCanvas *canvas) override
 
void onDraw (int loops, SkCanvas *canvas) override
 
- Protected Member Functions inherited from Benchmark
void setUnits (int units)
 
virtual void setupPaint (SkPaint *paint)
 
virtual const char * onGetName ()=0
 
virtual const char * onGetUniqueName ()
 
virtual void onDelayedSetup ()
 
virtual void onPerCanvasPreDraw (SkCanvas *)
 
virtual void onPerCanvasPostDraw (SkCanvas *)
 
virtual void onPreDraw (SkCanvas *)
 
virtual void onPostDraw (SkCanvas *)
 
virtual void onDraw (int loops, SkCanvas *)=0
 
virtual SkISize onGetSize ()
 

Detailed Description

Similar to above but changes between being over and under budget by varying the number of images rendered. This is not directly comparable to the non-dynamic benchmarks.

Definition at line 183 of file ImageCacheBudgetBench.cpp.

Member Enumeration Documentation

◆ Mode

Enumerator
kPingPong 
kFlipFlop 

Definition at line 185 of file ImageCacheBudgetBench.cpp.

185 {
186 // Increase from min to max images drawn gradually over simulated frames and then back.
187 kPingPong,
188 // Alternate between under and over budget every other simulated frame.
189 kFlipFlop
190 };

Constructor & Destructor Documentation

◆ ImageCacheBudgetDynamicBench()

ImageCacheBudgetDynamicBench::ImageCacheBudgetDynamicBench ( Mode  mode)
inline

Definition at line 192 of file ImageCacheBudgetBench.cpp.

192: fMode(mode) {}
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 mode
Definition: switches.h:228

Member Function Documentation

◆ isSuitableFor()

bool ImageCacheBudgetDynamicBench::isSuitableFor ( Backend  backend)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 194 of file ImageCacheBudgetBench.cpp.

194{ return Backend::kGanesh == backend; }
const char * backend

◆ onDraw()

void ImageCacheBudgetDynamicBench::onDraw ( int  loops,
SkCanvas canvas 
)
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 224 of file ImageCacheBudgetBench.cpp.

224 {
225 auto dContext = GrAsDirectContext(canvas->recordingContext());
226
227 int delta = 0;
228 switch (fMode) {
229 case Mode::kPingPong:
230 delta = 1;
231 break;
232 case Mode::kFlipFlop:
233 delta = kMaxImagesToDraw - kMinImagesToDraw;
234 break;
235 }
236 for (int i = 0; i < loops; ++i) {
237 int imgsToDraw = kMinImagesToDraw;
238 for (int frame = 0; frame < kSimulatedFrames; ++frame) {
239 for (int j = 0; j < imgsToDraw; ++j) {
240 draw_image(canvas, fImages[j].get());
241 }
242 imgsToDraw += delta;
243 if (imgsToDraw > kMaxImagesToDraw || imgsToDraw < kMinImagesToDraw) {
244 delta = -delta;
245 imgsToDraw += 2 * delta;
246 }
247 // Simulate a frame boundary by flushing. This should notify GrResourceCache.
248 if (dContext) {
249 dContext->flush();
250 }
251 }
252 }
253 }
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
static void draw_image(SkCanvas *canvas, SkImage *img)
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
double frame
Definition: examples.cpp:31
const myers::Point & get(const myers::Segment &)

◆ onGetName()

const char * ImageCacheBudgetDynamicBench::onGetName ( )
inlineoverrideprotectedvirtual

Implements Benchmark.

Definition at line 197 of file ImageCacheBudgetBench.cpp.

197 {
198 switch (fMode) {
199 case Mode::kPingPong:
200 return "image_cache_budget_dynamic_ping_pong";
201 case Mode::kFlipFlop:
202 return "image_cache_budget_dynamic_flip_flop";
203 }
204 return "";
205 }

◆ onPerCanvasPostDraw()

void ImageCacheBudgetDynamicBench::onPerCanvasPostDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 215 of file ImageCacheBudgetBench.cpp.

215 {
216 auto context = canvas->recordingContext()->asDirectContext();
217 SkASSERT(context);
218 context->setResourceCacheLimits(fOldCount, fOldBytes);
219 for (int i = 0; i < kMaxImagesToDraw; ++i) {
220 fImages[i].reset();
221 }
222 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
virtual GrDirectContext * asDirectContext()
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

◆ onPerCanvasPreDraw()

void ImageCacheBudgetDynamicBench::onPerCanvasPreDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from Benchmark.

Definition at line 207 of file ImageCacheBudgetBench.cpp.

207 {
208 auto context = canvas->recordingContext()->asDirectContext();
209 SkASSERT(context);
210 context->getResourceCacheLimits(&fOldCount, &fOldBytes);
211 make_images(fImages, kMaxImagesToDraw);
212 set_cache_budget(canvas, kImagesInBudget);
213 }
static void make_images(sk_sp< SkImage > imgs[], int cnt)
void set_cache_budget(SkCanvas *canvas, int approxImagesInBudget)

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