Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: cc/raster/raster_source.cc

Issue 2563743004: [3/5] Add translated rasterization support for RasterBuffer & below (Closed)
Patch Set: rebase & fix last nits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/raster/raster_source.h ('k') | cc/raster/raster_source_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/debug_colors.h" 12 #include "cc/debug/debug_colors.h"
13 #include "cc/debug/traced_value.h" 13 #include "cc/debug/traced_value.h"
14 #include "cc/paint/display_item_list.h" 14 #include "cc/paint/display_item_list.h"
15 #include "cc/raster/image_hijack_canvas.h" 15 #include "cc/raster/image_hijack_canvas.h"
16 #include "cc/raster/skip_image_canvas.h" 16 #include "cc/raster/skip_image_canvas.h"
17 #include "skia/ext/analysis_canvas.h" 17 #include "skia/ext/analysis_canvas.h"
18 #include "third_party/skia/include/core/SkCanvas.h" 18 #include "third_party/skia/include/core/SkCanvas.h"
19 #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h" 19 #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
20 #include "third_party/skia/include/core/SkPictureRecorder.h" 20 #include "third_party/skia/include/core/SkPictureRecorder.h"
21 #include "ui/gfx/geometry/axis_transform2d.h"
21 #include "ui/gfx/geometry/rect_conversions.h" 22 #include "ui/gfx/geometry/rect_conversions.h"
22 23
23 namespace cc { 24 namespace cc {
24 25
25 scoped_refptr<RasterSource> RasterSource::CreateFromRecordingSource( 26 scoped_refptr<RasterSource> RasterSource::CreateFromRecordingSource(
26 const RecordingSource* other, 27 const RecordingSource* other,
27 bool can_use_lcd_text) { 28 bool can_use_lcd_text) {
28 return make_scoped_refptr(new RasterSource(other, can_use_lcd_text)); 29 return make_scoped_refptr(new RasterSource(other, can_use_lcd_text));
29 } 30 }
30 31
(...skipping 22 matching lines...) Expand all
53 solid_color_(other->solid_color_), 54 solid_color_(other->solid_color_),
54 recorded_viewport_(other->recorded_viewport_), 55 recorded_viewport_(other->recorded_viewport_),
55 size_(other->size_), 56 size_(other->size_),
56 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), 57 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
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(
64 const gfx::ColorSpace& canvas_color_space, 65 SkCanvas* raster_canvas,
65 const gfx::Rect& canvas_bitmap_rect, 66 const gfx::ColorSpace& canvas_color_space,
66 const gfx::Rect& canvas_playback_rect, 67 const gfx::Rect& canvas_bitmap_rect,
67 float raster_scale, 68 const gfx::Rect& canvas_playback_rect,
68 const PlaybackSettings& settings) const { 69 const gfx::AxisTransform2d& raster_transform,
70 const PlaybackSettings& settings) const {
69 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); 71 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect);
70 if (!canvas_playback_rect.IsEmpty() && 72 if (!canvas_playback_rect.IsEmpty() &&
71 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) 73 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect)))
72 return; 74 return;
73 // Treat all subnormal values as zero for performance. 75 // Treat all subnormal values as zero for performance.
74 ScopedSubnormalFloatDisabler disabler; 76 ScopedSubnormalFloatDisabler disabler;
75 77
76 raster_canvas->save(); 78 raster_canvas->save();
77 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); 79 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y());
78 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); 80 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds));
79 raster_canvas->scale(raster_scale, raster_scale); 81 raster_canvas->translate(raster_transform.translation().x(),
82 raster_transform.translation().y());
83 raster_canvas->scale(raster_transform.scale(), raster_transform.scale());
80 PlaybackToCanvas(raster_canvas, canvas_color_space, settings); 84 PlaybackToCanvas(raster_canvas, canvas_color_space, settings);
81 raster_canvas->restore(); 85 raster_canvas->restore();
82 } 86 }
83 87
84 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, 88 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas,
85 const gfx::ColorSpace& canvas_color_space, 89 const gfx::ColorSpace& canvas_color_space,
86 const PlaybackSettings& settings) const { 90 const PlaybackSettings& settings) const {
87 if (!settings.playback_to_shared_canvas) 91 if (!settings.playback_to_shared_canvas)
88 PrepareForPlaybackToCanvas(raster_canvas); 92 PrepareForPlaybackToCanvas(raster_canvas);
89 93
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 use_image_hijack_canvas(true) {} 324 use_image_hijack_canvas(true) {}
321 325
322 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = 326 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) =
323 default; 327 default;
324 328
325 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; 329 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default;
326 330
327 RasterSource::PlaybackSettings::~PlaybackSettings() = default; 331 RasterSource::PlaybackSettings::~PlaybackSettings() = default;
328 332
329 } // namespace cc 333 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/raster_source.h ('k') | cc/raster/raster_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698