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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Resolving comments and sync with ToT Created 3 years, 5 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 17 matching lines...) Expand all
28 painter_reported_memory_usage_(other->painter_reported_memory_usage_), 28 painter_reported_memory_usage_(other->painter_reported_memory_usage_),
29 background_color_(other->background_color_), 29 background_color_(other->background_color_),
30 requires_clear_(other->requires_clear_), 30 requires_clear_(other->requires_clear_),
31 is_solid_color_(other->is_solid_color_), 31 is_solid_color_(other->is_solid_color_),
32 solid_color_(other->solid_color_), 32 solid_color_(other->solid_color_),
33 recorded_viewport_(other->recorded_viewport_), 33 recorded_viewport_(other->recorded_viewport_),
34 size_(other->size_), 34 size_(other->size_),
35 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), 35 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
36 slow_down_raster_scale_factor_for_debug_( 36 slow_down_raster_scale_factor_for_debug_(
37 other->slow_down_raster_scale_factor_for_debug_), 37 other->slow_down_raster_scale_factor_for_debug_),
38 recording_scale_factor_(other->recording_scale_factor_),
38 image_decode_cache_(nullptr) {} 39 image_decode_cache_(nullptr) {}
39 RasterSource::~RasterSource() = default; 40 RasterSource::~RasterSource() = default;
40 41
41 void RasterSource::PlaybackToCanvas( 42 void RasterSource::PlaybackToCanvas(
42 SkCanvas* raster_canvas, 43 SkCanvas* raster_canvas,
43 const gfx::ColorSpace& target_color_space, 44 const gfx::ColorSpace& target_color_space,
44 const gfx::Rect& canvas_bitmap_rect, 45 const gfx::Rect& canvas_bitmap_rect,
45 const gfx::Rect& canvas_playback_rect, 46 const gfx::Rect& canvas_playback_rect,
46 const gfx::AxisTransform2d& raster_transform, 47 const gfx::AxisTransform2d& raster_transform,
47 const PlaybackSettings& settings) const { 48 const PlaybackSettings& settings) const {
48 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); 49 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect);
49 if (!canvas_playback_rect.IsEmpty() && 50 if (!canvas_playback_rect.IsEmpty() &&
50 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) 51 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect)))
51 return; 52 return;
52 // Treat all subnormal values as zero for performance. 53 // Treat all subnormal values as zero for performance.
53 ScopedSubnormalFloatDisabler disabler; 54 ScopedSubnormalFloatDisabler disabler;
54 55
55 raster_canvas->save(); 56 raster_canvas->save();
56 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); 57 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y());
57 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); 58 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds));
58 raster_canvas->translate(raster_transform.translation().x(), 59 raster_canvas->translate(raster_transform.translation().x(),
59 raster_transform.translation().y()); 60 raster_transform.translation().y());
60 raster_canvas->scale(raster_transform.scale(), raster_transform.scale()); 61 raster_canvas->scale(raster_transform.scale() / recording_scale_factor_,
62 raster_transform.scale() / recording_scale_factor_);
61 PlaybackToCanvas(raster_canvas, target_color_space, settings); 63 PlaybackToCanvas(raster_canvas, target_color_space, settings);
62 raster_canvas->restore(); 64 raster_canvas->restore();
63 } 65 }
64 66
65 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas, 67 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas,
66 const gfx::ColorSpace& target_color_space, 68 const gfx::ColorSpace& target_color_space,
67 const PlaybackSettings& settings) const { 69 const PlaybackSettings& settings) const {
68 SkCanvas* raster_canvas = input_canvas; 70 SkCanvas* raster_canvas = input_canvas;
69 std::unique_ptr<SkCanvas> color_transform_canvas; 71 std::unique_ptr<SkCanvas> color_transform_canvas;
70 if (target_color_space.IsValid()) { 72 if (target_color_space.IsValid()) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (!display_list_) 214 if (!display_list_)
213 return 0; 215 return 0;
214 return display_list_->BytesUsed() + painter_reported_memory_usage_; 216 return display_list_->BytesUsed() + painter_reported_memory_usage_;
215 } 217 }
216 218
217 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect, 219 bool RasterSource::PerformSolidColorAnalysis(gfx::Rect layer_rect,
218 SkColor* color) const { 220 SkColor* color) const {
219 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); 221 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis");
220 222
221 layer_rect.Intersect(gfx::Rect(size_)); 223 layer_rect.Intersect(gfx::Rect(size_));
224 layer_rect = gfx::ScaleToRoundedRect(layer_rect, recording_scale_factor_);
222 return display_list_->GetColorIfSolidInRect(layer_rect, color); 225 return display_list_->GetColorIfSolidInRect(layer_rect, color);
223 } 226 }
224 227
225 void RasterSource::GetDiscardableImagesInRect( 228 void RasterSource::GetDiscardableImagesInRect(
226 const gfx::Rect& layer_rect, 229 const gfx::Rect& layer_rect,
227 float contents_scale, 230 float contents_scale,
228 const gfx::ColorSpace& target_color_space, 231 const gfx::ColorSpace& target_color_space,
229 std::vector<DrawImage>* images) const { 232 std::vector<DrawImage>* images) const {
230 DCHECK_EQ(0u, images->size()); 233 DCHECK_EQ(0u, images->size());
231 display_list_->discardable_image_map().GetDiscardableImagesInRect( 234 display_list_->discardable_image_map().GetDiscardableImagesInRect(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 use_lcd_text(true) {} 287 use_lcd_text(true) {}
285 288
286 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = 289 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) =
287 default; 290 default;
288 291
289 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; 292 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default;
290 293
291 RasterSource::PlaybackSettings::~PlaybackSettings() = default; 294 RasterSource::PlaybackSettings::~PlaybackSettings() = default;
292 295
293 } // namespace cc 296 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698