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 "base/numerics/safe_math.h" | 9 #include "base/numerics/safe_math.h" |
10 #include "cc/base/histograms.h" | 10 #include "cc/base/histograms.h" |
11 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
12 #include "cc/layers/content_layer_client.h" | 12 #include "cc/layers/content_layer_client.h" |
13 #include "cc/playback/display_item_list.h" | 13 #include "cc/playback/display_item_list.h" |
14 #include "cc/playback/display_list_raster_source.h" | 14 #include "cc/playback/display_list_raster_source.h" |
15 #include "cc/proto/display_list_recording_source.pb.h" | |
16 #include "cc/proto/gfx_conversions.h" | |
15 #include "skia/ext/analysis_canvas.h" | 17 #include "skia/ext/analysis_canvas.h" |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 #ifdef NDEBUG | 21 #ifdef NDEBUG |
20 const bool kDefaultClearCanvasSetting = false; | 22 const bool kDefaultClearCanvasSetting = false; |
21 #else | 23 #else |
22 const bool kDefaultClearCanvasSetting = true; | 24 const bool kDefaultClearCanvasSetting = true; |
23 #endif | 25 #endif |
24 | 26 |
(...skipping 12 matching lines...) Expand all Loading... | |
37 requires_clear_(false), | 39 requires_clear_(false), |
38 is_solid_color_(false), | 40 is_solid_color_(false), |
39 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 41 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
40 solid_color_(SK_ColorTRANSPARENT), | 42 solid_color_(SK_ColorTRANSPARENT), |
41 background_color_(SK_ColorTRANSPARENT), | 43 background_color_(SK_ColorTRANSPARENT), |
42 painter_reported_memory_usage_(0) {} | 44 painter_reported_memory_usage_(0) {} |
43 | 45 |
44 DisplayListRecordingSource::~DisplayListRecordingSource() { | 46 DisplayListRecordingSource::~DisplayListRecordingSource() { |
45 } | 47 } |
46 | 48 |
49 void DisplayListRecordingSource::ToProtobuf( | |
50 proto::DisplayListRecordingSource* proto) const { | |
51 RectToProto(recorded_viewport_, proto->mutable_recorded_viewport()); | |
David Trainor- moved to gerrit
2015/12/09 04:07:24
Note to self: I need to write a unit test that val
| |
52 SizeToProto(size_, proto->mutable_size()); | |
53 proto->set_slow_down_raster_scale_factor_for_debug( | |
54 slow_down_raster_scale_factor_for_debug_); | |
55 proto->set_generate_discardable_images_metadata( | |
56 generate_discardable_images_metadata_); | |
57 proto->set_requires_clear(requires_clear_); | |
58 proto->set_is_solid_color(is_solid_color_); | |
59 proto->set_clear_canvas_with_debug_color(clear_canvas_with_debug_color_); | |
60 proto->set_solid_color(static_cast<uint64_t>(solid_color_)); | |
61 proto->set_background_color(static_cast<uint64_t>(background_color_)); | |
62 display_list_->ToProtobuf(proto->mutable_display_list()); | |
63 } | |
64 | |
65 void DisplayListRecordingSource::FromProtobuf( | |
66 const proto::DisplayListRecordingSource& proto) { | |
67 recorded_viewport_ = ProtoToRect(proto.recorded_viewport()); | |
68 size_ = ProtoToSize(proto.size()); | |
69 slow_down_raster_scale_factor_for_debug_ = | |
70 proto.slow_down_raster_scale_factor_for_debug(); | |
71 generate_discardable_images_metadata_ = | |
72 proto.generate_discardable_images_metadata(); | |
73 requires_clear_ = proto.requires_clear(); | |
74 is_solid_color_ = proto.is_solid_color(); | |
75 clear_canvas_with_debug_color_ = proto.clear_canvas_with_debug_color(); | |
76 solid_color_ = static_cast<SkColor>(proto.solid_color()); | |
77 background_color_ = static_cast<SkColor>(proto.background_color()); | |
78 display_list_ = DisplayItemList::CreateFromProto(proto.display_list()); | |
79 | |
80 DetermineIfSolidColor(); | |
David Trainor- moved to gerrit
2015/12/09 04:07:24
Note to self: Combine this with the calls in Updat
| |
81 display_list_->EmitTraceSnapshot(); | |
82 if (generate_discardable_images_metadata_) | |
83 display_list_->GenerateDiscardableImagesMetadata(); | |
84 } | |
85 | |
47 void DisplayListRecordingSource::UpdateInvalidationForNewViewport( | 86 void DisplayListRecordingSource::UpdateInvalidationForNewViewport( |
48 const gfx::Rect& old_recorded_viewport, | 87 const gfx::Rect& old_recorded_viewport, |
49 const gfx::Rect& new_recorded_viewport, | 88 const gfx::Rect& new_recorded_viewport, |
50 Region* invalidation) { | 89 Region* invalidation) { |
51 // Invalidate newly-exposed and no-longer-exposed areas. | 90 // Invalidate newly-exposed and no-longer-exposed areas. |
52 Region newly_exposed_region(new_recorded_viewport); | 91 Region newly_exposed_region(new_recorded_viewport); |
53 newly_exposed_region.Subtract(old_recorded_viewport); | 92 newly_exposed_region.Subtract(old_recorded_viewport); |
54 invalidation->Union(newly_exposed_region); | 93 invalidation->Union(newly_exposed_region); |
55 | 94 |
56 Region no_longer_exposed_region(old_recorded_viewport); | 95 Region no_longer_exposed_region(old_recorded_viewport); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 } | 220 } |
182 | 221 |
183 void DisplayListRecordingSource::Clear() { | 222 void DisplayListRecordingSource::Clear() { |
184 recorded_viewport_ = gfx::Rect(); | 223 recorded_viewport_ = gfx::Rect(); |
185 display_list_ = nullptr; | 224 display_list_ = nullptr; |
186 painter_reported_memory_usage_ = 0; | 225 painter_reported_memory_usage_ = 0; |
187 is_solid_color_ = false; | 226 is_solid_color_ = false; |
188 } | 227 } |
189 | 228 |
190 } // namespace cc | 229 } // namespace cc |
OLD | NEW |