| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Benchmark.h" | 7 #include "Benchmark.h" |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| 11 #include "SkString.h" | 11 #include "SkString.h" |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * This bench measures the rendering time of SkCanvas::drawBitmap with different
anti-aliasing / | 14 * This bench measures the rendering time of SkCanvas::drawBitmap with different
anti-aliasing / |
| 15 * matrix combinations. | 15 * matrix combinations. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 class DrawBitmapAABench : public Benchmark { | 18 class DrawBitmapAABench : public Benchmark { |
| 19 public: | 19 public: |
| 20 DrawBitmapAABench(bool doAA, const SkMatrix& matrix, const char name[]) | 20 DrawBitmapAABench(bool doAA, const SkMatrix& matrix, const char name[]) |
| 21 : fMatrix(matrix) | 21 : fMatrix(matrix) |
| 22 , fName("draw_bitmap_") { | 22 , fName("draw_bitmap_") { |
| 23 | 23 |
| 24 fPaint.setAntiAlias(doAA); | 24 fPaint.setAntiAlias(doAA); |
| 25 // Most clients use filtering, so let's focus on this for now. |
| 26 fPaint.setFilterQuality(kLow_SkFilterQuality); |
| 25 fName.appendf("%s_%s", doAA ? "aa" : "noaa", name); | 27 fName.appendf("%s_%s", doAA ? "aa" : "noaa", name); |
| 26 } | 28 } |
| 27 | 29 |
| 28 protected: | 30 protected: |
| 29 const char* onGetName() override { | 31 const char* onGetName() override { |
| 30 return fName.c_str(); | 32 return fName.c_str(); |
| 31 } | 33 } |
| 32 | 34 |
| 33 void onPreDraw() override { | 35 void onPreDraw() override { |
| 34 fBitmap.allocN32Pixels(200, 200); | 36 fBitmap.allocN32Pixels(200, 200); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1.17f), "scale
"); ) | 71 DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1.17f), "scale
"); ) |
| 70 | 72 |
| 71 DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeTrans(17.5f, 17.5f),
"translate"); ) | 73 DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeTrans(17.5f, 17.5f),
"translate"); ) |
| 72 | 74 |
| 73 DEF_BENCH( | 75 DEF_BENCH( |
| 74 SkMatrix m; | 76 SkMatrix m; |
| 75 m.reset(); | 77 m.reset(); |
| 76 m.preRotate(15); | 78 m.preRotate(15); |
| 77 return new DrawBitmapAABench(true, m, "rotate"); | 79 return new DrawBitmapAABench(true, m, "rotate"); |
| 78 ) | 80 ) |
| OLD | NEW |