Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2013 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 #include "SkBenchmark.h" | |
| 8 #include "SkCanvas.h" | |
| 9 #include "SkMagnifierImageFilter.h" | |
| 10 | |
| 11 #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.
| |
| 12 #define HEIGHT 250 | |
| 13 | |
| 14 class MagnifierBench : public SkBenchmark { | |
| 15 public: | |
| 16 MagnifierBench(void* param) : INHERITED(param) { | |
| 17 } | |
| 18 | |
| 19 protected: | |
| 20 virtual const char* onGetName() SK_OVERRIDE { | |
| 21 return "magnifier"; | |
| 22 } | |
| 23 | |
| 24 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | |
| 25 SkPaint paint; | |
| 26 paint.setImageFilter( | |
| 27 new SkMagnifierImageFilter( | |
| 28 SkRect::MakeXYWH(SkIntToScalar(WIDTH / 4), | |
| 29 SkIntToScalar(HEIGHT / 4), | |
| 30 SkIntToScalar(WIDTH / 2), | |
| 31 SkIntToScalar(HEIGHT / 2)), 100))->unref(); | |
| 32 canvas->saveLayer(NULL, &paint); | |
| 33 paint.setAntiAlias(true); | |
| 34 const char* str = "The quick brown fox jumped over the lazy dog."; | |
| 35 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
| |
| 36 for (int i = 0; i < 25; ++i) { | |
| 37 int x = rand() % WIDTH; | |
| 38 int y = rand() % HEIGHT; | |
| 39 paint.setColor(rand() % 0x1000000 | 0xFF000000); | |
| 40 paint.setTextSize(SkIntToScalar(rand() % 300)); | |
| 41 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.
| |
| 42 SkIntToScalar(y), paint); | |
| 43 } | |
| 44 canvas->restore(); | |
| 45 } | |
| 46 | |
| 47 private: | |
| 48 typedef SkBenchmark INHERITED; | |
| 49 }; | |
| 50 | |
| 51 /////////////////////////////////////////////////////////////////////////////// | |
| 52 | |
| 53 DEF_BENCH( return new MagnifierBench(p); ) | |
| 54 | |
| OLD | NEW |