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

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

Issue 2563743004: [3/5] Add translated rasterization support for RasterBuffer & below (Closed)
Patch Set: Created 4 years 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
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/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 should_attempt_to_use_distance_field_text_( 60 should_attempt_to_use_distance_field_text_(
60 other->should_attempt_to_use_distance_field_text_), 61 other->should_attempt_to_use_distance_field_text_),
61 image_decode_cache_(other->image_decode_cache_) {} 62 image_decode_cache_(other->image_decode_cache_) {}
62 63
63 RasterSource::~RasterSource() { 64 RasterSource::~RasterSource() {
64 } 65 }
65 66
66 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, 67 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas,
67 const gfx::Rect& canvas_bitmap_rect, 68 const gfx::Rect& canvas_bitmap_rect,
68 const gfx::Rect& canvas_playback_rect, 69 const gfx::Rect& canvas_playback_rect,
69 const gfx::SizeF& raster_scales, 70 const ScaleTranslate2d& raster_transform,
70 const PlaybackSettings& settings) const { 71 const PlaybackSettings& settings) const {
71 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); 72 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect);
72 if (!canvas_playback_rect.IsEmpty() && 73 if (!canvas_playback_rect.IsEmpty() &&
73 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) 74 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect)))
74 return; 75 return;
75 // Treat all subnormal values as zero for performance. 76 // Treat all subnormal values as zero for performance.
76 ScopedSubnormalFloatDisabler disabler; 77 ScopedSubnormalFloatDisabler disabler;
77 78
78 raster_canvas->save(); 79 raster_canvas->save();
79 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); 80 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y());
80 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); 81 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds));
81 raster_canvas->scale(raster_scales.width(), raster_scales.height()); 82 raster_transform.ApplyToCanvas(raster_canvas);
82 PlaybackToCanvas(raster_canvas, settings); 83 PlaybackToCanvas(raster_canvas, settings);
83 raster_canvas->restore(); 84 raster_canvas->restore();
84 } 85 }
85 86
86 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, 87 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas,
87 const PlaybackSettings& settings) const { 88 const PlaybackSettings& settings) const {
88 if (!settings.playback_to_shared_canvas) 89 if (!settings.playback_to_shared_canvas)
89 PrepareForPlaybackToCanvas(raster_canvas); 90 PrepareForPlaybackToCanvas(raster_canvas);
90 91
91 if (settings.skip_images) { 92 if (settings.skip_images) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 bool can_use_lcd_text = false; 304 bool can_use_lcd_text = false;
304 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text)); 305 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text));
305 } 306 }
306 307
307 RasterSource::PlaybackSettings::PlaybackSettings() 308 RasterSource::PlaybackSettings::PlaybackSettings()
308 : playback_to_shared_canvas(false), 309 : playback_to_shared_canvas(false),
309 skip_images(false), 310 skip_images(false),
310 use_image_hijack_canvas(true) {} 311 use_image_hijack_canvas(true) {}
311 312
312 } // namespace cc 313 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698