OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "SkBenchmark.h" | 7 #include "SkBenchmark.h" |
8 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkMagnifierImageFilter.h" | 10 #include "SkMagnifierImageFilter.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 make_checkerboard(); | 31 make_checkerboard(); |
32 fInitialized = true; | 32 fInitialized = true; |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 36 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
37 const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; | 37 const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; |
38 const int h = fIsSmall ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE; | 38 const int h = fIsSmall ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE; |
39 SkPaint paint; | 39 SkPaint paint; |
40 paint.setImageFilter( | 40 paint.setImageFilter( |
41 new SkMagnifierImageFilter( | 41 SkMagnifierImageFilter::Create( |
42 SkRect::MakeXYWH(SkIntToScalar(w / 4), | 42 SkRect::MakeXYWH(SkIntToScalar(w / 4), |
43 SkIntToScalar(h / 4), | 43 SkIntToScalar(h / 4), |
44 SkIntToScalar(w / 2), | 44 SkIntToScalar(w / 2), |
45 SkIntToScalar(h / 2)), 100))->unref(); | 45 SkIntToScalar(h / 2)), 100))->unref(); |
46 | 46 |
47 for (int i = 0; i < loops; i++) { | 47 for (int i = 0; i < loops; i++) { |
48 canvas->drawBitmap(fCheckerboard, 0, 0, &paint); | 48 canvas->drawBitmap(fCheckerboard, 0, 0, &paint); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
(...skipping 26 matching lines...) Expand all Loading... |
78 bool fIsSmall; | 78 bool fIsSmall; |
79 bool fInitialized; | 79 bool fInitialized; |
80 SkBitmap fCheckerboard; | 80 SkBitmap fCheckerboard; |
81 typedef SkBenchmark INHERITED; | 81 typedef SkBenchmark INHERITED; |
82 }; | 82 }; |
83 | 83 |
84 /////////////////////////////////////////////////////////////////////////////// | 84 /////////////////////////////////////////////////////////////////////////////// |
85 | 85 |
86 DEF_BENCH( return new MagnifierBench(true); ) | 86 DEF_BENCH( return new MagnifierBench(true); ) |
87 DEF_BENCH( return new MagnifierBench(false); ) | 87 DEF_BENCH( return new MagnifierBench(false); ) |
OLD | NEW |