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 500 | |
| 12 #define HEIGHT 500 | |
| 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(125), SkIntToScalar(125), | |
| 29 SkIntToScalar(WIDTH / 2), | |
| 30 SkIntToScalar(HEIGHT / 2)), 100))->unref(); | |
| 31 canvas->saveLayer(NULL, &paint); | |
| 32 paint.setAntiAlias(true); | |
| 33 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,
| |
| 34 srand(1234); | |
| 35 for (int i = 0; i < 25; ++i) { | |
| 36 int x = rand() % WIDTH; | |
| 37 int y = rand() % HEIGHT; | |
| 38 paint.setColor(rand() % 0x1000000 | 0xFF000000); | |
| 39 paint.setTextSize(SkIntToScalar(rand() % 300)); | |
| 40 canvas->drawText(str, strlen(str), SkIntToScalar(x), | |
| 41 SkIntToScalar(y), paint); | |
| 42 } | |
| 43 canvas->restore(); | |
| 44 } | |
| 45 | |
| 46 private: | |
| 47 typedef SkBenchmark INHERITED; | |
| 48 }; | |
| 49 | |
| 50 /////////////////////////////////////////////////////////////////////////////// | |
| 51 | |
| 52 DEF_BENCH( return new MagnifierBench(p); ) | |
| 53 | |
| OLD | NEW |