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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Sync With ToT Created 3 years, 4 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
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"
(...skipping 14 matching lines...) Expand all
25 : display_list_(other->display_list_), 25 : display_list_(other->display_list_),
26 painter_reported_memory_usage_(other->painter_reported_memory_usage_), 26 painter_reported_memory_usage_(other->painter_reported_memory_usage_),
27 background_color_(other->background_color_), 27 background_color_(other->background_color_),
28 requires_clear_(other->requires_clear_), 28 requires_clear_(other->requires_clear_),
29 is_solid_color_(other->is_solid_color_), 29 is_solid_color_(other->is_solid_color_),
30 solid_color_(other->solid_color_), 30 solid_color_(other->solid_color_),
31 recorded_viewport_(other->recorded_viewport_), 31 recorded_viewport_(other->recorded_viewport_),
32 size_(other->size_), 32 size_(other->size_),
33 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), 33 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
34 slow_down_raster_scale_factor_for_debug_( 34 slow_down_raster_scale_factor_for_debug_(
35 other->slow_down_raster_scale_factor_for_debug_) {} 35 other->slow_down_raster_scale_factor_for_debug_),
36 recording_scale_factor_(other->recording_scale_factor_) {}
36 RasterSource::~RasterSource() = default; 37 RasterSource::~RasterSource() = default;
37 38
38 void RasterSource::PlaybackToCanvas( 39 void RasterSource::PlaybackToCanvas(
39 SkCanvas* raster_canvas, 40 SkCanvas* raster_canvas,
40 const gfx::ColorSpace& target_color_space, 41 const gfx::ColorSpace& target_color_space,
41 const gfx::Rect& canvas_bitmap_rect, 42 const gfx::Rect& canvas_bitmap_rect,
42 const gfx::Rect& canvas_playback_rect, 43 const gfx::Rect& canvas_playback_rect,
43 const gfx::AxisTransform2d& raster_transform, 44 const gfx::AxisTransform2d& raster_transform,
44 const PlaybackSettings& settings) const { 45 const PlaybackSettings& settings) const {
45 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); 46 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect);
46 if (!canvas_playback_rect.IsEmpty() && 47 if (!canvas_playback_rect.IsEmpty() &&
47 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) 48 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect)))
48 return; 49 return;
49 // Treat all subnormal values as zero for performance. 50 // Treat all subnormal values as zero for performance.
50 ScopedSubnormalFloatDisabler disabler; 51 ScopedSubnormalFloatDisabler disabler;
51 52
52 raster_canvas->save(); 53 raster_canvas->save();
53 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); 54 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y());
54 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); 55 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds));
55 raster_canvas->translate(raster_transform.translation().x(), 56 raster_canvas->translate(raster_transform.translation().x(),
56 raster_transform.translation().y()); 57 raster_transform.translation().y());
57 raster_canvas->scale(raster_transform.scale(), raster_transform.scale()); 58 raster_canvas->scale(raster_transform.scale() / recording_scale_factor_,
59 raster_transform.scale() / recording_scale_factor_);
58 PlaybackToCanvas(raster_canvas, target_color_space, settings); 60 PlaybackToCanvas(raster_canvas, target_color_space, settings);
59 raster_canvas->restore(); 61 raster_canvas->restore();
60 } 62 }
61 63
62 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas, 64 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas,
63 const gfx::ColorSpace& target_color_space, 65 const gfx::ColorSpace& target_color_space,
64 const PlaybackSettings& settings) const { 66 const PlaybackSettings& settings) const {
65 SkCanvas* raster_canvas = input_canvas; 67 SkCanvas* raster_canvas = input_canvas;
66 std::unique_ptr<SkCanvas> color_transform_canvas; 68 std::unique_ptr<SkCanvas> color_transform_canvas;
67 if (target_color_space.IsValid()) { 69 if (target_color_space.IsValid()) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (!display_list_) 193 if (!display_list_)
192 return 0; 194 return 0;
193 return display_list_->BytesUsed() + painter_reported_memory_usage_; 195 return display_list_->BytesUsed() + painter_reported_memory_usage_;
194 } 196 }
195 197
196 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect, 198 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect,
197 SkColor* color) const { 199 SkColor* color) const {
198 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); 200 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis");
199 201
200 layer_rect.Intersect(gfx::Rect(size_)); 202 layer_rect.Intersect(gfx::Rect(size_));
203 layer_rect = gfx::ScaleToRoundedRect(layer_rect, recording_scale_factor_);
201 return display_list_->GetColorIfSolidInRect(layer_rect, color); 204 return display_list_->GetColorIfSolidInRect(layer_rect, color);
202 } 205 }
203 206
204 void RasterSource::GetDiscardableImagesInRect( 207 void RasterSource::GetDiscardableImagesInRect(
205 const gfx::Rect& layer_rect, 208 const gfx::Rect& layer_rect,
206 float contents_scale, 209 float contents_scale,
207 const gfx::ColorSpace& target_color_space, 210 const gfx::ColorSpace& target_color_space,
208 std::vector<DrawImage>* images) const { 211 std::vector<DrawImage>* images) const {
209 DCHECK_EQ(0u, images->size()); 212 DCHECK_EQ(0u, images->size());
210 display_list_->discardable_image_map().GetDiscardableImagesInRect( 213 display_list_->discardable_image_map().GetDiscardableImagesInRect(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 use_lcd_text(true) {} 264 use_lcd_text(true) {}
262 265
263 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = 266 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) =
264 default; 267 default;
265 268
266 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; 269 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default;
267 270
268 RasterSource::PlaybackSettings::~PlaybackSettings() = default; 271 RasterSource::PlaybackSettings::~PlaybackSettings() = default;
269 272
270 } // namespace cc 273 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/raster_source.h ('k') | cc/raster/raster_source_unittest.cc » ('j') | ui/views/view.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698