| 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/debug/trace_event_argument.h" | 12 #include "base/debug/trace_event_argument.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
| 17 #include "cc/debug/frame_viewer_instrumentation.h" | 17 #include "cc/debug/frame_viewer_instrumentation.h" |
| 18 #include "cc/debug/traced_value.h" | 18 #include "cc/debug/traced_value.h" |
| 19 #include "cc/layers/picture_layer_impl.h" | 19 #include "cc/layers/picture_layer_impl.h" |
| 20 #include "cc/resources/raster_worker_pool.h" | 20 #include "cc/resources/rasterizer.h" |
| 21 #include "cc/resources/tile.h" | 21 #include "cc/resources/tile.h" |
| 22 #include "skia/ext/paint_simplifier.h" | 22 #include "skia/ext/paint_simplifier.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 24 #include "third_party/skia/include/core/SkPixelRef.h" | 24 #include "third_party/skia/include/core/SkPixelRef.h" |
| 25 #include "ui/gfx/rect_conversions.h" | 25 #include "ui/gfx/rect_conversions.h" |
| 26 | 26 |
| 27 namespace cc { | 27 namespace cc { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Flag to indicate whether we should try and detect that | 30 // Flag to indicate whether we should try and detect that |
| (...skipping 28 matching lines...) Expand all Loading... |
| 59 analyze_picture_(analyze_picture), | 59 analyze_picture_(analyze_picture), |
| 60 rendering_stats_(rendering_stats), | 60 rendering_stats_(rendering_stats), |
| 61 reply_(reply), | 61 reply_(reply), |
| 62 canvas_(NULL) {} | 62 canvas_(NULL) {} |
| 63 | 63 |
| 64 // Overridden from Task: | 64 // Overridden from Task: |
| 65 virtual void RunOnWorkerThread() OVERRIDE { | 65 virtual void RunOnWorkerThread() OVERRIDE { |
| 66 TRACE_EVENT0("cc", "RasterizerTaskImpl::RunOnWorkerThread"); | 66 TRACE_EVENT0("cc", "RasterizerTaskImpl::RunOnWorkerThread"); |
| 67 | 67 |
| 68 DCHECK(picture_pile_); | 68 DCHECK(picture_pile_); |
| 69 if (canvas_) { | 69 if (!canvas_) |
| 70 AnalyzeAndRaster(picture_pile_->GetCloneForDrawingOnThread( | 70 return; |
| 71 RasterWorkerPool::GetPictureCloneIndexForCurrentThread())); | 71 |
| 72 if (analyze_picture_) { |
| 73 Analyze(picture_pile_.get()); |
| 74 if (analysis_.is_solid_color) |
| 75 return; |
| 72 } | 76 } |
| 77 |
| 78 Raster(picture_pile_.get()); |
| 73 } | 79 } |
| 74 | 80 |
| 75 // Overridden from RasterizerTask: | 81 // Overridden from RasterizerTask: |
| 76 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 82 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
| 77 DCHECK(!canvas_); | 83 DCHECK(!canvas_); |
| 78 canvas_ = client->AcquireCanvasForRaster(this); | 84 canvas_ = client->AcquireCanvasForRaster(this); |
| 79 } | 85 } |
| 80 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 86 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
| 81 canvas_ = NULL; | 87 canvas_ = NULL; |
| 82 client->ReleaseCanvasForRaster(this); | 88 client->ReleaseCanvasForRaster(this); |
| 83 } | 89 } |
| 84 virtual void RunReplyOnOriginThread() OVERRIDE { | 90 virtual void RunReplyOnOriginThread() OVERRIDE { |
| 85 DCHECK(!canvas_); | 91 DCHECK(!canvas_); |
| 86 reply_.Run(analysis_, !HasFinishedRunning()); | 92 reply_.Run(analysis_, !HasFinishedRunning()); |
| 87 } | 93 } |
| 88 | 94 |
| 89 protected: | 95 protected: |
| 90 virtual ~RasterTaskImpl() { DCHECK(!canvas_); } | 96 virtual ~RasterTaskImpl() { DCHECK(!canvas_); } |
| 91 | 97 |
| 92 private: | 98 private: |
| 93 void AnalyzeAndRaster(PicturePileImpl* picture_pile) { | 99 void Analyze(const PicturePileImpl* picture_pile) { |
| 94 DCHECK(picture_pile); | |
| 95 DCHECK(canvas_); | |
| 96 | |
| 97 if (analyze_picture_) { | |
| 98 Analyze(picture_pile); | |
| 99 if (analysis_.is_solid_color) | |
| 100 return; | |
| 101 } | |
| 102 | |
| 103 Raster(picture_pile); | |
| 104 } | |
| 105 | |
| 106 void Analyze(PicturePileImpl* picture_pile) { | |
| 107 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task( | 100 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task( |
| 108 tile_id_, tile_resolution_, source_frame_number_, layer_id_); | 101 tile_id_, tile_resolution_, source_frame_number_, layer_id_); |
| 109 | 102 |
| 110 DCHECK(picture_pile); | 103 DCHECK(picture_pile); |
| 111 | 104 |
| 112 picture_pile->AnalyzeInRect( | 105 picture_pile->AnalyzeInRect( |
| 113 content_rect_, contents_scale_, &analysis_, rendering_stats_); | 106 content_rect_, contents_scale_, &analysis_, rendering_stats_); |
| 114 | 107 |
| 115 // Record the solid color prediction. | 108 // Record the solid color prediction. |
| 116 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", | 109 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", |
| 117 analysis_.is_solid_color); | 110 analysis_.is_solid_color); |
| 118 | 111 |
| 119 // Clear the flag if we're not using the estimator. | 112 // Clear the flag if we're not using the estimator. |
| 120 analysis_.is_solid_color &= kUseColorEstimator; | 113 analysis_.is_solid_color &= kUseColorEstimator; |
| 121 } | 114 } |
| 122 | 115 |
| 123 void Raster(PicturePileImpl* picture_pile) { | 116 void Raster(const PicturePileImpl* picture_pile) { |
| 124 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 117 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
| 125 tile_id_, | 118 tile_id_, |
| 126 tile_resolution_, | 119 tile_resolution_, |
| 127 source_frame_number_, | 120 source_frame_number_, |
| 128 layer_id_, | 121 layer_id_, |
| 129 raster_mode_); | 122 raster_mode_); |
| 130 devtools_instrumentation::ScopedLayerTask layer_task( | 123 devtools_instrumentation::ScopedLayerTask layer_task( |
| 131 devtools_instrumentation::kRasterTask, layer_id_); | 124 devtools_instrumentation::kRasterTask, layer_id_); |
| 132 | 125 |
| 133 skia::RefPtr<SkDrawFilter> draw_filter; | 126 skia::RefPtr<SkDrawFilter> draw_filter; |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 1169 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 1177 | 1170 |
| 1178 rasterizer_->CheckForCompletedTasks(); | 1171 rasterizer_->CheckForCompletedTasks(); |
| 1179 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1172 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1180 | 1173 |
| 1181 if (IsReadyToActivate()) | 1174 if (IsReadyToActivate()) |
| 1182 client_->NotifyReadyToActivate(); | 1175 client_->NotifyReadyToActivate(); |
| 1183 } | 1176 } |
| 1184 | 1177 |
| 1185 } // namespace cc | 1178 } // namespace cc |
| OLD | NEW |