OLD | NEW |
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" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 slow_down_raster_scale_factor_for_debug_( | 56 slow_down_raster_scale_factor_for_debug_( |
57 other->slow_down_raster_scale_factor_for_debug_), | 57 other->slow_down_raster_scale_factor_for_debug_), |
58 image_decode_cache_(other->image_decode_cache_) {} | 58 image_decode_cache_(other->image_decode_cache_) {} |
59 | 59 |
60 RasterSource::~RasterSource() { | 60 RasterSource::~RasterSource() { |
61 } | 61 } |
62 | 62 |
63 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, | 63 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, |
64 const gfx::Rect& canvas_bitmap_rect, | 64 const gfx::Rect& canvas_bitmap_rect, |
65 const gfx::Rect& canvas_playback_rect, | 65 const gfx::Rect& canvas_playback_rect, |
66 const gfx::SizeF& raster_scales, | 66 float raster_scale, |
67 const PlaybackSettings& settings) const { | 67 const PlaybackSettings& settings) const { |
68 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); | 68 SkIRect raster_bounds = gfx::RectToSkIRect(canvas_bitmap_rect); |
69 if (!canvas_playback_rect.IsEmpty() && | 69 if (!canvas_playback_rect.IsEmpty() && |
70 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) | 70 !raster_bounds.intersect(gfx::RectToSkIRect(canvas_playback_rect))) |
71 return; | 71 return; |
72 // Treat all subnormal values as zero for performance. | 72 // Treat all subnormal values as zero for performance. |
73 ScopedSubnormalFloatDisabler disabler; | 73 ScopedSubnormalFloatDisabler disabler; |
74 | 74 |
75 raster_canvas->save(); | 75 raster_canvas->save(); |
76 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); | 76 raster_canvas->translate(-canvas_bitmap_rect.x(), -canvas_bitmap_rect.y()); |
77 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); | 77 raster_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); |
78 raster_canvas->scale(raster_scales.width(), raster_scales.height()); | 78 raster_canvas->scale(raster_scale, raster_scale); |
79 PlaybackToCanvas(raster_canvas, settings); | 79 PlaybackToCanvas(raster_canvas, settings); |
80 raster_canvas->restore(); | 80 raster_canvas->restore(); |
81 } | 81 } |
82 | 82 |
83 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, | 83 void RasterSource::PlaybackToCanvas(SkCanvas* raster_canvas, |
84 const PlaybackSettings& settings) const { | 84 const PlaybackSettings& settings) const { |
85 if (!settings.playback_to_shared_canvas) | 85 if (!settings.playback_to_shared_canvas) |
86 PrepareForPlaybackToCanvas(raster_canvas); | 86 PrepareForPlaybackToCanvas(raster_canvas); |
87 | 87 |
88 if (settings.skip_images) { | 88 if (settings.skip_images) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 size_t RasterSource::GetPictureMemoryUsage() const { | 210 size_t RasterSource::GetPictureMemoryUsage() const { |
211 if (!display_list_) | 211 if (!display_list_) |
212 return 0; | 212 return 0; |
213 return display_list_->ApproximateMemoryUsage() + | 213 return display_list_->ApproximateMemoryUsage() + |
214 painter_reported_memory_usage_; | 214 painter_reported_memory_usage_; |
215 } | 215 } |
216 | 216 |
217 bool RasterSource::PerformSolidColorAnalysis(const gfx::Rect& content_rect, | 217 bool RasterSource::PerformSolidColorAnalysis(const gfx::Rect& content_rect, |
218 const gfx::SizeF& raster_scales, | 218 float contents_scale, |
219 SkColor* color) const { | 219 SkColor* color) const { |
220 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); | 220 TRACE_EVENT0("cc", "RasterSource::PerformSolidColorAnalysis"); |
221 | 221 |
222 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 222 gfx::Rect layer_rect = |
223 content_rect, 1.f / raster_scales.width(), 1.f / raster_scales.height()); | 223 gfx::ScaleToEnclosingRect(content_rect, 1.f / contents_scale); |
224 | 224 |
225 layer_rect.Intersect(gfx::Rect(size_)); | 225 layer_rect.Intersect(gfx::Rect(size_)); |
226 skia::AnalysisCanvas canvas(layer_rect.width(), layer_rect.height()); | 226 skia::AnalysisCanvas canvas(layer_rect.width(), layer_rect.height()); |
227 canvas.translate(-layer_rect.x(), -layer_rect.y()); | 227 canvas.translate(-layer_rect.x(), -layer_rect.y()); |
228 RasterCommon(&canvas, &canvas); | 228 RasterCommon(&canvas, &canvas); |
229 return canvas.GetColorIfSolid(color); | 229 return canvas.GetColorIfSolid(color); |
230 } | 230 } |
231 | 231 |
232 void RasterSource::GetDiscardableImagesInRect( | 232 void RasterSource::GetDiscardableImagesInRect( |
233 const gfx::Rect& layer_rect, | 233 const gfx::Rect& layer_rect, |
234 const gfx::SizeF& raster_scales, | 234 float contents_scale, |
235 std::vector<DrawImage>* images) const { | 235 std::vector<DrawImage>* images) const { |
236 DCHECK_EQ(0u, images->size()); | 236 DCHECK_EQ(0u, images->size()); |
237 display_list_->GetDiscardableImagesInRect(layer_rect, raster_scales, images); | 237 display_list_->GetDiscardableImagesInRect(layer_rect, contents_scale, images); |
238 } | 238 } |
239 | 239 |
240 bool RasterSource::CoversRect(const gfx::Rect& layer_rect) const { | 240 bool RasterSource::CoversRect(const gfx::Rect& layer_rect) const { |
241 if (size_.IsEmpty()) | 241 if (size_.IsEmpty()) |
242 return false; | 242 return false; |
243 gfx::Rect bounded_rect = layer_rect; | 243 gfx::Rect bounded_rect = layer_rect; |
244 bounded_rect.Intersect(gfx::Rect(size_)); | 244 bounded_rect.Intersect(gfx::Rect(size_)); |
245 return recorded_viewport_.Contains(bounded_rect); | 245 return recorded_viewport_.Contains(bounded_rect); |
246 } | 246 } |
247 | 247 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 bool can_use_lcd_text = false; | 292 bool can_use_lcd_text = false; |
293 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text)); | 293 return scoped_refptr<RasterSource>(new RasterSource(this, can_use_lcd_text)); |
294 } | 294 } |
295 | 295 |
296 RasterSource::PlaybackSettings::PlaybackSettings() | 296 RasterSource::PlaybackSettings::PlaybackSettings() |
297 : playback_to_shared_canvas(false), | 297 : playback_to_shared_canvas(false), |
298 skip_images(false), | 298 skip_images(false), |
299 use_image_hijack_canvas(true) {} | 299 use_image_hijack_canvas(true) {} |
300 | 300 |
301 } // namespace cc | 301 } // namespace cc |
OLD | NEW |