27static constexpr int kS = 25;
30 for (
int i = 0;
i < cnt; ++
i) {
48 context->flushAndSubmit();
49 context->priv().getResourceCache()->purgeUnlockedResources(
54 context->flushAndSubmit();
56 context->getResourceCacheUsage(&baselineCount,
nullptr);
58 context->setResourceCacheLimits(baselineCount + approxImagesInBudget, 1 << 30);
59 context->priv().getResourceCache()->purgeUnlockedResources(
75 : fBudgetSize(budgetSize)
78 float imagesOverBudget =
float(kImagesToDraw) / budgetSize;
81 fName.
printf(
"image_cache_budget_%.0f%s", imagesOverBudget * 100,
95 fOldBytes = context->getResourceCacheLimit();
100 fIndices.reset(
new int[kSimulatedFrames * kImagesToDraw]);
102 int*
base = fIndices.get() +
frame * kImagesToDraw;
103 for (
int i = 0;
i < kImagesToDraw; ++
i) {
106 for (
int i = 0;
i < kImagesToDraw - 1; ++
i) {
118 context->setResourceCacheLimit(fOldBytes);
119 for (
int i = 0;
i < kImagesToDraw; ++
i) {
122 fIndices.reset(
nullptr);
128 for (
int i = 0;
i < loops; ++
i) {
130 for (
int j = 0; j < kImagesToDraw; ++j) {
133 idx = fIndices[
frame * kImagesToDraw + j];
148 inline static constexpr int kImagesToDraw = 100;
149 inline static constexpr int kSimulatedFrames = 5;
155 std::unique_ptr<int[]> fIndices;
199 case Mode::kPingPong:
200 return "image_cache_budget_dynamic_ping_pong";
201 case Mode::kFlipFlop:
202 return "image_cache_budget_dynamic_flip_flop";
210 context->getResourceCacheLimits(&fOldCount, &fOldBytes);
218 context->setResourceCacheLimits(fOldCount, fOldBytes);
219 for (
int i = 0;
i < kMaxImagesToDraw; ++
i) {
229 case Mode::kPingPong:
232 case Mode::kFlipFlop:
233 delta = kMaxImagesToDraw - kMinImagesToDraw;
236 for (
int i = 0;
i < loops; ++
i) {
237 int imgsToDraw = kMinImagesToDraw;
239 for (
int j = 0; j < imgsToDraw; ++j) {
243 if (imgsToDraw > kMaxImagesToDraw || imgsToDraw < kMinImagesToDraw) {
245 imgsToDraw += 2 *
delta;
256 inline static constexpr int kImagesInBudget = 25;
257 inline static constexpr int kMinImagesToDraw = 15;
258 inline static constexpr int kMaxImagesToDraw = 35;
259 inline static constexpr int kSimulatedFrames = 80;
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
static void make_images(sk_sp< SkImage > imgs[], int cnt)
static void draw_image(SkCanvas *canvas, SkImage *img)
void set_cache_budget(SkCanvas *canvas, int approxImagesInBudget)
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorBLACK
#define INHERITED(method,...)
void swap(sk_sp< T > &a, sk_sp< T > &b)
virtual GrDirectContext * asDirectContext()
void onDraw(int loops, SkCanvas *canvas) override
bool isSuitableFor(Backend backend) override
void onPerCanvasPreDraw(SkCanvas *canvas) override
void onPerCanvasPostDraw(SkCanvas *canvas) override
const char * onGetName() override
ImageCacheBudgetBench(int budgetSize, bool shuffle)
bool isSuitableFor(Backend backend) override
void onPerCanvasPostDraw(SkCanvas *canvas) override
void onPerCanvasPreDraw(SkCanvas *canvas) override
void onDraw(int loops, SkCanvas *canvas) override
const char * onGetName() override
ImageCacheBudgetDynamicBench(Mode mode)
virtual GrRecordingContext * recordingContext() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
uint32_t nextULessThan(uint32_t count)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
void reset(T *ptr=nullptr)
sk_sp< const SkImage > image
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
const myers::Point & get(const myers::Segment &)
SkSamplingOptions(SkFilterMode::kLinear))
SI Vec< sizeof...(Ix), T > shuffle(const Vec< N, T > &)