Chromium Code Reviews| Index: bench/MagnifierBench.cpp |
| =================================================================== |
| --- bench/MagnifierBench.cpp (revision 0) |
| +++ bench/MagnifierBench.cpp (revision 0) |
| @@ -0,0 +1,54 @@ |
| +/* |
| + * 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 250 |
|
Stephen White
2013/04/19 18:39:01
As above, perhaps 32x32 and 512x512.
sugoi1
2013/04/22 15:49:47
Done.
|
| +#define HEIGHT 250 |
| + |
| +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(WIDTH / 4), |
| + SkIntToScalar(HEIGHT / 4), |
| + 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."; |
| + srand(1234); |
|
jvanverth1
2013/04/19 19:26:31
Is there a reason you're using rand()? Can you try
sugoi1
2013/04/19 20:47:28
The quality of the randomness isn't really importa
sugoi1
2013/04/22 15:49:47
Well, I ended up removing all random number genera
|
| + 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), |
|
Stephen White
2013/04/19 18:39:01
You should probably preinitialize the input bitmap
sugoi1
2013/04/22 15:49:47
Done.
|
| + SkIntToScalar(y), paint); |
| + } |
| + canvas->restore(); |
| + } |
| + |
| +private: |
| + typedef SkBenchmark INHERITED; |
| +}; |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +DEF_BENCH( return new MagnifierBench(p); ) |
| + |