| 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 | 7 |
| 8 #include "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| 11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 #include "SkString.h" | 13 #include "SkString.h" |
| 14 #include "SkBlurMask.h" | 14 #include "SkBlurMask.h" |
| 15 | 15 |
| 16 class BitmapScaleBench: public SkBenchmark { | 16 class BitmapScaleBench: public SkBenchmark { |
| 17 int fLoopCount; | 17 int fLoopCount; |
| 18 int fInputSize; | 18 int fInputSize; |
| 19 int fOutputSize; | 19 int fOutputSize; |
| 20 SkString fName; | 20 SkString fName; |
| 21 | 21 |
| 22 public: | 22 public: |
| 23 BitmapScaleBench(void *param, int is, int os) : INHERITED(param) { | 23 BitmapScaleBench(void *param, int is, int os) : INHERITED(param) { |
| 24 fInputSize = is; | 24 fInputSize = is; |
| 25 fOutputSize = os; | 25 fOutputSize = os; |
| 26 | 26 |
| 27 fLoopCount = 100; | 27 fLoopCount = 20; |
| 28 } | 28 } |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 | 31 |
| 32 SkBitmap fInputBitmap, fOutputBitmap; | 32 SkBitmap fInputBitmap, fOutputBitmap; |
| 33 SkMatrix fMatrix; | 33 SkMatrix fMatrix; |
| 34 | 34 |
| 35 virtual const char* onGetName() { | 35 virtual const char* onGetName() { |
| 36 return fName.c_str(); | 36 return fName.c_str(); |
| 37 } | 37 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 SkPaint paint; | 97 SkPaint paint; |
| 98 | 98 |
| 99 paint.setFlags( SkPaint::kHighQualityFilterBitmap_Flag | SkPaint::kFilte
rBitmap_Flag ); | 99 paint.setFlags( SkPaint::kHighQualityFilterBitmap_Flag | SkPaint::kFilte
rBitmap_Flag ); |
| 100 | 100 |
| 101 canvas.drawBitmapMatrix( fInputBitmap, fMatrix, &paint ); | 101 canvas.drawBitmapMatrix( fInputBitmap, fMatrix, &paint ); |
| 102 } | 102 } |
| 103 private: | 103 private: |
| 104 typedef BitmapScaleBench INHERITED; | 104 typedef BitmapScaleBench INHERITED; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class BitmapDirectScaleBench: public BitmapScaleBench { | |
| 108 public: | |
| 109 BitmapDirectScaleBench(void *param, int is, int os) : INHERITED(param, is, o
s) { | |
| 110 setName( "direct" ); | |
| 111 } | |
| 112 protected: | |
| 113 virtual void doScaleImage() SK_OVERRIDE { | |
| 114 fInputBitmap.scale( &fOutputBitmap ); | |
| 115 } | |
| 116 private: | |
| 117 typedef BitmapScaleBench INHERITED; | |
| 118 }; | |
| 119 | |
| 120 | |
| 121 DEF_BENCH(return new BitmapFilterScaleBench(p, 10, 90);) | 107 DEF_BENCH(return new BitmapFilterScaleBench(p, 10, 90);) |
| 122 DEF_BENCH(return new BitmapFilterScaleBench(p, 30, 90);) | 108 DEF_BENCH(return new BitmapFilterScaleBench(p, 30, 90);) |
| 123 DEF_BENCH(return new BitmapFilterScaleBench(p, 80, 90);) | 109 DEF_BENCH(return new BitmapFilterScaleBench(p, 80, 90);) |
| 124 // DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 90);) | 110 DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 90);) |
| 125 // DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 80);) | 111 DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 80);) |
| 126 // DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 30);) | 112 DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 30);) |
| 127 // DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 10);) | 113 DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 10);) |
| 128 | 114 DEF_BENCH(return new BitmapFilterScaleBench(p, 256, 64);) |
| 129 DEF_BENCH(return new BitmapDirectScaleBench(p, 10, 90);) | 115 DEF_BENCH(return new BitmapFilterScaleBench(p, 64, 256);) |
| 130 DEF_BENCH(return new BitmapDirectScaleBench(p, 30, 90);) | |
| 131 DEF_BENCH(return new BitmapDirectScaleBench(p, 80, 90);) | |
| 132 // DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 90);) | |
| 133 // DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 80);) | |
| 134 // DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 30);) | |
| 135 // DEF_BENCH(return new BitmapDirectScaleBench(p, 90, 10);) | |
| OLD | NEW |