| 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 "Benchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 fOutputSize = os; | 25 fOutputSize = os; |
| 26 | 26 |
| 27 fLoopCount = 20; | 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 const char* onGetName() override { |
| 36 return fName.c_str(); | 36 return fName.c_str(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 int inputSize() const { | 39 int inputSize() const { |
| 40 return fInputSize; | 40 return fInputSize; |
| 41 } | 41 } |
| 42 | 42 |
| 43 int outputSize() const { | 43 int outputSize() const { |
| 44 return fOutputSize; | 44 return fOutputSize; |
| 45 } | 45 } |
| 46 | 46 |
| 47 float scale() const { | 47 float scale() const { |
| 48 return float(outputSize())/inputSize(); | 48 return float(outputSize())/inputSize(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 SkIPoint onGetSize() override { | 51 SkIPoint onGetSize() override { |
| 52 return SkIPoint::Make( fOutputSize, fOutputSize ); | 52 return SkIPoint::Make( fOutputSize, fOutputSize ); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void setName(const char * name) { | 55 void setName(const char * name) { |
| 56 fName.printf( "bitmap_scale_%s_%d_%d", name, fInputSize, fOutputSize ); | 56 fName.printf( "bitmap_scale_%s_%d_%d", name, fInputSize, fOutputSize ); |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual void onPreDraw() { | 59 void onPreDraw() override { |
| 60 fInputBitmap.allocN32Pixels(fInputSize, fInputSize, true); | 60 fInputBitmap.allocN32Pixels(fInputSize, fInputSize, true); |
| 61 fInputBitmap.eraseColor(SK_ColorWHITE); | 61 fInputBitmap.eraseColor(SK_ColorWHITE); |
| 62 | 62 |
| 63 fOutputBitmap.allocN32Pixels(fOutputSize, fOutputSize, true); | 63 fOutputBitmap.allocN32Pixels(fOutputSize, fOutputSize, true); |
| 64 | 64 |
| 65 fMatrix.setScale( scale(), scale() ); | 65 fMatrix.setScale( scale(), scale() ); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void onDraw(const int loops, SkCanvas*) { | 68 void onDraw(const int loops, SkCanvas*) override { |
| 69 SkPaint paint; | 69 SkPaint paint; |
| 70 this->setupPaint(&paint); | 70 this->setupPaint(&paint); |
| 71 | 71 |
| 72 preBenchSetup(); | 72 preBenchSetup(); |
| 73 | 73 |
| 74 for (int i = 0; i < loops; i++) { | 74 for (int i = 0; i < loops; i++) { |
| 75 doScaleImage(); | 75 doScaleImage(); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 103 | 103 |
| 104 DEF_BENCH(return new BitmapFilterScaleBench(10, 90);) | 104 DEF_BENCH(return new BitmapFilterScaleBench(10, 90);) |
| 105 DEF_BENCH(return new BitmapFilterScaleBench(30, 90);) | 105 DEF_BENCH(return new BitmapFilterScaleBench(30, 90);) |
| 106 DEF_BENCH(return new BitmapFilterScaleBench(80, 90);) | 106 DEF_BENCH(return new BitmapFilterScaleBench(80, 90);) |
| 107 DEF_BENCH(return new BitmapFilterScaleBench(90, 90);) | 107 DEF_BENCH(return new BitmapFilterScaleBench(90, 90);) |
| 108 DEF_BENCH(return new BitmapFilterScaleBench(90, 80);) | 108 DEF_BENCH(return new BitmapFilterScaleBench(90, 80);) |
| 109 DEF_BENCH(return new BitmapFilterScaleBench(90, 30);) | 109 DEF_BENCH(return new BitmapFilterScaleBench(90, 30);) |
| 110 DEF_BENCH(return new BitmapFilterScaleBench(90, 10);) | 110 DEF_BENCH(return new BitmapFilterScaleBench(90, 10);) |
| 111 DEF_BENCH(return new BitmapFilterScaleBench(256, 64);) | 111 DEF_BENCH(return new BitmapFilterScaleBench(256, 64);) |
| 112 DEF_BENCH(return new BitmapFilterScaleBench(64, 256);) | 112 DEF_BENCH(return new BitmapFilterScaleBench(64, 256);) |
| OLD | NEW |