| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/playback/display_list_recording_source.h" | 5 #include "cc/playback/display_list_recording_source.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/base/histograms.h" | 9 #include "cc/base/histograms.h" |
| 10 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const gfx::Size& grid_cell_size) | 45 const gfx::Size& grid_cell_size) |
| 46 : slow_down_raster_scale_factor_for_debug_(0), | 46 : slow_down_raster_scale_factor_for_debug_(0), |
| 47 gather_images_(false), | 47 gather_images_(false), |
| 48 requires_clear_(false), | 48 requires_clear_(false), |
| 49 is_solid_color_(false), | 49 is_solid_color_(false), |
| 50 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 50 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
| 51 solid_color_(SK_ColorTRANSPARENT), | 51 solid_color_(SK_ColorTRANSPARENT), |
| 52 background_color_(SK_ColorTRANSPARENT), | 52 background_color_(SK_ColorTRANSPARENT), |
| 53 pixel_record_distance_(kPixelDistanceToRecord), | 53 pixel_record_distance_(kPixelDistanceToRecord), |
| 54 grid_cell_size_(grid_cell_size), | 54 grid_cell_size_(grid_cell_size), |
| 55 painter_reported_memory_usage_(0) {} | 55 painter_reported_memory_usage_(0), |
| 56 is_suitable_for_gpu_rasterization_(true) {} |
| 56 | 57 |
| 57 DisplayListRecordingSource::~DisplayListRecordingSource() { | 58 DisplayListRecordingSource::~DisplayListRecordingSource() { |
| 58 } | 59 } |
| 59 | 60 |
| 60 // This method only really makes sense to call if the size of the layer didn't | 61 // This method only really makes sense to call if the size of the layer didn't |
| 61 // change. | 62 // change. |
| 62 bool DisplayListRecordingSource::ExposesEnoughNewArea( | 63 bool DisplayListRecordingSource::ExposesEnoughNewArea( |
| 63 const gfx::Rect& current_recorded_viewport, | 64 const gfx::Rect& current_recorded_viewport, |
| 64 const gfx::Rect& potential_new_recorded_viewport, | 65 const gfx::Rect& potential_new_recorded_viewport, |
| 65 const gfx::Size& layer_size) { | 66 const gfx::Size& layer_size) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // case RecordingSource::RECORD_WITH_SK_NULL_CANVAS should not be reached | 176 // case RecordingSource::RECORD_WITH_SK_NULL_CANVAS should not be reached |
| 176 NOTREACHED(); | 177 NOTREACHED(); |
| 177 } | 178 } |
| 178 | 179 |
| 179 // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able | 180 // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able |
| 180 // to slow down recording. | 181 // to slow down recording. |
| 181 display_list_ = | 182 display_list_ = |
| 182 painter->PaintContentsToDisplayList(recorded_viewport_, painting_control); | 183 painter->PaintContentsToDisplayList(recorded_viewport_, painting_control); |
| 183 painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage(); | 184 painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage(); |
| 184 | 185 |
| 186 is_suitable_for_gpu_rasterization_ = |
| 187 display_list_->IsSuitableForGpuRasterization(); |
| 185 DetermineIfSolidColor(); | 188 DetermineIfSolidColor(); |
| 186 display_list_->EmitTraceSnapshot(); | 189 display_list_->EmitTraceSnapshot(); |
| 187 if (gather_images_) | 190 if (gather_images_) |
| 188 display_list_->GatherDiscardableImages(grid_cell_size_); | 191 display_list_->GatherDiscardableImages(grid_cell_size_); |
| 189 | 192 |
| 190 return true; | 193 return true; |
| 191 } | 194 } |
| 192 | 195 |
| 193 gfx::Size DisplayListRecordingSource::GetSize() const { | 196 gfx::Size DisplayListRecordingSource::GetSize() const { |
| 194 return size_; | 197 return size_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 209 } | 212 } |
| 210 | 213 |
| 211 void DisplayListRecordingSource::SetBackgroundColor(SkColor background_color) { | 214 void DisplayListRecordingSource::SetBackgroundColor(SkColor background_color) { |
| 212 background_color_ = background_color; | 215 background_color_ = background_color; |
| 213 } | 216 } |
| 214 | 217 |
| 215 void DisplayListRecordingSource::SetRequiresClear(bool requires_clear) { | 218 void DisplayListRecordingSource::SetRequiresClear(bool requires_clear) { |
| 216 requires_clear_ = requires_clear; | 219 requires_clear_ = requires_clear; |
| 217 } | 220 } |
| 218 | 221 |
| 222 void DisplayListRecordingSource::SetUnsuitableForGpuRasterizationForTesting() { |
| 223 is_suitable_for_gpu_rasterization_ = false; |
| 224 } |
| 225 |
| 219 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { | 226 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { |
| 220 // The display list needs to be created (see: UpdateAndExpandInvalidation) | 227 return is_suitable_for_gpu_rasterization_; |
| 221 // before checking for suitability. | |
| 222 DCHECK(display_list_); | |
| 223 return display_list_->IsSuitableForGpuRasterization(); | |
| 224 } | 228 } |
| 225 | 229 |
| 226 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( | 230 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( |
| 227 bool can_use_lcd_text) const { | 231 bool can_use_lcd_text) const { |
| 228 return scoped_refptr<RasterSource>( | 232 return scoped_refptr<RasterSource>( |
| 229 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 233 DisplayListRasterSource::CreateFromDisplayListRecordingSource( |
| 230 this, can_use_lcd_text)); | 234 this, can_use_lcd_text)); |
| 231 } | 235 } |
| 232 | 236 |
| 233 void DisplayListRecordingSource::DetermineIfSolidColor() { | 237 void DisplayListRecordingSource::DetermineIfSolidColor() { |
| 234 DCHECK(display_list_); | 238 DCHECK(display_list_.get()); |
| 235 is_solid_color_ = false; | 239 is_solid_color_ = false; |
| 236 solid_color_ = SK_ColorTRANSPARENT; | 240 solid_color_ = SK_ColorTRANSPARENT; |
| 237 | 241 |
| 238 if (!display_list_->ShouldBeAnalyzedForSolidColor()) | 242 if (!display_list_->ShouldBeAnalyzedForSolidColor()) |
| 239 return; | 243 return; |
| 240 | 244 |
| 241 gfx::Size layer_size = GetSize(); | 245 gfx::Size layer_size = GetSize(); |
| 242 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); | 246 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); |
| 243 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); | 247 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); |
| 244 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 248 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| 245 } | 249 } |
| 246 | 250 |
| 247 void DisplayListRecordingSource::Clear() { | 251 void DisplayListRecordingSource::Clear() { |
| 248 recorded_viewport_ = gfx::Rect(); | 252 recorded_viewport_ = gfx::Rect(); |
| 249 display_list_ = nullptr; | 253 display_list_ = NULL; |
| 250 painter_reported_memory_usage_ = 0; | 254 painter_reported_memory_usage_ = 0; |
| 251 is_solid_color_ = false; | 255 is_solid_color_ = false; |
| 252 } | 256 } |
| 253 | 257 |
| 254 } // namespace cc | 258 } // namespace cc |
| OLD | NEW |