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/raster/raster_source.h" | 5 #include "cc/raster/raster_source.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 background_color_(other->background_color_), | 35 background_color_(other->background_color_), |
| 36 requires_clear_(other->requires_clear_), | 36 requires_clear_(other->requires_clear_), |
| 37 can_use_lcd_text_(can_use_lcd_text), | 37 can_use_lcd_text_(can_use_lcd_text), |
| 38 is_solid_color_(other->is_solid_color_), | 38 is_solid_color_(other->is_solid_color_), |
| 39 solid_color_(other->solid_color_), | 39 solid_color_(other->solid_color_), |
| 40 recorded_viewport_(other->recorded_viewport_), | 40 recorded_viewport_(other->recorded_viewport_), |
| 41 size_(other->size_), | 41 size_(other->size_), |
| 42 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 42 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
| 43 slow_down_raster_scale_factor_for_debug_( | 43 slow_down_raster_scale_factor_for_debug_( |
| 44 other->slow_down_raster_scale_factor_for_debug_), | 44 other->slow_down_raster_scale_factor_for_debug_), |
| 45 recording_scale_factor_(other->recording_scale_factor_), | |
| 45 image_decode_cache_(nullptr) {} | 46 image_decode_cache_(nullptr) {} |
| 46 | 47 |
| 47 RasterSource::RasterSource(const RasterSource* other, bool can_use_lcd_text) | 48 RasterSource::RasterSource(const RasterSource* other, bool can_use_lcd_text) |
| 48 : display_list_(other->display_list_), | 49 : display_list_(other->display_list_), |
| 49 painter_reported_memory_usage_(other->painter_reported_memory_usage_), | 50 painter_reported_memory_usage_(other->painter_reported_memory_usage_), |
| 50 background_color_(other->background_color_), | 51 background_color_(other->background_color_), |
| 51 requires_clear_(other->requires_clear_), | 52 requires_clear_(other->requires_clear_), |
| 52 can_use_lcd_text_(can_use_lcd_text), | 53 can_use_lcd_text_(can_use_lcd_text), |
| 53 is_solid_color_(other->is_solid_color_), | 54 is_solid_color_(other->is_solid_color_), |
| 54 solid_color_(other->solid_color_), | 55 solid_color_(other->solid_color_), |
| 55 recorded_viewport_(other->recorded_viewport_), | 56 recorded_viewport_(other->recorded_viewport_), |
| 56 size_(other->size_), | 57 size_(other->size_), |
| 57 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 58 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
| 58 slow_down_raster_scale_factor_for_debug_( | 59 slow_down_raster_scale_factor_for_debug_( |
| 59 other->slow_down_raster_scale_factor_for_debug_), | 60 other->slow_down_raster_scale_factor_for_debug_), |
| 61 recording_scale_factor_(other->recording_scale_factor_), | |
| 60 image_decode_cache_(other->image_decode_cache_) {} | 62 image_decode_cache_(other->image_decode_cache_) {} |
| 61 | 63 |
| 62 RasterSource::~RasterSource() {} | 64 RasterSource::~RasterSource() {} |
| 63 | 65 |
| 64 void RasterSource::PlaybackToCanvas( | 66 void RasterSource::PlaybackToCanvas( |
| 65 SkCanvas* raster_canvas, | 67 SkCanvas* raster_canvas, |
| 66 const gfx::ColorSpace& target_color_space, | 68 const gfx::ColorSpace& target_color_space, |
| 67 const gfx::Rect& canvas_bitmap_rect, | 69 const gfx::Rect& canvas_bitmap_rect, |
| 68 const gfx::Rect& canvas_playback_rect, | 70 const gfx::Rect& canvas_playback_rect, |
| 69 const gfx::AxisTransform2d& raster_transform, | 71 const gfx::AxisTransform2d& raster_transform, |
| 70 const PlaybackSettings& settings) const { | 72 const PlaybackSettings& settings) const { |
| 71 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); | 73 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); |
| 72 if (!canvas_playback_rect.IsEmpty() && | 74 if (!canvas_playback_rect.IsEmpty() && |
| 73 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) | 75 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) |
| 74 return; | 76 return; |
| 75 // Treat all subnormal values as zero for performance. | 77 // Treat all subnormal values as zero for performance. |
| 76 ScopedSubnormalFloatDisabler disabler; | 78 ScopedSubnormalFloatDisabler disabler; |
| 77 | 79 |
| 78 raster_canvas->save(); | 80 raster_canvas->save(); |
| 79 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); | 81 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); |
| 80 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); | 82 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); |
| 81 raster_canvas->translate(raster_transform.translation().x(), | 83 raster_canvas->translate(raster_transform.translation().x(), |
| 82 raster_transform.translation().y()); | 84 raster_transform.translation().y()); |
| 83 raster_canvas->scale(raster_transform.scale(), raster_transform.scale()); | 85 raster_canvas->scale(raster_transform.scale() / recording_scale_factor_, |
| 86 raster_transform.scale() / recording_scale_factor_); | |
| 84 PlaybackToCanvas(raster_canvas, target_color_space, settings); | 87 PlaybackToCanvas(raster_canvas, target_color_space, settings); |
| 85 raster_canvas->restore(); | 88 raster_canvas->restore(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas, | 91 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas, |
| 89 const gfx::ColorSpace& target_color_space, | 92 const gfx::ColorSpace& target_color_space, |
| 90 const PlaybackSettings& settings) const { | 93 const PlaybackSettings& settings) const { |
| 91 SkCanvas* raster_canvas = input_canvas; | 94 SkCanvas* raster_canvas = input_canvas; |
| 92 std::unique_ptr<SkCanvas> color_transform_canvas; | 95 std::unique_ptr<SkCanvas> color_transform_canvas; |
| 93 if (target_color_space.IsValid()) { | 96 if (target_color_space.IsValid()) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 if (!display_list_) | 238 if (!display_list_) |
| 236 return 0; | 239 return 0; |
| 237 return display_list_->BytesUsed() + painter_reported_memory_usage_; | 240 return display_list_->BytesUsed() + painter_reported_memory_usage_; |
| 238 } | 241 } |
| 239 | 242 |
| 240 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect, | 243 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect, |
| 241 SkColor* color) const { | 244 SkColor* color) const { |
| 242 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); | 245 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); |
| 243 | 246 |
| 244 layer_rect.Intersect(gfx::Rect(size_)); | 247 layer_rect.Intersect(gfx::Rect(size_)); |
| 248 layer_rect = | |
| 249 gfx::ScaleToCornerScaledRect(layer_rect, recording_scale_factor_); | |
|
vmpstr
2017/07/07 22:56:42
Could you add a couple of tests to raster_source_u
| |
| 245 return display_list_->GetColorIfSolidInRect(layer_rect, color); | 250 return display_list_->GetColorIfSolidInRect(layer_rect, color); |
| 246 } | 251 } |
| 247 | 252 |
| 248 void RasterSource::GetDiscardableImagesInRect( | 253 void RasterSource::GetDiscardableImagesInRect( |
| 249 const gfx::Rect& layer_rect, | 254 const gfx::Rect& layer_rect, |
| 250 float contents_scale, | 255 float contents_scale, |
| 251 const gfx::ColorSpace& target_color_space, | 256 const gfx::ColorSpace& target_color_space, |
| 252 std::vector<DrawImage>* images) const { | 257 std::vector<DrawImage>* images) const { |
| 253 DCHECK_EQ(0u, images->size()); | 258 DCHECK_EQ(0u, images->size()); |
| 254 display_list_->GetDiscardableImagesInRect(layer_rect, contents_scale, | 259 display_list_->GetDiscardableImagesInRect(layer_rect, contents_scale, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 use_image_hijack_canvas(true) {} | 320 use_image_hijack_canvas(true) {} |
| 316 | 321 |
| 317 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = | 322 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = |
| 318 default; | 323 default; |
| 319 | 324 |
| 320 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; | 325 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; |
| 321 | 326 |
| 322 RasterSource::PlaybackSettings::~PlaybackSettings() = default; | 327 RasterSource::PlaybackSettings::~PlaybackSettings() = default; |
| 323 | 328 |
| 324 } // namespace cc | 329 } // namespace cc |
| OLD | NEW |