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 // The display list needs to be created (see: UpdateAndExpandInvalidation) |
| 221 // before checking for suitability. |
| 222 DCHECK(display_list_); |
| 223 return display_list_->IsSuitableForGpuRasterization(); |
228 } | 224 } |
229 | 225 |
230 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( | 226 scoped_refptr<RasterSource> DisplayListRecordingSource::CreateRasterSource( |
231 bool can_use_lcd_text) const { | 227 bool can_use_lcd_text) const { |
232 return scoped_refptr<RasterSource>( | 228 return scoped_refptr<RasterSource>( |
233 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 229 DisplayListRasterSource::CreateFromDisplayListRecordingSource( |
234 this, can_use_lcd_text)); | 230 this, can_use_lcd_text)); |
235 } | 231 } |
236 | 232 |
237 void DisplayListRecordingSource::DetermineIfSolidColor() { | 233 void DisplayListRecordingSource::DetermineIfSolidColor() { |
238 DCHECK(display_list_.get()); | 234 DCHECK(display_list_); |
239 is_solid_color_ = false; | 235 is_solid_color_ = false; |
240 solid_color_ = SK_ColorTRANSPARENT; | 236 solid_color_ = SK_ColorTRANSPARENT; |
241 | 237 |
242 if (!display_list_->ShouldBeAnalyzedForSolidColor()) | 238 if (!display_list_->ShouldBeAnalyzedForSolidColor()) |
243 return; | 239 return; |
244 | 240 |
245 gfx::Size layer_size = GetSize(); | 241 gfx::Size layer_size = GetSize(); |
246 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); | 242 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); |
247 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); | 243 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); |
248 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 244 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
249 } | 245 } |
250 | 246 |
251 void DisplayListRecordingSource::Clear() { | 247 void DisplayListRecordingSource::Clear() { |
252 recorded_viewport_ = gfx::Rect(); | 248 recorded_viewport_ = gfx::Rect(); |
253 display_list_ = NULL; | 249 display_list_ = nullptr; |
254 painter_reported_memory_usage_ = 0; | 250 painter_reported_memory_usage_ = 0; |
255 is_solid_color_ = false; | 251 is_solid_color_ = false; |
256 } | 252 } |
257 | 253 |
258 } // namespace cc | 254 } // namespace cc |
OLD | NEW |