blob: cb4658ae0f14b9958dd7848c53b43083d6607cd0 [file] [log] [blame]
reed96638d12015-01-26 12:28:54 -08001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "Benchmark.h"
9#include "SkBitmap.h"
10#include "SkMipMap.h"
11
12class MipMapBench: public Benchmark {
13 SkBitmap fBitmap;
14
15public:
16 MipMapBench() {}
17
18protected:
19 bool isSuitableFor(Backend backend) SK_OVERRIDE {
20 return kNonRendering_Backend == backend;
21 }
22
23 const char* onGetName() SK_OVERRIDE { return "mipmap_build"; }
24
25 void onPreDraw() SK_OVERRIDE {
26 fBitmap.allocN32Pixels(1000, 1000, true);
27 fBitmap.eraseColor(SK_ColorWHITE); // so we don't read uninitialized memory
28 }
29
30 void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
31 for (int i = 0; i < loops; i++) {
32 SkMipMap::Build(fBitmap, NULL)->unref();
33 }
34 }
35
36private:
37 typedef Benchmark INHERITED;
38};
39
40DEF_BENCH( return new MipMapBench; )