| 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 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 reply_.Run(analysis_, !HasFinishedRunning()); | 86 reply_.Run(analysis_, !HasFinishedRunning()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 virtual ~RasterTaskImpl() { DCHECK(!canvas_); } | 90 virtual ~RasterTaskImpl() { DCHECK(!canvas_); } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 void AnalyzeAndRaster(PicturePileImpl* picture_pile) { | 93 void AnalyzeAndRaster(PicturePileImpl* picture_pile) { |
| 94 DCHECK(picture_pile); | 94 DCHECK(picture_pile); |
| 95 DCHECK(canvas_); | 95 DCHECK(canvas_); |
| 96 DCHECK(canvas_->GetSkCanvas()); |
| 96 | 97 |
| 97 if (analyze_picture_) { | 98 if (analyze_picture_) { |
| 98 Analyze(picture_pile); | 99 Analyze(picture_pile); |
| 99 if (analysis_.is_solid_color) | 100 if (analysis_.is_solid_color) |
| 100 return; | 101 return; |
| 101 } | 102 } |
| 102 | 103 |
| 103 Raster(picture_pile); | 104 Raster(picture_pile); |
| 105 |
| 106 canvas_->Flush(); |
| 104 } | 107 } |
| 105 | 108 |
| 106 void Analyze(PicturePileImpl* picture_pile) { | 109 void Analyze(PicturePileImpl* picture_pile) { |
| 107 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task( | 110 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task( |
| 108 tile_id_, tile_resolution_, source_frame_number_, layer_id_); | 111 tile_id_, tile_resolution_, source_frame_number_, layer_id_); |
| 109 | 112 |
| 110 DCHECK(picture_pile); | 113 DCHECK(picture_pile); |
| 111 | 114 |
| 112 picture_pile->AnalyzeInRect( | 115 picture_pile->AnalyzeInRect( |
| 113 content_rect_, contents_scale_, &analysis_, rendering_stats_); | 116 content_rect_, contents_scale_, &analysis_, rendering_stats_); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 134 switch (raster_mode_) { | 137 switch (raster_mode_) { |
| 135 case LOW_QUALITY_RASTER_MODE: | 138 case LOW_QUALITY_RASTER_MODE: |
| 136 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); | 139 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); |
| 137 break; | 140 break; |
| 138 case HIGH_QUALITY_RASTER_MODE: | 141 case HIGH_QUALITY_RASTER_MODE: |
| 139 break; | 142 break; |
| 140 case NUM_RASTER_MODES: | 143 case NUM_RASTER_MODES: |
| 141 default: | 144 default: |
| 142 NOTREACHED(); | 145 NOTREACHED(); |
| 143 } | 146 } |
| 144 canvas_->setDrawFilter(draw_filter.get()); | 147 canvas_->GetSkCanvas()->setDrawFilter(draw_filter.get()); |
| 145 | 148 |
| 146 base::TimeDelta prev_rasterize_time = | 149 base::TimeDelta prev_rasterize_time = |
| 147 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | 150 rendering_stats_->impl_thread_rendering_stats().rasterize_time; |
| 148 | 151 |
| 149 // Only record rasterization time for highres tiles, because | 152 // Only record rasterization time for highres tiles, because |
| 150 // lowres tiles are not required for activation and therefore | 153 // lowres tiles are not required for activation and therefore |
| 151 // introduce noise in the measurement (sometimes they get rasterized | 154 // introduce noise in the measurement (sometimes they get rasterized |
| 152 // before we draw and sometimes they aren't) | 155 // before we draw and sometimes they aren't) |
| 153 RenderingStatsInstrumentation* stats = | 156 RenderingStatsInstrumentation* stats = |
| 154 tile_resolution_ == HIGH_RESOLUTION ? rendering_stats_ : NULL; | 157 tile_resolution_ == HIGH_RESOLUTION ? rendering_stats_ : NULL; |
| 155 DCHECK(picture_pile); | 158 DCHECK(picture_pile); |
| 156 picture_pile->RasterToBitmap( | 159 picture_pile->RasterToBitmap( |
| 157 canvas_, content_rect_, contents_scale_, stats); | 160 canvas_->GetSkCanvas(), content_rect_, contents_scale_, stats); |
| 158 | 161 |
| 159 if (rendering_stats_->record_rendering_stats()) { | 162 if (rendering_stats_->record_rendering_stats()) { |
| 160 base::TimeDelta current_rasterize_time = | 163 base::TimeDelta current_rasterize_time = |
| 161 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | 164 rendering_stats_->impl_thread_rendering_stats().rasterize_time; |
| 162 HISTOGRAM_CUSTOM_COUNTS( | 165 HISTOGRAM_CUSTOM_COUNTS( |
| 163 "Renderer4.PictureRasterTimeUS", | 166 "Renderer4.PictureRasterTimeUS", |
| 164 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), | 167 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), |
| 165 0, | 168 0, |
| 166 100000, | 169 100000, |
| 167 100); | 170 100); |
| 168 } | 171 } |
| 169 } | 172 } |
| 170 | 173 |
| 171 PicturePileImpl::Analysis analysis_; | 174 PicturePileImpl::Analysis analysis_; |
| 172 scoped_refptr<PicturePileImpl> picture_pile_; | 175 scoped_refptr<PicturePileImpl> picture_pile_; |
| 173 gfx::Rect content_rect_; | 176 gfx::Rect content_rect_; |
| 174 float contents_scale_; | 177 float contents_scale_; |
| 175 RasterMode raster_mode_; | 178 RasterMode raster_mode_; |
| 176 TileResolution tile_resolution_; | 179 TileResolution tile_resolution_; |
| 177 int layer_id_; | 180 int layer_id_; |
| 178 const void* tile_id_; | 181 const void* tile_id_; |
| 179 int source_frame_number_; | 182 int source_frame_number_; |
| 180 bool analyze_picture_; | 183 bool analyze_picture_; |
| 181 RenderingStatsInstrumentation* rendering_stats_; | 184 RenderingStatsInstrumentation* rendering_stats_; |
| 182 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_; | 185 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_; |
| 183 SkCanvas* canvas_; | 186 RasterCanvas* canvas_; |
| 184 | 187 |
| 185 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 188 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
| 186 }; | 189 }; |
| 187 | 190 |
| 188 class ImageDecodeTaskImpl : public ImageDecodeTask { | 191 class ImageDecodeTaskImpl : public ImageDecodeTask { |
| 189 public: | 192 public: |
| 190 ImageDecodeTaskImpl(SkPixelRef* pixel_ref, | 193 ImageDecodeTaskImpl(SkPixelRef* pixel_ref, |
| 191 int layer_id, | 194 int layer_id, |
| 192 RenderingStatsInstrumentation* rendering_stats, | 195 RenderingStatsInstrumentation* rendering_stats, |
| 193 const base::Callback<void(bool was_canceled)>& reply) | 196 const base::Callback<void(bool was_canceled)>& reply) |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 1184 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 1182 | 1185 |
| 1183 rasterizer_->CheckForCompletedTasks(); | 1186 rasterizer_->CheckForCompletedTasks(); |
| 1184 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1187 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1185 | 1188 |
| 1186 if (IsReadyToActivate()) | 1189 if (IsReadyToActivate()) |
| 1187 client_->NotifyReadyToActivate(); | 1190 client_->NotifyReadyToActivate(); |
| 1188 } | 1191 } |
| 1189 | 1192 |
| 1190 } // namespace cc | 1193 } // namespace cc |
| OLD | NEW |