Chromium Code Reviews| Index: bench/MagnifierBench.cpp |
| =================================================================== |
| --- bench/MagnifierBench.cpp (revision 0) |
| +++ bench/MagnifierBench.cpp (revision 0) |
| @@ -0,0 +1,53 @@ |
| +/* |
| + * Copyright 2013 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| +#include "SkBenchmark.h" |
| +#include "SkCanvas.h" |
| +#include "SkMagnifierImageFilter.h" |
| + |
| +#define WIDTH 500 |
| +#define HEIGHT 500 |
| + |
| +class MagnifierBench : public SkBenchmark { |
| +public: |
| + MagnifierBench(void* param) : INHERITED(param) { |
| + } |
| + |
| +protected: |
| + virtual const char* onGetName() SK_OVERRIDE { |
| + return "magnifier"; |
| + } |
| + |
| + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| + SkPaint paint; |
| + paint.setImageFilter( |
| + new SkMagnifierImageFilter( |
| + SkRect::MakeXYWH(SkIntToScalar(125), SkIntToScalar(125), |
| + SkIntToScalar(WIDTH / 2), |
| + SkIntToScalar(HEIGHT / 2)), 100))->unref(); |
| + canvas->saveLayer(NULL, &paint); |
| + paint.setAntiAlias(true); |
| + const char* str = "The quick brown fox jumped over the lazy dog."; |
|
Stephen White
2013/04/15 15:34:21
We should probably rewrite this one (as well as th
sugoi1
2013/04/19 18:09:42
Done. I made it twice as small in each direction,
|
| + srand(1234); |
| + for (int i = 0; i < 25; ++i) { |
| + int x = rand() % WIDTH; |
| + int y = rand() % HEIGHT; |
| + paint.setColor(rand() % 0x1000000 | 0xFF000000); |
| + paint.setTextSize(SkIntToScalar(rand() % 300)); |
| + canvas->drawText(str, strlen(str), SkIntToScalar(x), |
| + SkIntToScalar(y), paint); |
| + } |
| + canvas->restore(); |
| + } |
| + |
| +private: |
| + typedef SkBenchmark INHERITED; |
| +}; |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +DEF_BENCH( return new MagnifierBench(p); ) |
| + |