| 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 "SkBitmapSource.h" |   9 #include "SkBitmapSource.h" | 
|  10 #include "SkCanvas.h" |  10 #include "SkCanvas.h" | 
|  11 #include "SkMergeImageFilter.h" |  11 #include "SkMergeImageFilter.h" | 
|  12  |  12  | 
|  13 #define FILTER_WIDTH_SMALL  SkIntToScalar(32) |  13 #define FILTER_WIDTH_SMALL  SkIntToScalar(32) | 
|  14 #define FILTER_HEIGHT_SMALL SkIntToScalar(32) |  14 #define FILTER_HEIGHT_SMALL SkIntToScalar(32) | 
|  15 #define FILTER_WIDTH_LARGE  SkIntToScalar(256) |  15 #define FILTER_WIDTH_LARGE  SkIntToScalar(256) | 
|  16 #define FILTER_HEIGHT_LARGE SkIntToScalar(256) |  16 #define FILTER_HEIGHT_LARGE SkIntToScalar(256) | 
|  17  |  17  | 
|  18 class MergeBench : public Benchmark { |  18 class MergeBench : public Benchmark { | 
|  19 public: |  19 public: | 
|  20     MergeBench(bool small) : fIsSmall(small), fInitialized(false) { } |  20     MergeBench(bool small) : fIsSmall(small), fInitialized(false) { } | 
|  21  |  21  | 
|  22 protected: |  22 protected: | 
|  23     const char* onGetName() SK_OVERRIDE { |  23     const char* onGetName() override { | 
|  24         return fIsSmall ? "merge_small" : "merge_large"; |  24         return fIsSmall ? "merge_small" : "merge_large"; | 
|  25     } |  25     } | 
|  26  |  26  | 
|  27     void onPreDraw() SK_OVERRIDE { |  27     void onPreDraw() override { | 
|  28         if (!fInitialized) { |  28         if (!fInitialized) { | 
|  29             make_bitmap(); |  29             make_bitmap(); | 
|  30             make_checkerboard(); |  30             make_checkerboard(); | 
|  31             fInitialized = true; |  31             fInitialized = true; | 
|  32         } |  32         } | 
|  33     } |  33     } | 
|  34  |  34  | 
|  35     void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |  35     void onDraw(const int loops, SkCanvas* canvas) override { | 
|  36         SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_S
    MALL) : |  36         SkRect r = fIsSmall ? SkRect::MakeWH(FILTER_WIDTH_SMALL, FILTER_HEIGHT_S
    MALL) : | 
|  37                               SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L
    ARGE); |  37                               SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L
    ARGE); | 
|  38         SkPaint paint; |  38         SkPaint paint; | 
|  39         paint.setImageFilter(mergeBitmaps())->unref(); |  39         paint.setImageFilter(mergeBitmaps())->unref(); | 
|  40         for (int i = 0; i < loops; i++) { |  40         for (int i = 0; i < loops; i++) { | 
|  41             canvas->drawRect(r, paint); |  41             canvas->drawRect(r, paint); | 
|  42         } |  42         } | 
|  43     } |  43     } | 
|  44  |  44  | 
|  45 private: |  45 private: | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  88     bool fInitialized; |  88     bool fInitialized; | 
|  89     SkBitmap fBitmap, fCheckerboard; |  89     SkBitmap fBitmap, fCheckerboard; | 
|  90  |  90  | 
|  91     typedef Benchmark INHERITED; |  91     typedef Benchmark INHERITED; | 
|  92 }; |  92 }; | 
|  93  |  93  | 
|  94 /////////////////////////////////////////////////////////////////////////////// |  94 /////////////////////////////////////////////////////////////////////////////// | 
|  95  |  95  | 
|  96 DEF_BENCH( return new MergeBench(true); ) |  96 DEF_BENCH( return new MergeBench(true); ) | 
|  97 DEF_BENCH( return new MergeBench(false); ) |  97 DEF_BENCH( return new MergeBench(false); ) | 
| OLD | NEW |