| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 SizeToProto(size_, proto->mutable_size()); | 54 SizeToProto(size_, proto->mutable_size()); |
| 55 proto->set_slow_down_raster_scale_factor_for_debug( | 55 proto->set_slow_down_raster_scale_factor_for_debug( |
| 56 slow_down_raster_scale_factor_for_debug_); | 56 slow_down_raster_scale_factor_for_debug_); |
| 57 proto->set_generate_discardable_images_metadata( | 57 proto->set_generate_discardable_images_metadata( |
| 58 generate_discardable_images_metadata_); | 58 generate_discardable_images_metadata_); |
| 59 proto->set_requires_clear(requires_clear_); | 59 proto->set_requires_clear(requires_clear_); |
| 60 proto->set_is_solid_color(is_solid_color_); | 60 proto->set_is_solid_color(is_solid_color_); |
| 61 proto->set_clear_canvas_with_debug_color(clear_canvas_with_debug_color_); | 61 proto->set_clear_canvas_with_debug_color(clear_canvas_with_debug_color_); |
| 62 proto->set_solid_color(static_cast<uint64_t>(solid_color_)); | 62 proto->set_solid_color(static_cast<uint64_t>(solid_color_)); |
| 63 proto->set_background_color(static_cast<uint64_t>(background_color_)); | 63 proto->set_background_color(static_cast<uint64_t>(background_color_)); |
| 64 display_list_->ToProtobuf(proto->mutable_display_list()); | 64 if (display_list_) |
| 65 display_list_->ToProtobuf(proto->mutable_display_list()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void DisplayListRecordingSource::FromProtobuf( | 68 void DisplayListRecordingSource::FromProtobuf( |
| 68 const proto::DisplayListRecordingSource& proto) { | 69 const proto::DisplayListRecordingSource& proto) { |
| 69 recorded_viewport_ = ProtoToRect(proto.recorded_viewport()); | 70 recorded_viewport_ = ProtoToRect(proto.recorded_viewport()); |
| 70 size_ = ProtoToSize(proto.size()); | 71 size_ = ProtoToSize(proto.size()); |
| 71 slow_down_raster_scale_factor_for_debug_ = | 72 slow_down_raster_scale_factor_for_debug_ = |
| 72 proto.slow_down_raster_scale_factor_for_debug(); | 73 proto.slow_down_raster_scale_factor_for_debug(); |
| 73 generate_discardable_images_metadata_ = | 74 generate_discardable_images_metadata_ = |
| 74 proto.generate_discardable_images_metadata(); | 75 proto.generate_discardable_images_metadata(); |
| 75 requires_clear_ = proto.requires_clear(); | 76 requires_clear_ = proto.requires_clear(); |
| 76 is_solid_color_ = proto.is_solid_color(); | 77 is_solid_color_ = proto.is_solid_color(); |
| 77 clear_canvas_with_debug_color_ = proto.clear_canvas_with_debug_color(); | 78 clear_canvas_with_debug_color_ = proto.clear_canvas_with_debug_color(); |
| 78 solid_color_ = static_cast<SkColor>(proto.solid_color()); | 79 solid_color_ = static_cast<SkColor>(proto.solid_color()); |
| 79 background_color_ = static_cast<SkColor>(proto.background_color()); | 80 background_color_ = static_cast<SkColor>(proto.background_color()); |
| 80 display_list_ = DisplayItemList::CreateFromProto(proto.display_list()); | |
| 81 | 81 |
| 82 FinishDisplayItemListUpdate(); | 82 // This might not exist if the |display_list_| of the serialized |
| 83 // DisplayListRecordingSource was null, wich can happen if |Clear()| is |
| 84 // called. |
| 85 if (proto.has_display_list()) { |
| 86 display_list_ = DisplayItemList::CreateFromProto(proto.display_list()); |
| 87 FinishDisplayItemListUpdate(); |
| 88 } else { |
| 89 display_list_ = nullptr; |
| 90 } |
| 83 } | 91 } |
| 84 | 92 |
| 85 void DisplayListRecordingSource::UpdateInvalidationForNewViewport( | 93 void DisplayListRecordingSource::UpdateInvalidationForNewViewport( |
| 86 const gfx::Rect& old_recorded_viewport, | 94 const gfx::Rect& old_recorded_viewport, |
| 87 const gfx::Rect& new_recorded_viewport, | 95 const gfx::Rect& new_recorded_viewport, |
| 88 Region* invalidation) { | 96 Region* invalidation) { |
| 89 // Invalidate newly-exposed and no-longer-exposed areas. | 97 // Invalidate newly-exposed and no-longer-exposed areas. |
| 90 Region newly_exposed_region(new_recorded_viewport); | 98 Region newly_exposed_region(new_recorded_viewport); |
| 91 newly_exposed_region.Subtract(old_recorded_viewport); | 99 newly_exposed_region.Subtract(old_recorded_viewport); |
| 92 invalidation->Union(newly_exposed_region); | 100 invalidation->Union(newly_exposed_region); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 231 } |
| 224 | 232 |
| 225 void DisplayListRecordingSource::Clear() { | 233 void DisplayListRecordingSource::Clear() { |
| 226 recorded_viewport_ = gfx::Rect(); | 234 recorded_viewport_ = gfx::Rect(); |
| 227 display_list_ = nullptr; | 235 display_list_ = nullptr; |
| 228 painter_reported_memory_usage_ = 0; | 236 painter_reported_memory_usage_ = 0; |
| 229 is_solid_color_ = false; | 237 is_solid_color_ = false; |
| 230 } | 238 } |
| 231 | 239 |
| 232 } // namespace cc | 240 } // namespace cc |
| OLD | NEW |