| 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" |
| 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/debug/traced_value.h" | 14 #include "cc/debug/traced_value.h" |
| 14 #include "cc/paint/display_item_list.h" | 15 #include "cc/paint/display_item_list.h" |
| 15 #include "cc/raster/image_hijack_canvas.h" | 16 #include "cc/raster/image_hijack_canvas.h" |
| 16 #include "cc/raster/skip_image_canvas.h" | 17 #include "cc/raster/skip_image_canvas.h" |
| 17 #include "skia/ext/analysis_canvas.h" | 18 #include "skia/ext/analysis_canvas.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
| 19 #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h" | 20 #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h" |
| 20 #include "third_party/skia/include/core/SkPictureRecorder.h" | 21 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 21 #include "ui/gfx/geometry/rect_conversions.h" | 22 #include "ui/gfx/geometry/rect_conversions.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 slow_down_raster_scale_factor_for_debug_( | 58 slow_down_raster_scale_factor_for_debug_( |
| 58 other->slow_down_raster_scale_factor_for_debug_), | 59 other->slow_down_raster_scale_factor_for_debug_), |
| 59 image_decode_cache_(other->image_decode_cache_) {} | 60 image_decode_cache_(other->image_decode_cache_) {} |
| 60 | 61 |
| 61 RasterSource::~RasterSource() {} | 62 RasterSource::~RasterSource() {} |
| 62 | 63 |
| 63 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, | 64 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, |
| 64 const gfx::ColorSpace& canvas_color_space, | 65 const gfx::ColorSpace& canvas_color_space, |
| 65 const gfx::Rect& canvas_bitmap_rect, | 66 const gfx::Rect& canvas_bitmap_rect, |
| 66 const gfx::Rect& canvas_playback_rect, | 67 const gfx::Rect& canvas_playback_rect, |
| 67 float raster_scale, | 68 const ScaleTranslate2d& raster_transform, |
| 68 const PlaybackSettings& settings) const { | 69 const PlaybackSettings& settings) const { |
| 69 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); | 70 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); |
| 70 if (!canvas_playback_rect.IsEmpty() && | 71 if (!canvas_playback_rect.IsEmpty() && |
| 71 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) | 72 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) |
| 72 return; | 73 return; |
| 73 // Treat all subnormal values as zero for performance. | 74 // Treat all subnormal values as zero for performance. |
| 74 ScopedSubnormalFloatDisabler disabler; | 75 ScopedSubnormalFloatDisabler disabler; |
| 75 | 76 |
| 76 raster_canvas->save(); | 77 raster_canvas->save(); |
| 77 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); | 78 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); |
| 78 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); | 79 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); |
| 79 raster_canvas->scale(raster_scale, raster_scale); | 80 raster_transform.ApplyToCanvas(raster_canvas); |
| 80 PlaybackToCanvas(raster_canvas, canvas_color_space, settings); | 81 PlaybackToCanvas(raster_canvas, canvas_color_space, settings); |
| 81 raster_canvas->restore(); | 82 raster_canvas->restore(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, | 85 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, |
| 85 const gfx::ColorSpace& canvas_color_space, | 86 const gfx::ColorSpace& canvas_color_space, |
| 86 const PlaybackSettings& settings) const { | 87 const PlaybackSettings& settings) const { |
| 87 if (!settings.playback_to_shared_canvas) | 88 if (!settings.playback_to_shared_canvas) |
| 88 PrepareForPlaybackToCanvas(raster_canvas); | 89 PrepareForPlaybackToCanvas(raster_canvas); |
| 89 | 90 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 use_image_hijack_canvas(true) {} | 321 use_image_hijack_canvas(true) {} |
| 321 | 322 |
| 322 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = | 323 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = |
| 323 default; | 324 default; |
| 324 | 325 |
| 325 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; | 326 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; |
| 326 | 327 |
| 327 RasterSource::PlaybackSettings::~PlaybackSettings() = default; | 328 RasterSource::PlaybackSettings::~PlaybackSettings() = default; |
| 328 | 329 |
| 329 } // namespace cc | 330 } // namespace cc |
| OLD | NEW |