| 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" |
| 11 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
| 12 #include "cc/base/scale_translate2d.h" |
| 12 #include "cc/debug/debug_colors.h" | 13 #include "cc/debug/debug_colors.h" |
| 13 #include "cc/playback/display_item_list.h" | 14 #include "cc/playback/display_item_list.h" |
| 14 #include "cc/playback/image_hijack_canvas.h" | 15 #include "cc/playback/image_hijack_canvas.h" |
| 15 #include "cc/playback/skip_image_canvas.h" | 16 #include "cc/playback/skip_image_canvas.h" |
| 16 #include "skia/ext/analysis_canvas.h" | 17 #include "skia/ext/analysis_canvas.h" |
| 17 #include "third_party/skia/include/core/SkCanvas.h" | 18 #include "third_party/skia/include/core/SkCanvas.h" |
| 18 #include "third_party/skia/include/core/SkClipStack.h" | 19 #include "third_party/skia/include/core/SkClipStack.h" |
| 19 #include "third_party/skia/include/core/SkPictureRecorder.h" | 20 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 20 #include "ui/gfx/geometry/rect_conversions.h" | 21 #include "ui/gfx/geometry/rect_conversions.h" |
| 21 | 22 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 other->should_attempt_to_use_distance_field_text_), | 61 other->should_attempt_to_use_distance_field_text_), |
| 61 image_decode_controller_(other->image_decode_controller_) { | 62 image_decode_controller_(other->image_decode_controller_) { |
| 62 } | 63 } |
| 63 | 64 |
| 64 RasterSource::~RasterSource() { | 65 RasterSource::~RasterSource() { |
| 65 } | 66 } |
| 66 | 67 |
| 67 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, | 68 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, |
| 68 const gfx::Rect& canvas_bitmap_rect, | 69 const gfx::Rect& canvas_bitmap_rect, |
| 69 const gfx::Rect& canvas_playback_rect, | 70 const gfx::Rect& canvas_playback_rect, |
| 70 float contents_scale, | 71 const ScaleTranslate2d& contents_transform, |
| 71 const PlaybackSettings& settings) const { | 72 const PlaybackSettings& settings) const { |
| 72 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); | 73 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); |
| 73 if (!canvas_playback_rect.IsEmpty() && | 74 if (!canvas_playback_rect.IsEmpty() && |
| 74 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) | 75 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) |
| 75 return; | 76 return; |
| 76 // Treat all subnormal values as zero for performance. | 77 // Treat all subnormal values as zero for performance. |
| 77 ScopedSubnormalFloatDisabler disabler; | 78 ScopedSubnormalFloatDisabler disabler; |
| 78 | 79 |
| 79 raster_canvas->save(); | 80 raster_canvas->save(); |
| 80 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); | 81 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); |
| 81 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); | 82 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); |
| 82 raster_canvas->scale(contents_scale, contents_scale); | 83 contents_transform.ApplyToCanvas(raster_canvas); |
| 83 PlaybackToCanvas(raster_canvas, settings); | 84 PlaybackToCanvas(raster_canvas, settings); |
| 84 raster_canvas->restore(); | 85 raster_canvas->restore(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, | 88 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, |
| 88 const PlaybackSettings& settings) const { | 89 const PlaybackSettings& settings) const { |
| 89 if (!settings.playback_to_shared_canvas) | 90 if (!settings.playback_to_shared_canvas) |
| 90 PrepareForPlaybackToCanvas(raster_canvas); | 91 PrepareForPlaybackToCanvas(raster_canvas); |
| 91 | 92 |
| 92 if (settings.skip_images) { | 93 if (settings.skip_images) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 bool can_use_lcd_text = false; | 298 bool can_use_lcd_text = false; |
| 298 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text)); | 299 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text)); |
| 299 } | 300 } |
| 300 | 301 |
| 301 RasterSource::PlaybackSettings::PlaybackSettings() | 302 RasterSource::PlaybackSettings::PlaybackSettings() |
| 302 : playback_to_shared_canvas(false), | 303 : playback_to_shared_canvas(false), |
| 303 skip_images(false), | 304 skip_images(false), |
| 304 use_image_hijack_canvas(true) {} | 305 use_image_hijack_canvas(true) {} |
| 305 | 306 |
| 306 } // namespace cc | 307 } // namespace cc |
| OLD | NEW |