OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/trace_event/trace_event_argument.h" | 15 #include "base/trace_event/trace_event_argument.h" |
16 #include "cc/base/histograms.h" | |
17 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
18 #include "cc/debug/frame_viewer_instrumentation.h" | 17 #include "cc/debug/frame_viewer_instrumentation.h" |
19 #include "cc/debug/traced_value.h" | 18 #include "cc/debug/traced_value.h" |
20 #include "cc/layers/picture_layer_impl.h" | 19 #include "cc/layers/picture_layer_impl.h" |
21 #include "cc/resources/raster_buffer.h" | 20 #include "cc/resources/raster_buffer.h" |
22 #include "cc/resources/tile.h" | 21 #include "cc/resources/tile.h" |
23 #include "cc/resources/tile_task_runner.h" | 22 #include "cc/resources/tile_task_runner.h" |
24 #include "ui/gfx/geometry/rect_conversions.h" | 23 #include "ui/gfx/geometry/rect_conversions.h" |
25 | 24 |
26 namespace cc { | 25 namespace cc { |
27 namespace { | 26 namespace { |
28 | 27 |
29 // Flag to indicate whether we should try and detect that | 28 // Flag to indicate whether we should try and detect that |
30 // a tile is of solid color. | 29 // a tile is of solid color. |
31 const bool kUseColorEstimator = true; | 30 const bool kUseColorEstimator = true; |
32 | 31 |
33 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | |
34 ScopedRasterTaskTimer, | |
35 "Compositing.RasterTask.RasterUs", | |
36 "Compositing.RasterTask.RasterPixelsPerMs"); | |
37 | |
38 class RasterTaskImpl : public RasterTask { | 32 class RasterTaskImpl : public RasterTask { |
39 public: | 33 public: |
40 RasterTaskImpl( | 34 RasterTaskImpl( |
41 const Resource* resource, | 35 const Resource* resource, |
42 RasterSource* raster_source, | 36 RasterSource* raster_source, |
43 const gfx::Rect& content_rect, | 37 const gfx::Rect& content_rect, |
44 float contents_scale, | 38 float contents_scale, |
45 TileResolution tile_resolution, | 39 TileResolution tile_resolution, |
46 int layer_id, | 40 int layer_id, |
47 const void* tile_id, | 41 const void* tile_id, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 96 |
103 raster_source->PerformSolidColorAnalysis(content_rect_, contents_scale_, | 97 raster_source->PerformSolidColorAnalysis(content_rect_, contents_scale_, |
104 &analysis_); | 98 &analysis_); |
105 // Clear the flag if we're not using the estimator. | 99 // Clear the flag if we're not using the estimator. |
106 analysis_.is_solid_color &= kUseColorEstimator; | 100 analysis_.is_solid_color &= kUseColorEstimator; |
107 } | 101 } |
108 | 102 |
109 void Raster(const RasterSource* raster_source) { | 103 void Raster(const RasterSource* raster_source) { |
110 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 104 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
111 tile_id_, tile_resolution_, source_frame_number_, layer_id_); | 105 tile_id_, tile_resolution_, source_frame_number_, layer_id_); |
112 ScopedRasterTaskTimer timer; | |
113 timer.SetArea(content_rect_.size().GetArea()); | |
114 | 106 |
115 DCHECK(raster_source); | 107 DCHECK(raster_source); |
116 | 108 |
117 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 109 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
118 contents_scale_); | 110 contents_scale_); |
119 } | 111 } |
120 | 112 |
121 RasterSource::SolidColorAnalysis analysis_; | 113 RasterSource::SolidColorAnalysis analysis_; |
122 scoped_refptr<RasterSource> raster_source_; | 114 scoped_refptr<RasterSource> raster_source_; |
123 gfx::Rect content_rect_; | 115 gfx::Rect content_rect_; |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 result -= other; | 970 result -= other; |
979 return result; | 971 return result; |
980 } | 972 } |
981 | 973 |
982 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 974 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
983 return memory_bytes_ > limit.memory_bytes_ || | 975 return memory_bytes_ > limit.memory_bytes_ || |
984 resource_count_ > limit.resource_count_; | 976 resource_count_ > limit.resource_count_; |
985 } | 977 } |
986 | 978 |
987 } // namespace cc | 979 } // namespace cc |
OLD | NEW |