| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/debug/rasterize_and_record_benchmark_impl.h" | 5 #include "cc/debug/rasterize_and_record_benchmark_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 float contents_scale, | 30 float contents_scale, |
| 31 size_t repeat_count) | 31 size_t repeat_count) |
| 32 : picture_pile_(picture_pile), | 32 : picture_pile_(picture_pile), |
| 33 content_rect_(content_rect), | 33 content_rect_(content_rect), |
| 34 contents_scale_(contents_scale), | 34 contents_scale_(contents_scale), |
| 35 repeat_count_(repeat_count), | 35 repeat_count_(repeat_count), |
| 36 is_solid_color_(false), | 36 is_solid_color_(false), |
| 37 best_time_(base::TimeDelta::Max()) {} | 37 best_time_(base::TimeDelta::Max()) {} |
| 38 | 38 |
| 39 // Overridden from Task: | 39 // Overridden from Task: |
| 40 virtual void RunOnWorkerThread() override { | 40 void RunOnWorkerThread() override { |
| 41 // Parameters for LapTimer. | 41 // Parameters for LapTimer. |
| 42 const int kTimeLimitMillis = 1; | 42 const int kTimeLimitMillis = 1; |
| 43 const int kWarmupRuns = 0; | 43 const int kWarmupRuns = 0; |
| 44 const int kTimeCheckInterval = 1; | 44 const int kTimeCheckInterval = 1; |
| 45 | 45 |
| 46 for (size_t i = 0; i < repeat_count_; ++i) { | 46 for (size_t i = 0; i < repeat_count_; ++i) { |
| 47 // Run for a minimum amount of time to avoid problems with timer | 47 // Run for a minimum amount of time to avoid problems with timer |
| 48 // quantization when the layer is very small. | 48 // quantization when the layer is very small. |
| 49 LapTimer timer(kWarmupRuns, | 49 LapTimer timer(kWarmupRuns, |
| 50 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 50 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 69 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); | 69 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
| 70 if (duration < best_time_) | 70 if (duration < best_time_) |
| 71 best_time_ = duration; | 71 best_time_ = duration; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool IsSolidColor() const { return is_solid_color_; } | 75 bool IsSolidColor() const { return is_solid_color_; } |
| 76 base::TimeDelta GetBestTime() const { return best_time_; } | 76 base::TimeDelta GetBestTime() const { return best_time_; } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 virtual ~BenchmarkRasterTask() {} | 79 ~BenchmarkRasterTask() override {} |
| 80 | 80 |
| 81 PicturePileImpl* picture_pile_; | 81 PicturePileImpl* picture_pile_; |
| 82 gfx::Rect content_rect_; | 82 gfx::Rect content_rect_; |
| 83 float contents_scale_; | 83 float contents_scale_; |
| 84 size_t repeat_count_; | 84 size_t repeat_count_; |
| 85 bool is_solid_color_; | 85 bool is_solid_color_; |
| 86 base::TimeDelta best_time_; | 86 base::TimeDelta best_time_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 class FixedInvalidationPictureLayerTilingClient | 89 class FixedInvalidationPictureLayerTilingClient |
| 90 : public PictureLayerTilingClient { | 90 : public PictureLayerTilingClient { |
| 91 public: | 91 public: |
| 92 FixedInvalidationPictureLayerTilingClient( | 92 FixedInvalidationPictureLayerTilingClient( |
| 93 PictureLayerTilingClient* base_client, | 93 PictureLayerTilingClient* base_client, |
| 94 const Region invalidation) | 94 const Region invalidation) |
| 95 : base_client_(base_client), invalidation_(invalidation) {} | 95 : base_client_(base_client), invalidation_(invalidation) {} |
| 96 | 96 |
| 97 virtual scoped_refptr<Tile> CreateTile( | 97 scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, |
| 98 PictureLayerTiling* tiling, | 98 const gfx::Rect& content_rect) override { |
| 99 const gfx::Rect& content_rect) override { | |
| 100 return base_client_->CreateTile(tiling, content_rect); | 99 return base_client_->CreateTile(tiling, content_rect); |
| 101 } | 100 } |
| 102 | 101 |
| 103 virtual PicturePileImpl* GetPile() override { | 102 PicturePileImpl* GetPile() override { return base_client_->GetPile(); } |
| 104 return base_client_->GetPile(); | |
| 105 } | |
| 106 | 103 |
| 107 virtual gfx::Size CalculateTileSize( | 104 gfx::Size CalculateTileSize(const gfx::Size& content_bounds) const override { |
| 108 const gfx::Size& content_bounds) const override { | |
| 109 return base_client_->CalculateTileSize(content_bounds); | 105 return base_client_->CalculateTileSize(content_bounds); |
| 110 } | 106 } |
| 111 | 107 |
| 112 // This is the only function that returns something different from the base | 108 // This is the only function that returns something different from the base |
| 113 // client. | 109 // client. |
| 114 virtual const Region* GetInvalidation() override { return &invalidation_; } | 110 const Region* GetInvalidation() override { return &invalidation_; } |
| 115 | 111 |
| 116 virtual const PictureLayerTiling* GetTwinTiling( | 112 const PictureLayerTiling* GetTwinTiling( |
| 117 const PictureLayerTiling* tiling) const override { | 113 const PictureLayerTiling* tiling) const override { |
| 118 return base_client_->GetTwinTiling(tiling); | 114 return base_client_->GetTwinTiling(tiling); |
| 119 } | 115 } |
| 120 | 116 |
| 121 virtual PictureLayerTiling* GetRecycledTwinTiling( | 117 PictureLayerTiling* GetRecycledTwinTiling( |
| 122 const PictureLayerTiling* tiling) override { | 118 const PictureLayerTiling* tiling) override { |
| 123 return base_client_->GetRecycledTwinTiling(tiling); | 119 return base_client_->GetRecycledTwinTiling(tiling); |
| 124 } | 120 } |
| 125 | 121 |
| 126 virtual size_t GetMaxTilesForInterestArea() const override { | 122 size_t GetMaxTilesForInterestArea() const override { |
| 127 return base_client_->GetMaxTilesForInterestArea(); | 123 return base_client_->GetMaxTilesForInterestArea(); |
| 128 } | 124 } |
| 129 | 125 |
| 130 virtual float GetSkewportTargetTimeInSeconds() const override { | 126 float GetSkewportTargetTimeInSeconds() const override { |
| 131 return base_client_->GetSkewportTargetTimeInSeconds(); | 127 return base_client_->GetSkewportTargetTimeInSeconds(); |
| 132 } | 128 } |
| 133 | 129 |
| 134 virtual int GetSkewportExtrapolationLimitInContentPixels() const override { | 130 int GetSkewportExtrapolationLimitInContentPixels() const override { |
| 135 return base_client_->GetSkewportExtrapolationLimitInContentPixels(); | 131 return base_client_->GetSkewportExtrapolationLimitInContentPixels(); |
| 136 } | 132 } |
| 137 | 133 |
| 138 virtual WhichTree GetTree() const override { return base_client_->GetTree(); } | 134 WhichTree GetTree() const override { return base_client_->GetTree(); } |
| 139 | 135 |
| 140 virtual bool RequiresHighResToDraw() const override { | 136 bool RequiresHighResToDraw() const override { |
| 141 return base_client_->RequiresHighResToDraw(); | 137 return base_client_->RequiresHighResToDraw(); |
| 142 } | 138 } |
| 143 | 139 |
| 144 private: | 140 private: |
| 145 PictureLayerTilingClient* base_client_; | 141 PictureLayerTilingClient* base_client_; |
| 146 Region invalidation_; | 142 Region invalidation_; |
| 147 }; | 143 }; |
| 148 | 144 |
| 149 } // namespace | 145 } // namespace |
| 150 | 146 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 pixels_rasterized_with_non_solid_color(0), | 267 pixels_rasterized_with_non_solid_color(0), |
| 272 pixels_rasterized_as_opaque(0), | 268 pixels_rasterized_as_opaque(0), |
| 273 total_layers(0), | 269 total_layers(0), |
| 274 total_picture_layers(0), | 270 total_picture_layers(0), |
| 275 total_picture_layers_with_no_content(0), | 271 total_picture_layers_with_no_content(0), |
| 276 total_picture_layers_off_screen(0) {} | 272 total_picture_layers_off_screen(0) {} |
| 277 | 273 |
| 278 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} | 274 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} |
| 279 | 275 |
| 280 } // namespace cc | 276 } // namespace cc |
| OLD | NEW |