| 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/recording_source.h" | 5 #include "cc/playback/recording_source.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 Region newly_exposed_region(new_recorded_viewport); | 97 Region newly_exposed_region(new_recorded_viewport); |
| 98 newly_exposed_region.Subtract(old_recorded_viewport); | 98 newly_exposed_region.Subtract(old_recorded_viewport); |
| 99 invalidation->Union(newly_exposed_region); | 99 invalidation->Union(newly_exposed_region); |
| 100 | 100 |
| 101 Region no_longer_exposed_region(old_recorded_viewport); | 101 Region no_longer_exposed_region(old_recorded_viewport); |
| 102 no_longer_exposed_region.Subtract(new_recorded_viewport); | 102 no_longer_exposed_region.Subtract(new_recorded_viewport); |
| 103 invalidation->Union(no_longer_exposed_region); | 103 invalidation->Union(no_longer_exposed_region); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void RecordingSource::FinishDisplayItemListUpdate() { | 106 void RecordingSource::FinishDisplayItemListUpdate() { |
| 107 TRACE_EVENT0("cc", "RecordingSource::FinishDisplayItemListUpdate"); |
| 107 DetermineIfSolidColor(); | 108 DetermineIfSolidColor(); |
| 108 display_list_->EmitTraceSnapshot(); | 109 display_list_->EmitTraceSnapshot(); |
| 109 if (generate_discardable_images_metadata_) | 110 if (generate_discardable_images_metadata_) |
| 110 display_list_->GenerateDiscardableImagesMetadata(); | 111 display_list_->GenerateDiscardableImagesMetadata(); |
| 111 } | 112 } |
| 112 | 113 |
| 113 void RecordingSource::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { | 114 void RecordingSource::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { |
| 114 if (!layer_rect.IsEmpty()) { | 115 if (!layer_rect.IsEmpty()) { |
| 115 // Clamp invalidation to the layer bounds. | 116 // Clamp invalidation to the layer bounds. |
| 116 invalidation_.Union(gfx::IntersectRects(layer_rect, gfx::Rect(size_))); | 117 invalidation_.Union(gfx::IntersectRects(layer_rect, gfx::Rect(size_))); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 221 } |
| 221 | 222 |
| 222 void RecordingSource::DetermineIfSolidColor() { | 223 void RecordingSource::DetermineIfSolidColor() { |
| 223 DCHECK(display_list_); | 224 DCHECK(display_list_); |
| 224 is_solid_color_ = false; | 225 is_solid_color_ = false; |
| 225 solid_color_ = SK_ColorTRANSPARENT; | 226 solid_color_ = SK_ColorTRANSPARENT; |
| 226 | 227 |
| 227 if (!display_list_->ShouldBeAnalyzedForSolidColor()) | 228 if (!display_list_->ShouldBeAnalyzedForSolidColor()) |
| 228 return; | 229 return; |
| 229 | 230 |
| 231 TRACE_EVENT1("cc", "RecordingSource::DetermineIfSolidColor", "opcount", |
| 232 display_list_->ApproximateOpCount()); |
| 230 gfx::Size layer_size = GetSize(); | 233 gfx::Size layer_size = GetSize(); |
| 231 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); | 234 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); |
| 232 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); | 235 display_list_->Raster(&canvas, nullptr, gfx::Rect(), 1.f); |
| 233 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | 236 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| 234 } | 237 } |
| 235 | 238 |
| 236 void RecordingSource::Clear() { | 239 void RecordingSource::Clear() { |
| 237 recorded_viewport_ = gfx::Rect(); | 240 recorded_viewport_ = gfx::Rect(); |
| 238 display_list_ = nullptr; | 241 display_list_ = nullptr; |
| 239 painter_reported_memory_usage_ = 0; | 242 painter_reported_memory_usage_ = 0; |
| 240 is_solid_color_ = false; | 243 is_solid_color_ = false; |
| 241 } | 244 } |
| 242 | 245 |
| 243 } // namespace cc | 246 } // namespace cc |
| OLD | NEW |