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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: nits Created 3 years, 6 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) 73 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect)))
74 return; 74 return;
75 // Treat all subnormal values as zero for performance. 75 // Treat all subnormal values as zero for performance.
76 ScopedSubnormalFloatDisabler disabler; 76 ScopedSubnormalFloatDisabler disabler;
77 77
78 raster_canvas->save(); 78 raster_canvas->save();
79 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); 79 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y());
80 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); 80 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds));
81 raster_canvas->translate(raster_transform.translation().x(), 81 raster_canvas->translate(raster_transform.translation().x(),
82 raster_transform.translation().y()); 82 raster_transform.translation().y());
83 raster_canvas->scale(raster_transform.scale(), raster_transform.scale()); 83 if (!display_list_->pixel_canvas_enabled())
84 raster_canvas->scale(raster_transform.scale(), raster_transform.scale());
84 PlaybackToCanvas(raster_canvas, target_color_space, settings); 85 PlaybackToCanvas(raster_canvas, target_color_space, settings);
85 raster_canvas->restore(); 86 raster_canvas->restore();
86 } 87 }
87 88
88 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas, 89 void RasterSource::PlaybackToCanvas(SkCanvas* input_canvas,
89 const gfx::ColorSpace& target_color_space, 90 const gfx::ColorSpace& target_color_space,
90 const PlaybackSettings& settings) const { 91 const PlaybackSettings& settings) const {
91 SkCanvas* raster_canvas = input_canvas; 92 SkCanvas* raster_canvas = input_canvas;
92 std::unique_ptr<SkCanvas> color_transform_canvas; 93 std::unique_ptr<SkCanvas> color_transform_canvas;
93 if (target_color_space.IsValid()) { 94 if (target_color_space.IsValid()) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 231
231 return recorder.finishRecordingAsPicture(); 232 return recorder.finishRecordingAsPicture();
232 } 233 }
233 234
234 size_t RasterSource::GetMemoryUsage() const { 235 size_t RasterSource::GetMemoryUsage() const {
235 if (!display_list_) 236 if (!display_list_)
236 return 0; 237 return 0;
237 return display_list_->BytesUsed() + painter_reported_memory_usage_; 238 return display_list_->BytesUsed() + painter_reported_memory_usage_;
238 } 239 }
239 240
240 bool RasterSource::PerformSolidColorAnalysis(const gfx::Rect& content_rect, 241 bool RasterSource::PerformSolidColorAnalysis(
241 float contents_scale, 242 gfx::Rect content_rect,
242 SkColor* color) const { 243 const gfx::AxisTransform2d& raster_transform,
244 SkColor* color) const {
243 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); 245 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis");
246 if (display_list_->pixel_canvas_enabled()) {
247 content_rect.Intersect(
248 gfx::ScaleToEnclosingRect(gfx::Rect(size_), raster_transform.scale()));
249 } else {
250 content_rect = gfx::ToEnclosingRect(
251 raster_transform.InverseMapRect(gfx::RectF(content_rect)));
252 content_rect.Intersect(gfx::Rect(size_));
253 }
254 skia::AnalysisCanvas canvas(content_rect.width(), content_rect.height());
255 canvas.translate(-content_rect.x(), -content_rect.y());
244 256
245 gfx::Rect layer_rect =
246 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale);
247
248 layer_rect.Intersect(gfx::Rect(size_));
249 skia::AnalysisCanvas canvas(layer_rect.width(), layer_rect.height());
250 canvas.translate(-layer_rect.x(), -layer_rect.y());
251 // Note that because no color conversion is applied to solid color analysis, 257 // Note that because no color conversion is applied to solid color analysis,
252 // the resulting solid color will be known to be sRGB. 258 // the resulting solid color will be known to be sRGB.
253 RasterCommon(&canvas, &canvas); 259 RasterCommon(&canvas, &canvas);
254 return canvas.GetColorIfSolid(color); 260 return canvas.GetColorIfSolid(color);
255 } 261 }
256 262
257 void RasterSource::GetDiscardableImagesInRect( 263 void RasterSource::GetDiscardableImagesInRect(
258 const gfx::Rect& layer_rect, 264 const gfx::Rect& layer_rect,
259 float contents_scale, 265 float contents_scale,
260 const gfx::ColorSpace& target_color_space, 266 const gfx::ColorSpace& target_color_space,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 use_image_hijack_canvas(true) {} 330 use_image_hijack_canvas(true) {}
325 331
326 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) = 332 RasterSource::PlaybackSettings::PlaybackSettings(const PlaybackSettings&) =
327 default; 333 default;
328 334
329 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default; 335 RasterSource::PlaybackSettings::PlaybackSettings(PlaybackSettings&&) = default;
330 336
331 RasterSource::PlaybackSettings::~PlaybackSettings() = default; 337 RasterSource::PlaybackSettings::~PlaybackSettings() = default;
332 338
333 } // namespace cc 339 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698