| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "Benchmark.h" |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkColor.h" | 9 #include "SkColor.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| 11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
| 12 #include "SkPictureRecorder.h" | 12 #include "SkPictureRecorder.h" |
| 13 #include "SkPoint.h" | 13 #include "SkPoint.h" |
| 14 #include "SkRect.h" | 14 #include "SkRect.h" |
| 15 #include "SkString.h" | 15 #include "SkString.h" |
| 16 | 16 |
| 17 // This is designed to emulate about 4 screens of textual content | 17 // This is designed to emulate about 4 screens of textual content |
| 18 | 18 |
| 19 | 19 |
| 20 class PicturePlaybackBench : public SkBenchmark { | 20 class PicturePlaybackBench : public Benchmark { |
| 21 public: | 21 public: |
| 22 PicturePlaybackBench(const char name[]) { | 22 PicturePlaybackBench(const char name[]) { |
| 23 fName.printf("picture_playback_%s", name); | 23 fName.printf("picture_playback_%s", name); |
| 24 fPictureWidth = SkIntToScalar(PICTURE_WIDTH); | 24 fPictureWidth = SkIntToScalar(PICTURE_WIDTH); |
| 25 fPictureHeight = SkIntToScalar(PICTURE_HEIGHT); | 25 fPictureHeight = SkIntToScalar(PICTURE_HEIGHT); |
| 26 fTextSize = SkIntToScalar(TEXT_SIZE); | 26 fTextSize = SkIntToScalar(TEXT_SIZE); |
| 27 } | 27 } |
| 28 | 28 |
| 29 enum { | 29 enum { |
| 30 PICTURE_WIDTH = 1000, | 30 PICTURE_WIDTH = 1000, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 56 SkIPoint canvasSize = onGetSize(); | 56 SkIPoint canvasSize = onGetSize(); |
| 57 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/N), | 57 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/N), |
| 58 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/N)); | 58 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/N)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 SkString fName; | 61 SkString fName; |
| 62 SkScalar fPictureWidth; | 62 SkScalar fPictureWidth; |
| 63 SkScalar fPictureHeight; | 63 SkScalar fPictureHeight; |
| 64 SkScalar fTextSize; | 64 SkScalar fTextSize; |
| 65 private: | 65 private: |
| 66 typedef SkBenchmark INHERITED; | 66 typedef Benchmark INHERITED; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 | 69 |
| 70 class TextPlaybackBench : public PicturePlaybackBench { | 70 class TextPlaybackBench : public PicturePlaybackBench { |
| 71 public: | 71 public: |
| 72 TextPlaybackBench() : INHERITED("drawText") { } | 72 TextPlaybackBench() : INHERITED("drawText") { } |
| 73 protected: | 73 protected: |
| 74 virtual void recordCanvas(SkCanvas* canvas) SK_OVERRIDE { | 74 virtual void recordCanvas(SkCanvas* canvas) SK_OVERRIDE { |
| 75 SkPaint paint; | 75 SkPaint paint; |
| 76 paint.setTextSize(fTextSize); | 76 paint.setTextSize(fTextSize); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool fDrawPosH; | 132 bool fDrawPosH; |
| 133 typedef PicturePlaybackBench INHERITED; | 133 typedef PicturePlaybackBench INHERITED; |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 | 136 |
| 137 /////////////////////////////////////////////////////////////////////////////// | 137 /////////////////////////////////////////////////////////////////////////////// |
| 138 | 138 |
| 139 DEF_BENCH( return new TextPlaybackBench(); ) | 139 DEF_BENCH( return new TextPlaybackBench(); ) |
| 140 DEF_BENCH( return new PosTextPlaybackBench(true); ) | 140 DEF_BENCH( return new PosTextPlaybackBench(true); ) |
| 141 DEF_BENCH( return new PosTextPlaybackBench(false); ) | 141 DEF_BENCH( return new PosTextPlaybackBench(false); ) |
| OLD | NEW |