Chromium Code Reviews| 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) {} | |
| 57 | 56 |
| 58 DisplayListRecordingSource::~DisplayListRecordingSource() { | 57 DisplayListRecordingSource::~DisplayListRecordingSource() { |
| 59 } | 58 } |
| 60 | 59 |
| 61 // This method only really makes sense to call if the size of the layer didn't | 60 // This method only really makes sense to call if the size of the layer didn't |
| 62 // change. | 61 // change. |
| 63 bool DisplayListRecordingSource::ExposesEnoughNewArea( | 62 bool DisplayListRecordingSource::ExposesEnoughNewArea( |
| 64 const gfx::Rect& current_recorded_viewport, | 63 const gfx::Rect& current_recorded_viewport, |
| 65 const gfx::Rect& potential_new_recorded_viewport, | 64 const gfx::Rect& potential_new_recorded_viewport, |
| 66 const gfx::Size& layer_size) { | 65 const gfx::Size& layer_size) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 // case RecordingSource::RECORD_WITH_SK_NULL_CANVAS should not be reached | 175 // case RecordingSource::RECORD_WITH_SK_NULL_CANVAS should not be reached |
| 177 NOTREACHED(); | 176 NOTREACHED(); |
| 178 } | 177 } |
| 179 | 178 |
| 180 // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able | 179 // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able |
| 181 // to slow down recording. | 180 // to slow down recording. |
| 182 display_list_ = | 181 display_list_ = |
| 183 painter->PaintContentsToDisplayList(recorded_viewport_, painting_control); | 182 painter->PaintContentsToDisplayList(recorded_viewport_, painting_control); |
| 184 painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage(); | 183 painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage(); |
| 185 | 184 |
| 186 is_suitable_for_gpu_rasterization_ = | |
| 187 display_list_->IsSuitableForGpuRasterization(); | |
| 188 DetermineIfSolidColor(); | 185 DetermineIfSolidColor(); |
| 189 display_list_->EmitTraceSnapshot(); | 186 display_list_->EmitTraceSnapshot(); |
| 190 if (gather_images_) | 187 if (gather_images_) |
| 191 display_list_->GatherDiscardableImages(grid_cell_size_); | 188 display_list_->GatherDiscardableImages(grid_cell_size_); |
| 192 | 189 |
| 193 return true; | 190 return true; |
| 194 } | 191 } |
| 195 | 192 |
| 196 gfx::Size DisplayListRecordingSource::GetSize() const { | 193 gfx::Size DisplayListRecordingSource::GetSize() const { |
| 197 return size_; | 194 return size_; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 212 } | 209 } |
| 213 | 210 |
| 214 void DisplayListRecordingSource::SetBackgroundColor(SkColor background_color) { | 211 void DisplayListRecordingSource::SetBackgroundColor(SkColor background_color) { |
| 215 background_color_ = background_color; | 212 background_color_ = background_color; |
| 216 } | 213 } |
| 217 | 214 |
| 218 void DisplayListRecordingSource::SetRequiresClear(bool requires_clear) { | 215 void DisplayListRecordingSource::SetRequiresClear(bool requires_clear) { |
| 219 requires_clear_ = requires_clear; | 216 requires_clear_ = requires_clear; |
| 220 } | 217 } |
| 221 | 218 |
| 222 void DisplayListRecordingSource::SetUnsuitableForGpuRasterizationForTesting() { | |
| 223 is_suitable_for_gpu_rasterization_ = false; | |
| 224 } | |
| 225 | |
| 226 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { | 219 bool DisplayListRecordingSource::IsSuitableForGpuRasterization() const { |
| 227 return is_suitable_for_gpu_rasterization_; | 220 return !display_list_ || display_list_->IsSuitableForGpuRasterization(); |
|
danakj
2015/09/17 21:11:32
when/how can display_list_ be null?
pdr.
2015/09/18 22:40:14
display_list_ can be null if this is called before
danakj
2015/09/18 22:42:07
I guess I'm wondering, we ask if it's suitable for
| |
| 228 } | 221 } |
| 229 | 222 |
| 230 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( | 223 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( |
| 231 bool can_use_lcd_text) const { | 224 bool can_use_lcd_text) const { |
| 232 return scoped_refptr<RasterSource>( | 225 return scoped_refptr<RasterSource>( |
| 233 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 226 DisplayListRasterSource::CreateFromDisplayListRecordingSource( |
| 234 this, can_use_lcd_text)); | 227 this, can_use_lcd_text)); |
| 235 } | 228 } |
| 236 | 229 |
| 237 void DisplayListRecordingSource::DetermineIfSolidColor() { | 230 void DisplayListRecordingSource::DetermineIfSolidColor() { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 249 } | 242 } |
| 250 | 243 |
| 251 void DisplayListRecordingSource::Clear() { | 244 void DisplayListRecordingSource::Clear() { |
| 252 recorded_viewport_ = gfx::Rect(); | 245 recorded_viewport_ = gfx::Rect(); |
| 253 display_list_ = NULL; | 246 display_list_ = NULL; |
| 254 painter_reported_memory_usage_ = 0; | 247 painter_reported_memory_usage_ = 0; |
| 255 is_solid_color_ = false; | 248 is_solid_color_ = false; |
| 256 } | 249 } |
| 257 | 250 |
| 258 } // namespace cc | 251 } // namespace cc |
| OLD | NEW |