Chromium Code Reviews| 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> |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "cc/tiles/tile.h" | 30 #include "cc/tiles/tile.h" |
| 31 #include "ui/gfx/geometry/rect_conversions.h" | 31 #include "ui/gfx/geometry/rect_conversions.h" |
| 32 | 32 |
| 33 namespace cc { | 33 namespace cc { |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 // Flag to indicate whether we should try and detect that | 36 // Flag to indicate whether we should try and detect that |
| 37 // a tile is of solid color. | 37 // a tile is of solid color. |
| 38 const bool kUseColorEstimator = true; | 38 const bool kUseColorEstimator = true; |
| 39 | 39 |
| 40 // TODO(enne): remove this eventually once there is enough new data from | |
| 41 // the other two raster task timers. | |
| 40 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | 42 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
| 41 ScopedRasterTaskTimer, | 43 ScopedRasterTaskTimer, |
| 42 "Compositing.%s.RasterTask.RasterUs", | 44 "Compositing.%s.RasterTask.RasterUs", |
|
vmpstr
2016/10/03 17:33:13
This is also being monitored by some system, can y
| |
| 43 "Compositing.%s.RasterTask.RasterPixelsPerMs"); | 45 "Compositing.%s.RasterTask.RasterPixelsPerMs"); |
| 44 | 46 |
| 47 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | |
| 48 ScopedSoftwareRasterTaskTimer, | |
| 49 "Compositing.%s.RasterTask.SoftwareRasterUs", | |
| 50 "Compositing.%s.RasterTask.SoftwareRasterPixelsPerMs"); | |
| 51 | |
| 52 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | |
| 53 ScopedGpuRasterTaskTimer, | |
| 54 "Compositing.%s.RasterTask.GpuRasterUs", | |
| 55 "Compositing.%s.RasterTask.GpuRasterPixelsPerMs"); | |
| 56 | |
| 45 class RasterTaskImpl : public TileTask { | 57 class RasterTaskImpl : public TileTask { |
| 46 public: | 58 public: |
| 47 RasterTaskImpl(TileManager* tile_manager, | 59 RasterTaskImpl(TileManager* tile_manager, |
| 48 Tile* tile, | 60 Tile* tile, |
| 49 Resource* resource, | 61 Resource* resource, |
| 50 scoped_refptr<RasterSource> raster_source, | 62 scoped_refptr<RasterSource> raster_source, |
| 51 const RasterSource::PlaybackSettings& playback_settings, | 63 const RasterSource::PlaybackSettings& playback_settings, |
| 52 TileResolution tile_resolution, | 64 TileResolution tile_resolution, |
| 53 gfx::Rect invalidated_rect, | 65 gfx::Rect invalidated_rect, |
| 54 uint64_t source_prepare_tiles_id, | 66 uint64_t source_prepare_tiles_id, |
| 55 std::unique_ptr<RasterBuffer> raster_buffer, | 67 std::unique_ptr<RasterBuffer> raster_buffer, |
| 56 TileTask::Vector* dependencies, | 68 TileTask::Vector* dependencies, |
| 57 bool supports_concurrent_execution) | 69 bool is_gpu_rasterization) |
| 58 : TileTask(supports_concurrent_execution, dependencies), | 70 : TileTask(!is_gpu_rasterization, dependencies), |
| 59 tile_manager_(tile_manager), | 71 tile_manager_(tile_manager), |
| 60 tile_(tile), | 72 tile_(tile), |
| 61 resource_(resource), | 73 resource_(resource), |
| 62 raster_source_(std::move(raster_source)), | 74 raster_source_(std::move(raster_source)), |
| 63 content_rect_(tile->content_rect()), | 75 content_rect_(tile->content_rect()), |
| 64 invalid_content_rect_(invalidated_rect), | 76 invalid_content_rect_(invalidated_rect), |
| 65 contents_scale_(tile->contents_scale()), | 77 contents_scale_(tile->contents_scale()), |
| 66 playback_settings_(playback_settings), | 78 playback_settings_(playback_settings), |
| 67 tile_resolution_(tile_resolution), | 79 tile_resolution_(tile_resolution), |
| 68 layer_id_(tile->layer_id()), | 80 layer_id_(tile->layer_id()), |
| 69 source_prepare_tiles_id_(source_prepare_tiles_id), | 81 source_prepare_tiles_id_(source_prepare_tiles_id), |
| 70 tile_tracing_id_(static_cast<void*>(tile)), | 82 tile_tracing_id_(static_cast<void*>(tile)), |
| 71 new_content_id_(tile->id()), | 83 new_content_id_(tile->id()), |
| 72 source_frame_number_(tile->source_frame_number()), | 84 source_frame_number_(tile->source_frame_number()), |
| 85 is_gpu_rasterization_(is_gpu_rasterization), | |
| 73 raster_buffer_(std::move(raster_buffer)) { | 86 raster_buffer_(std::move(raster_buffer)) { |
| 74 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 87 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
| 75 } | 88 } |
| 76 | 89 |
| 77 // Overridden from Task: | 90 // Overridden from Task: |
| 78 void RunOnWorkerThread() override { | 91 void RunOnWorkerThread() override { |
| 79 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 92 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
| 80 "source_prepare_tiles_id", source_prepare_tiles_id_); | 93 "source_prepare_tiles_id", source_prepare_tiles_id_); |
| 81 | 94 |
| 82 DCHECK(raster_source_.get()); | 95 DCHECK(raster_source_.get()); |
| 83 DCHECK(raster_buffer_); | 96 DCHECK(raster_buffer_); |
| 84 | 97 |
| 85 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 98 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
| 86 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); | 99 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); |
| 87 ScopedRasterTaskTimer timer; | |
| 88 timer.SetArea(content_rect_.size().GetArea()); | |
| 89 | 100 |
| 90 DCHECK(raster_source_); | 101 DCHECK(raster_source_); |
| 91 | 102 |
| 92 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 103 int area = content_rect_.size().GetArea(); |
| 93 invalid_content_rect_, new_content_id_, | 104 if (is_gpu_rasterization_) { |
|
enne (OOO)
2016/10/03 17:11:36
Scoped timers, what are you going to do. Certainl
vmpstr
2016/10/03 17:33:13
Maybe something like
base::Optional<ScopedGpuRast
| |
| 94 contents_scale_, playback_settings_); | 105 ScopedRasterTaskTimer timer; |
| 106 ScopedGpuRasterTaskTimer timer_gpu; | |
| 107 timer.SetArea(area); | |
| 108 timer_gpu.SetArea(area); | |
| 109 raster_buffer_->Playback(raster_source_.get(), content_rect_, | |
| 110 invalid_content_rect_, new_content_id_, | |
| 111 contents_scale_, playback_settings_); | |
| 112 } else { | |
| 113 ScopedRasterTaskTimer timer; | |
| 114 ScopedSoftwareRasterTaskTimer timer_software; | |
| 115 timer.SetArea(area); | |
| 116 timer_software.SetArea(area); | |
| 117 raster_buffer_->Playback(raster_source_.get(), content_rect_, | |
| 118 invalid_content_rect_, new_content_id_, | |
| 119 contents_scale_, playback_settings_); | |
| 120 } | |
| 95 } | 121 } |
| 96 | 122 |
| 97 // Overridden from TileTask: | 123 // Overridden from TileTask: |
| 98 void OnTaskCompleted() override { | 124 void OnTaskCompleted() override { |
| 99 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 125 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
| 100 | 126 |
| 101 // Here calling state().IsCanceled() is thread-safe, because this task is | 127 // Here calling state().IsCanceled() is thread-safe, because this task is |
| 102 // already concluded as FINISHED or CANCELLED and no longer will be worked | 128 // already concluded as FINISHED or CANCELLED and no longer will be worked |
| 103 // upon by task graph runner. | 129 // upon by task graph runner. |
| 104 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_, | 130 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 126 gfx::Rect content_rect_; | 152 gfx::Rect content_rect_; |
| 127 gfx::Rect invalid_content_rect_; | 153 gfx::Rect invalid_content_rect_; |
| 128 float contents_scale_; | 154 float contents_scale_; |
| 129 RasterSource::PlaybackSettings playback_settings_; | 155 RasterSource::PlaybackSettings playback_settings_; |
| 130 TileResolution tile_resolution_; | 156 TileResolution tile_resolution_; |
| 131 int layer_id_; | 157 int layer_id_; |
| 132 uint64_t source_prepare_tiles_id_; | 158 uint64_t source_prepare_tiles_id_; |
| 133 void* tile_tracing_id_; | 159 void* tile_tracing_id_; |
| 134 uint64_t new_content_id_; | 160 uint64_t new_content_id_; |
| 135 int source_frame_number_; | 161 int source_frame_number_; |
| 162 bool is_gpu_rasterization_; | |
| 136 std::unique_ptr<RasterBuffer> raster_buffer_; | 163 std::unique_ptr<RasterBuffer> raster_buffer_; |
| 137 | 164 |
| 138 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 165 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
| 139 }; | 166 }; |
| 140 | 167 |
| 141 TaskCategory TaskCategoryForTileTask(TileTask* task, | 168 TaskCategory TaskCategoryForTileTask(TileTask* task, |
| 142 bool use_foreground_category) { | 169 bool use_foreground_category) { |
| 143 if (!task->supports_concurrent_execution()) | 170 if (!task->supports_concurrent_execution()) |
| 144 return TASK_CATEGORY_NONCONCURRENT_FOREGROUND; | 171 return TASK_CATEGORY_NONCONCURRENT_FOREGROUND; |
| 145 | 172 |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 } | 993 } |
| 967 | 994 |
| 968 // We can skip the image hijack canvas if we have no images. | 995 // We can skip the image hijack canvas if we have no images. |
| 969 playback_settings.use_image_hijack_canvas = !images.empty(); | 996 playback_settings.use_image_hijack_canvas = !images.empty(); |
| 970 | 997 |
| 971 // Get the tasks for the required images. | 998 // Get the tasks for the required images. |
| 972 ImageDecodeController::TracingInfo tracing_info( | 999 ImageDecodeController::TracingInfo tracing_info( |
| 973 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1000 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
| 974 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); | 1001 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); |
| 975 | 1002 |
| 976 bool supports_concurrent_execution = !use_gpu_rasterization_; | |
| 977 std::unique_ptr<RasterBuffer> raster_buffer = | 1003 std::unique_ptr<RasterBuffer> raster_buffer = |
| 978 raster_buffer_provider_->AcquireBufferForRaster( | 1004 raster_buffer_provider_->AcquireBufferForRaster( |
| 979 resource, resource_content_id, tile->invalidated_id()); | 1005 resource, resource_content_id, tile->invalidated_id()); |
| 980 return make_scoped_refptr(new RasterTaskImpl( | 1006 return make_scoped_refptr(new RasterTaskImpl( |
| 981 this, tile, resource, prioritized_tile.raster_source(), playback_settings, | 1007 this, tile, resource, prioritized_tile.raster_source(), playback_settings, |
| 982 prioritized_tile.priority().resolution, invalidated_rect, | 1008 prioritized_tile.priority().resolution, invalidated_rect, |
| 983 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, | 1009 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, |
| 984 supports_concurrent_execution)); | 1010 use_gpu_rasterization_)); |
| 985 } | 1011 } |
| 986 | 1012 |
| 987 void TileManager::OnRasterTaskCompleted( | 1013 void TileManager::OnRasterTaskCompleted( |
| 988 std::unique_ptr<RasterBuffer> raster_buffer, | 1014 std::unique_ptr<RasterBuffer> raster_buffer, |
| 989 Tile* tile, | 1015 Tile* tile, |
| 990 Resource* resource, | 1016 Resource* resource, |
| 991 bool was_canceled) { | 1017 bool was_canceled) { |
| 992 DCHECK(tile); | 1018 DCHECK(tile); |
| 993 DCHECK(tiles_.find(tile->id()) != tiles_.end()); | 1019 DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
| 994 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); | 1020 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; | 1355 all_tile_tasks_completed = false; |
| 1330 did_notify_all_tile_tasks_completed = false; | 1356 did_notify_all_tile_tasks_completed = false; |
| 1331 } | 1357 } |
| 1332 | 1358 |
| 1333 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1359 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1334 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1360 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1335 PrioritizedWorkToSchedule&& other) = default; | 1361 PrioritizedWorkToSchedule&& other) = default; |
| 1336 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1362 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1337 | 1363 |
| 1338 } // namespace cc | 1364 } // namespace cc |
| OLD | NEW |