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/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/numerics/safe_conversions.h" | 20 #include "base/numerics/safe_conversions.h" |
| 21 #include "base/optional.h" |
21 #include "base/threading/thread_checker.h" | 22 #include "base/threading/thread_checker.h" |
22 #include "base/trace_event/trace_event_argument.h" | 23 #include "base/trace_event/trace_event_argument.h" |
23 #include "cc/base/histograms.h" | 24 #include "cc/base/histograms.h" |
24 #include "cc/debug/devtools_instrumentation.h" | 25 #include "cc/debug/devtools_instrumentation.h" |
25 #include "cc/debug/frame_viewer_instrumentation.h" | 26 #include "cc/debug/frame_viewer_instrumentation.h" |
26 #include "cc/debug/traced_value.h" | 27 #include "cc/debug/traced_value.h" |
27 #include "cc/layers/picture_layer_impl.h" | 28 #include "cc/layers/picture_layer_impl.h" |
28 #include "cc/raster/raster_buffer.h" | 29 #include "cc/raster/raster_buffer.h" |
29 #include "cc/raster/task_category.h" | 30 #include "cc/raster/task_category.h" |
30 #include "cc/tiles/tile.h" | 31 #include "cc/tiles/tile.h" |
31 #include "ui/gfx/geometry/rect_conversions.h" | 32 #include "ui/gfx/geometry/rect_conversions.h" |
32 | 33 |
33 namespace cc { | 34 namespace cc { |
34 namespace { | 35 namespace { |
35 | 36 |
36 // Flag to indicate whether we should try and detect that | 37 // Flag to indicate whether we should try and detect that |
37 // a tile is of solid color. | 38 // a tile is of solid color. |
38 const bool kUseColorEstimator = true; | 39 const bool kUseColorEstimator = true; |
39 | 40 |
| 41 // TODO(enne): remove this histogram and its monitoring in M58 once there is |
| 42 // enough new data from the other two raster task timers. |
40 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | 43 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
41 ScopedRasterTaskTimer, | 44 ScopedGeneralRasterTaskTimer, |
42 "Compositing.%s.RasterTask.RasterUs", | 45 "Compositing.%s.RasterTask.RasterUs", |
43 "Compositing.%s.RasterTask.RasterPixelsPerMs"); | 46 "Compositing.%s.RasterTask.RasterPixelsPerMs"); |
44 | 47 |
| 48 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
| 49 ScopedSoftwareRasterTaskTimer, |
| 50 "Compositing.%s.RasterTask.RasterUs.Software", |
| 51 "Compositing.%s.RasterTask.RasterPixelsPerMs.Software"); |
| 52 |
| 53 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
| 54 ScopedGpuRasterTaskTimer, |
| 55 "Compositing.%s.RasterTask.RasterUs.Gpu", |
| 56 "Compositing.%s.RasterTask.RasterPixelsPerMs.Gpu"); |
| 57 |
| 58 class ScopedRasterTaskTimer { |
| 59 public: |
| 60 explicit ScopedRasterTaskTimer(bool use_gpu_rasterization) { |
| 61 if (use_gpu_rasterization) |
| 62 gpu_timer_.emplace(); |
| 63 else |
| 64 software_timer_.emplace(); |
| 65 } |
| 66 |
| 67 void SetArea(int area) { |
| 68 general_timer_.SetArea(area); |
| 69 if (software_timer_) |
| 70 software_timer_->SetArea(area); |
| 71 if (gpu_timer_) |
| 72 gpu_timer_->SetArea(area); |
| 73 } |
| 74 |
| 75 private: |
| 76 ScopedGeneralRasterTaskTimer general_timer_; |
| 77 base::Optional<ScopedSoftwareRasterTaskTimer> software_timer_; |
| 78 base::Optional<ScopedGpuRasterTaskTimer> gpu_timer_; |
| 79 }; |
| 80 |
45 class RasterTaskImpl : public TileTask { | 81 class RasterTaskImpl : public TileTask { |
46 public: | 82 public: |
47 RasterTaskImpl(TileManager* tile_manager, | 83 RasterTaskImpl(TileManager* tile_manager, |
48 Tile* tile, | 84 Tile* tile, |
49 Resource* resource, | 85 Resource* resource, |
50 scoped_refptr<RasterSource> raster_source, | 86 scoped_refptr<RasterSource> raster_source, |
51 const RasterSource::PlaybackSettings& playback_settings, | 87 const RasterSource::PlaybackSettings& playback_settings, |
52 TileResolution tile_resolution, | 88 TileResolution tile_resolution, |
53 gfx::Rect invalidated_rect, | 89 gfx::Rect invalidated_rect, |
54 uint64_t source_prepare_tiles_id, | 90 uint64_t source_prepare_tiles_id, |
55 std::unique_ptr<RasterBuffer> raster_buffer, | 91 std::unique_ptr<RasterBuffer> raster_buffer, |
56 TileTask::Vector* dependencies, | 92 TileTask::Vector* dependencies, |
57 bool supports_concurrent_execution) | 93 bool is_gpu_rasterization) |
58 : TileTask(supports_concurrent_execution, dependencies), | 94 : TileTask(!is_gpu_rasterization, dependencies), |
59 tile_manager_(tile_manager), | 95 tile_manager_(tile_manager), |
60 tile_(tile), | 96 tile_(tile), |
61 resource_(resource), | 97 resource_(resource), |
62 raster_source_(std::move(raster_source)), | 98 raster_source_(std::move(raster_source)), |
63 content_rect_(tile->content_rect()), | 99 content_rect_(tile->content_rect()), |
64 invalid_content_rect_(invalidated_rect), | 100 invalid_content_rect_(invalidated_rect), |
65 contents_scale_(tile->contents_scale()), | 101 contents_scale_(tile->contents_scale()), |
66 playback_settings_(playback_settings), | 102 playback_settings_(playback_settings), |
67 tile_resolution_(tile_resolution), | 103 tile_resolution_(tile_resolution), |
68 layer_id_(tile->layer_id()), | 104 layer_id_(tile->layer_id()), |
69 source_prepare_tiles_id_(source_prepare_tiles_id), | 105 source_prepare_tiles_id_(source_prepare_tiles_id), |
70 tile_tracing_id_(static_cast<void*>(tile)), | 106 tile_tracing_id_(static_cast<void*>(tile)), |
71 new_content_id_(tile->id()), | 107 new_content_id_(tile->id()), |
72 source_frame_number_(tile->source_frame_number()), | 108 source_frame_number_(tile->source_frame_number()), |
| 109 is_gpu_rasterization_(is_gpu_rasterization), |
73 raster_buffer_(std::move(raster_buffer)) { | 110 raster_buffer_(std::move(raster_buffer)) { |
74 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 111 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
75 } | 112 } |
76 | 113 |
77 // Overridden from Task: | 114 // Overridden from Task: |
78 void RunOnWorkerThread() override { | 115 void RunOnWorkerThread() override { |
79 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 116 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
80 "source_prepare_tiles_id", source_prepare_tiles_id_); | 117 "source_prepare_tiles_id", source_prepare_tiles_id_); |
81 | 118 |
82 DCHECK(raster_source_.get()); | 119 DCHECK(raster_source_.get()); |
83 DCHECK(raster_buffer_); | 120 DCHECK(raster_buffer_); |
84 | 121 |
85 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 122 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
86 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); | 123 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); |
87 ScopedRasterTaskTimer timer; | 124 ScopedRasterTaskTimer timer(is_gpu_rasterization_); |
88 timer.SetArea(content_rect_.size().GetArea()); | 125 timer.SetArea(content_rect_.size().GetArea()); |
89 | 126 |
90 DCHECK(raster_source_); | 127 DCHECK(raster_source_); |
91 | 128 |
92 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 129 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
93 invalid_content_rect_, new_content_id_, | 130 invalid_content_rect_, new_content_id_, |
94 contents_scale_, playback_settings_); | 131 contents_scale_, playback_settings_); |
95 } | 132 } |
96 | 133 |
97 // Overridden from TileTask: | 134 // Overridden from TileTask: |
(...skipping 28 matching lines...) Expand all Loading... |
126 gfx::Rect content_rect_; | 163 gfx::Rect content_rect_; |
127 gfx::Rect invalid_content_rect_; | 164 gfx::Rect invalid_content_rect_; |
128 float contents_scale_; | 165 float contents_scale_; |
129 RasterSource::PlaybackSettings playback_settings_; | 166 RasterSource::PlaybackSettings playback_settings_; |
130 TileResolution tile_resolution_; | 167 TileResolution tile_resolution_; |
131 int layer_id_; | 168 int layer_id_; |
132 uint64_t source_prepare_tiles_id_; | 169 uint64_t source_prepare_tiles_id_; |
133 void* tile_tracing_id_; | 170 void* tile_tracing_id_; |
134 uint64_t new_content_id_; | 171 uint64_t new_content_id_; |
135 int source_frame_number_; | 172 int source_frame_number_; |
| 173 bool is_gpu_rasterization_; |
136 std::unique_ptr<RasterBuffer> raster_buffer_; | 174 std::unique_ptr<RasterBuffer> raster_buffer_; |
137 | 175 |
138 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 176 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
139 }; | 177 }; |
140 | 178 |
141 TaskCategory TaskCategoryForTileTask(TileTask* task, | 179 TaskCategory TaskCategoryForTileTask(TileTask* task, |
142 bool use_foreground_category) { | 180 bool use_foreground_category) { |
143 if (!task->supports_concurrent_execution()) | 181 if (!task->supports_concurrent_execution()) |
144 return TASK_CATEGORY_NONCONCURRENT_FOREGROUND; | 182 return TASK_CATEGORY_NONCONCURRENT_FOREGROUND; |
145 | 183 |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 } | 1004 } |
967 | 1005 |
968 // We can skip the image hijack canvas if we have no images. | 1006 // We can skip the image hijack canvas if we have no images. |
969 playback_settings.use_image_hijack_canvas = !images.empty(); | 1007 playback_settings.use_image_hijack_canvas = !images.empty(); |
970 | 1008 |
971 // Get the tasks for the required images. | 1009 // Get the tasks for the required images. |
972 ImageDecodeController::TracingInfo tracing_info( | 1010 ImageDecodeController::TracingInfo tracing_info( |
973 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1011 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
974 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); | 1012 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); |
975 | 1013 |
976 bool supports_concurrent_execution = !use_gpu_rasterization_; | |
977 std::unique_ptr<RasterBuffer> raster_buffer = | 1014 std::unique_ptr<RasterBuffer> raster_buffer = |
978 raster_buffer_provider_->AcquireBufferForRaster( | 1015 raster_buffer_provider_->AcquireBufferForRaster( |
979 resource, resource_content_id, tile->invalidated_id()); | 1016 resource, resource_content_id, tile->invalidated_id()); |
980 return make_scoped_refptr(new RasterTaskImpl( | 1017 return make_scoped_refptr(new RasterTaskImpl( |
981 this, tile, resource, prioritized_tile.raster_source(), playback_settings, | 1018 this, tile, resource, prioritized_tile.raster_source(), playback_settings, |
982 prioritized_tile.priority().resolution, invalidated_rect, | 1019 prioritized_tile.priority().resolution, invalidated_rect, |
983 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, | 1020 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, |
984 supports_concurrent_execution)); | 1021 use_gpu_rasterization_)); |
985 } | 1022 } |
986 | 1023 |
987 void TileManager::OnRasterTaskCompleted( | 1024 void TileManager::OnRasterTaskCompleted( |
988 std::unique_ptr<RasterBuffer> raster_buffer, | 1025 std::unique_ptr<RasterBuffer> raster_buffer, |
989 Tile* tile, | 1026 Tile* tile, |
990 Resource* resource, | 1027 Resource* resource, |
991 bool was_canceled) { | 1028 bool was_canceled) { |
992 DCHECK(tile); | 1029 DCHECK(tile); |
993 DCHECK(tiles_.find(tile->id()) != tiles_.end()); | 1030 DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
994 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); | 1031 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 all_tile_tasks_completed = false; | 1366 all_tile_tasks_completed = false; |
1330 did_notify_all_tile_tasks_completed = false; | 1367 did_notify_all_tile_tasks_completed = false; |
1331 } | 1368 } |
1332 | 1369 |
1333 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1370 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
1334 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1371 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
1335 PrioritizedWorkToSchedule&& other) = default; | 1372 PrioritizedWorkToSchedule&& other) = default; |
1336 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1373 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
1337 | 1374 |
1338 } // namespace cc | 1375 } // namespace cc |
OLD | NEW |