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/raster_source.h" | 5 #include "cc/playback/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 23 matching lines...) Expand all Loading... |
34 requires_clear_(other->requires_clear_), | 34 requires_clear_(other->requires_clear_), |
35 can_use_lcd_text_(can_use_lcd_text), | 35 can_use_lcd_text_(can_use_lcd_text), |
36 is_solid_color_(other->is_solid_color_), | 36 is_solid_color_(other->is_solid_color_), |
37 solid_color_(other->solid_color_), | 37 solid_color_(other->solid_color_), |
38 recorded_viewport_(other->recorded_viewport_), | 38 recorded_viewport_(other->recorded_viewport_), |
39 size_(other->size_), | 39 size_(other->size_), |
40 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 40 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
41 slow_down_raster_scale_factor_for_debug_( | 41 slow_down_raster_scale_factor_for_debug_( |
42 other->slow_down_raster_scale_factor_for_debug_), | 42 other->slow_down_raster_scale_factor_for_debug_), |
43 should_attempt_to_use_distance_field_text_(false), | 43 should_attempt_to_use_distance_field_text_(false), |
44 image_decode_controller_(nullptr) {} | 44 image_decode_cache_(nullptr) {} |
45 | 45 |
46 RasterSource::RasterSource(const RasterSource* other, bool can_use_lcd_text) | 46 RasterSource::RasterSource(const RasterSource* other, bool can_use_lcd_text) |
47 : display_list_(other->display_list_), | 47 : display_list_(other->display_list_), |
48 painter_reported_memory_usage_(other->painter_reported_memory_usage_), | 48 painter_reported_memory_usage_(other->painter_reported_memory_usage_), |
49 background_color_(other->background_color_), | 49 background_color_(other->background_color_), |
50 requires_clear_(other->requires_clear_), | 50 requires_clear_(other->requires_clear_), |
51 can_use_lcd_text_(can_use_lcd_text), | 51 can_use_lcd_text_(can_use_lcd_text), |
52 is_solid_color_(other->is_solid_color_), | 52 is_solid_color_(other->is_solid_color_), |
53 solid_color_(other->solid_color_), | 53 solid_color_(other->solid_color_), |
54 recorded_viewport_(other->recorded_viewport_), | 54 recorded_viewport_(other->recorded_viewport_), |
55 size_(other->size_), | 55 size_(other->size_), |
56 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 56 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
57 slow_down_raster_scale_factor_for_debug_( | 57 slow_down_raster_scale_factor_for_debug_( |
58 other->slow_down_raster_scale_factor_for_debug_), | 58 other->slow_down_raster_scale_factor_for_debug_), |
59 should_attempt_to_use_distance_field_text_( | 59 should_attempt_to_use_distance_field_text_( |
60 other->should_attempt_to_use_distance_field_text_), | 60 other->should_attempt_to_use_distance_field_text_), |
61 image_decode_controller_(other->image_decode_controller_) { | 61 image_decode_cache_(other->image_decode_cache_) {} |
62 } | |
63 | 62 |
64 RasterSource::~RasterSource() { | 63 RasterSource::~RasterSource() { |
65 } | 64 } |
66 | 65 |
67 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, | 66 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, |
68 const gfx::Rect& canvas_bitmap_rect, | 67 const gfx::Rect& canvas_bitmap_rect, |
69 const gfx::Rect& canvas_playback_rect, | 68 const gfx::Rect& canvas_playback_rect, |
70 const gfx::SizeF& raster_scales, | 69 const gfx::SizeF& raster_scales, |
71 const PlaybackSettings& settings) const { | 70 const PlaybackSettings& settings) const { |
72 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); | 71 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); |
(...skipping 15 matching lines...) Expand all Loading... |
88 const PlaybackSettings& settings) const { | 87 const PlaybackSettings& settings) const { |
89 if (!settings.playback_to_shared_canvas) | 88 if (!settings.playback_to_shared_canvas) |
90 PrepareForPlaybackToCanvas(raster_canvas); | 89 PrepareForPlaybackToCanvas(raster_canvas); |
91 | 90 |
92 if (settings.skip_images) { | 91 if (settings.skip_images) { |
93 SkipImageCanvas canvas(raster_canvas); | 92 SkipImageCanvas canvas(raster_canvas); |
94 RasterCommon(&canvas, nullptr); | 93 RasterCommon(&canvas, nullptr); |
95 } else if (settings.use_image_hijack_canvas) { | 94 } else if (settings.use_image_hijack_canvas) { |
96 const SkImageInfo& info = raster_canvas->imageInfo(); | 95 const SkImageInfo& info = raster_canvas->imageInfo(); |
97 | 96 |
98 ImageHijackCanvas canvas(info.width(), info.height(), | 97 ImageHijackCanvas canvas(info.width(), info.height(), image_decode_cache_); |
99 image_decode_controller_); | |
100 // Before adding the canvas, make sure that the ImageHijackCanvas is aware | 98 // Before adding the canvas, make sure that the ImageHijackCanvas is aware |
101 // of the current transform and clip, which may affect the clip bounds. | 99 // of the current transform and clip, which may affect the clip bounds. |
102 // Since we query the clip bounds of the current canvas to get the list of | 100 // Since we query the clip bounds of the current canvas to get the list of |
103 // draw commands to process, this is important to produce correct content. | 101 // draw commands to process, this is important to produce correct content. |
104 SkIRect raster_bounds; | 102 SkIRect raster_bounds; |
105 raster_canvas->getClipDeviceBounds(&raster_bounds); | 103 raster_canvas->getClipDeviceBounds(&raster_bounds); |
106 canvas.clipRect(SkRect::MakeFromIRect(raster_bounds)); | 104 canvas.clipRect(SkRect::MakeFromIRect(raster_bounds)); |
107 canvas.setMatrix(raster_canvas->getTotalMatrix()); | 105 canvas.setMatrix(raster_canvas->getTotalMatrix()); |
108 canvas.addCanvas(raster_canvas); | 106 canvas.addCanvas(raster_canvas); |
109 | 107 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 bool can_use_lcd_text = false; | 303 bool can_use_lcd_text = false; |
306 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text)); | 304 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text)); |
307 } | 305 } |
308 | 306 |
309 RasterSource::PlaybackSettings::PlaybackSettings() | 307 RasterSource::PlaybackSettings::PlaybackSettings() |
310 : playback_to_shared_canvas(false), | 308 : playback_to_shared_canvas(false), |
311 skip_images(false), | 309 skip_images(false), |
312 use_image_hijack_canvas(true) {} | 310 use_image_hijack_canvas(true) {} |
313 | 311 |
314 } // namespace cc | 312 } // namespace cc |
OLD | NEW |