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/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 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 #ifdef NDEBUG | 22 #ifdef NDEBUG |
| 23 const bool kDefaultClearCanvasSetting = false; | 23 const bool kDefaultClearCanvasSetting = false; |
| 24 #else | 24 #else |
| 25 const bool kDefaultClearCanvasSetting = true; | 25 const bool kDefaultClearCanvasSetting = true; |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 namespace cc { | 30 namespace cc { |
| 31 class ImageSerializationProcessor; | |
| 32 | 31 |
| 33 RecordingSource::RecordingSource() | 32 RecordingSource::RecordingSource() |
| 34 : slow_down_raster_scale_factor_for_debug_(0), | 33 : slow_down_raster_scale_factor_for_debug_(0), |
| 35 generate_discardable_images_metadata_(false), | 34 generate_discardable_images_metadata_(false), |
| 36 requires_clear_(false), | 35 requires_clear_(false), |
| 37 is_solid_color_(false), | 36 is_solid_color_(false), |
| 38 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 37 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
| 39 solid_color_(SK_ColorTRANSPARENT), | 38 solid_color_(SK_ColorTRANSPARENT), |
| 40 background_color_(SK_ColorTRANSPARENT), | 39 background_color_(SK_ColorTRANSPARENT), |
| 41 painter_reported_memory_usage_(0) {} | 40 painter_reported_memory_usage_(0) {} |
| 42 | 41 |
| 43 RecordingSource::~RecordingSource() {} | 42 RecordingSource::~RecordingSource() {} |
| 44 | 43 |
| 45 void RecordingSource::ToProtobuf( | 44 void RecordingSource::ToProtobuf(proto::RecordingSource* proto) const { |
| 46 proto::RecordingSource* proto, | |
| 47 ImageSerializationProcessor* image_serialization_processor) const { | |
| 48 RectToProto(recorded_viewport_, proto->mutable_recorded_viewport()); | 45 RectToProto(recorded_viewport_, proto->mutable_recorded_viewport()); |
| 49 SizeToProto(size_, proto->mutable_size()); | 46 SizeToProto(size_, proto->mutable_size()); |
| 50 proto->set_slow_down_raster_scale_factor_for_debug( | 47 proto->set_slow_down_raster_scale_factor_for_debug( |
| 51 slow_down_raster_scale_factor_for_debug_); | 48 slow_down_raster_scale_factor_for_debug_); |
| 52 proto->set_generate_discardable_images_metadata( | 49 proto->set_generate_discardable_images_metadata( |
| 53 generate_discardable_images_metadata_); | 50 generate_discardable_images_metadata_); |
| 54 proto->set_requires_clear(requires_clear_); | 51 proto->set_requires_clear(requires_clear_); |
| 55 proto->set_is_solid_color(is_solid_color_); | 52 proto->set_is_solid_color(is_solid_color_); |
| 56 proto->set_clear_canvas_with_debug_color(clear_canvas_with_debug_color_); | 53 proto->set_clear_canvas_with_debug_color(clear_canvas_with_debug_color_); |
| 57 proto->set_solid_color(static_cast<uint64_t>(solid_color_)); | 54 proto->set_solid_color(static_cast<uint64_t>(solid_color_)); |
| 58 proto->set_background_color(static_cast<uint64_t>(background_color_)); | 55 proto->set_background_color(static_cast<uint64_t>(background_color_)); |
| 59 if (display_list_) { | 56 if (display_list_) |
| 60 display_list_->ToProtobuf(proto->mutable_display_list(), | 57 display_list_->ToProtobuf(proto->mutable_display_list()); |
| 61 image_serialization_processor); | |
| 62 } | |
| 63 } | 58 } |
| 64 | 59 |
| 65 void RecordingSource::FromProtobuf( | 60 void RecordingSource::FromProtobuf( |
| 66 const proto::RecordingSource& proto, | 61 const proto::RecordingSource& proto, |
| 67 ImageSerializationProcessor* image_serialization_processor) { | 62 ClientPictureCache* client_picture_cache, |
| 63 std::vector<uint32_t>* used_engine_picture_ids) { | |
| 64 DCHECK(client_picture_cache); | |
| 68 recorded_viewport_ = ProtoToRect(proto.recorded_viewport()); | 65 recorded_viewport_ = ProtoToRect(proto.recorded_viewport()); |
| 69 size_ = ProtoToSize(proto.size()); | 66 size_ = ProtoToSize(proto.size()); |
| 70 slow_down_raster_scale_factor_for_debug_ = | 67 slow_down_raster_scale_factor_for_debug_ = |
| 71 proto.slow_down_raster_scale_factor_for_debug(); | 68 proto.slow_down_raster_scale_factor_for_debug(); |
| 72 generate_discardable_images_metadata_ = | 69 generate_discardable_images_metadata_ = |
| 73 proto.generate_discardable_images_metadata(); | 70 proto.generate_discardable_images_metadata(); |
| 74 requires_clear_ = proto.requires_clear(); | 71 requires_clear_ = proto.requires_clear(); |
| 75 is_solid_color_ = proto.is_solid_color(); | 72 is_solid_color_ = proto.is_solid_color(); |
| 76 clear_canvas_with_debug_color_ = proto.clear_canvas_with_debug_color(); | 73 clear_canvas_with_debug_color_ = proto.clear_canvas_with_debug_color(); |
| 77 solid_color_ = static_cast<SkColor>(proto.solid_color()); | 74 solid_color_ = static_cast<SkColor>(proto.solid_color()); |
| 78 background_color_ = static_cast<SkColor>(proto.background_color()); | 75 background_color_ = static_cast<SkColor>(proto.background_color()); |
| 79 | 76 |
| 80 // This might not exist if the |display_list_| of the serialized | 77 // This might not exist if the |display_list_| of the serialized |
| 81 // RecordingSource was null, wich can happen if |Clear()| is | 78 // RecordingSource was null, wich can happen if |Clear()| is |
| 82 // called. | 79 // called. |
| 83 if (proto.has_display_list()) { | 80 if (proto.has_display_list()) { |
| 84 display_list_ = DisplayItemList::CreateFromProto( | 81 display_list_ = DisplayItemList::CreateFromProto( |
| 85 proto.display_list(), image_serialization_processor); | 82 proto.display_list(), client_picture_cache, used_engine_picture_ids); |
| 86 FinishDisplayItemListUpdate(); | 83 FinishDisplayItemListUpdate(); |
| 87 } else { | 84 } else { |
| 88 display_list_ = nullptr; | 85 display_list_ = nullptr; |
| 89 } | 86 } |
| 90 } | 87 } |
| 91 | 88 |
| 92 void RecordingSource::UpdateInvalidationForNewViewport( | 89 void RecordingSource::UpdateInvalidationForNewViewport( |
| 93 const gfx::Rect& old_recorded_viewport, | 90 const gfx::Rect& old_recorded_viewport, |
| 94 const gfx::Rect& new_recorded_viewport, | 91 const gfx::Rect& new_recorded_viewport, |
| 95 Region* invalidation) { | 92 Region* invalidation) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } | 204 } |
| 208 | 205 |
| 209 bool RecordingSource::IsSuitableForGpuRasterization() const { | 206 bool RecordingSource::IsSuitableForGpuRasterization() const { |
| 210 // The display list needs to be created (see: UpdateAndExpandInvalidation) | 207 // The display list needs to be created (see: UpdateAndExpandInvalidation) |
| 211 // before checking for suitability. There are cases where an update will not | 208 // before checking for suitability. There are cases where an update will not |
| 212 // create a display list (e.g., if the size is empty). We return true in these | 209 // create a display list (e.g., if the size is empty). We return true in these |
| 213 // cases because the gpu suitability bit sticks false. | 210 // cases because the gpu suitability bit sticks false. |
| 214 return !display_list_ || display_list_->IsSuitableForGpuRasterization(); | 211 return !display_list_ || display_list_->IsSuitableForGpuRasterization(); |
| 215 } | 212 } |
| 216 | 213 |
| 214 scoped_refptr<const DisplayItemList> RecordingSource::GetDisplayItemList() { | |
|
vmpstr
2016/06/24 18:58:32
Make this return a raw ptr
nyquist
2016/06/24 20:31:23
Done.
| |
| 215 return display_list_; | |
| 216 } | |
| 217 | |
| 217 scoped_refptr<RasterSource> RecordingSource::CreateRasterSource( | 218 scoped_refptr<RasterSource> RecordingSource::CreateRasterSource( |
| 218 bool can_use_lcd_text) const { | 219 bool can_use_lcd_text) const { |
| 219 return scoped_refptr<RasterSource>( | 220 return scoped_refptr<RasterSource>( |
| 220 RasterSource::CreateFromRecordingSource(this, can_use_lcd_text)); | 221 RasterSource::CreateFromRecordingSource(this, can_use_lcd_text)); |
| 221 } | 222 } |
| 222 | 223 |
| 223 void RecordingSource::DetermineIfSolidColor() { | 224 void RecordingSource::DetermineIfSolidColor() { |
| 224 DCHECK(display_list_); | 225 DCHECK(display_list_); |
| 225 is_solid_color_ = false; | 226 is_solid_color_ = false; |
| 226 solid_color_ = SK_ColorTRANSPARENT; | 227 solid_color_ = SK_ColorTRANSPARENT; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 237 } | 238 } |
| 238 | 239 |
| 239 void RecordingSource::Clear() { | 240 void RecordingSource::Clear() { |
| 240 recorded_viewport_ = gfx::Rect(); | 241 recorded_viewport_ = gfx::Rect(); |
| 241 display_list_ = nullptr; | 242 display_list_ = nullptr; |
| 242 painter_reported_memory_usage_ = 0; | 243 painter_reported_memory_usage_ = 0; |
| 243 is_solid_color_ = false; | 244 is_solid_color_ = false; |
| 244 } | 245 } |
| 245 | 246 |
| 246 } // namespace cc | 247 } // namespace cc |
| OLD | NEW |