OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <limits> | 6 #include <limits> |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 RasterCommon(canvas, NULL, canvas_rect, contents_scale); | 83 RasterCommon(canvas, NULL, canvas_rect, contents_scale); |
84 } | 84 } |
85 | 85 |
86 void PicturePileImpl::RasterForAnalysis(skia::AnalysisCanvas* canvas, | 86 void PicturePileImpl::RasterForAnalysis(skia::AnalysisCanvas* canvas, |
87 const gfx::Rect& canvas_rect, | 87 const gfx::Rect& canvas_rect, |
88 float contents_scale) const { | 88 float contents_scale) const { |
89 RasterCommon(canvas, canvas, canvas_rect, contents_scale); | 89 RasterCommon(canvas, canvas, canvas_rect, contents_scale); |
90 } | 90 } |
91 | 91 |
92 void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas, | 92 void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas, |
93 const gfx::Rect& canvas_rect, | 93 const gfx::Rect& canvas_bitmap_rect, |
| 94 const gfx::Rect& canvas_playback_rect, |
94 float contents_scale) const { | 95 float contents_scale) const { |
95 RasterSourceHelper::PrepareForPlaybackToCanvas( | 96 RasterSourceHelper::PrepareForPlaybackToCanvas( |
96 canvas, canvas_rect, gfx::Rect(tiling_.tiling_size()), contents_scale, | 97 canvas, canvas_bitmap_rect, canvas_playback_rect, |
97 background_color_, clear_canvas_with_debug_color_, requires_clear_); | 98 gfx::Rect(tiling_.tiling_size()), contents_scale, background_color_, |
98 RasterCommon(canvas, NULL, canvas_rect, contents_scale); | 99 clear_canvas_with_debug_color_, requires_clear_); |
| 100 RasterCommon(canvas, NULL, canvas_bitmap_rect, contents_scale); |
99 } | 101 } |
100 | 102 |
101 void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, | 103 void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, |
102 const gfx::Rect& content_rect, | 104 const gfx::Rect& content_rect, |
103 float contents_scale, | 105 float contents_scale, |
104 PictureRegionMap* results) const { | 106 PictureRegionMap* results) const { |
105 DCHECK(results); | 107 DCHECK(results); |
106 // Rasterize the collection of relevant picture piles. | 108 // Rasterize the collection of relevant picture piles. |
107 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 109 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
108 content_rect, 1.f / contents_scale); | 110 content_rect, 1.f / contents_scale); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 251 } |
250 | 252 |
251 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { | 253 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { |
252 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); | 254 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); |
253 | 255 |
254 gfx::Rect tiling_rect(tiling_.tiling_size()); | 256 gfx::Rect tiling_rect(tiling_.tiling_size()); |
255 SkPictureRecorder recorder; | 257 SkPictureRecorder recorder; |
256 SkCanvas* canvas = | 258 SkCanvas* canvas = |
257 recorder.beginRecording(tiling_rect.width(), tiling_rect.height()); | 259 recorder.beginRecording(tiling_rect.width(), tiling_rect.height()); |
258 if (!tiling_rect.IsEmpty()) | 260 if (!tiling_rect.IsEmpty()) |
259 PlaybackToCanvas(canvas, tiling_rect, 1.0); | 261 PlaybackToCanvas(canvas, tiling_rect, tiling_rect, 1.0); |
260 skia::RefPtr<SkPicture> picture = | 262 skia::RefPtr<SkPicture> picture = |
261 skia::AdoptRef(recorder.endRecordingAsPicture()); | 263 skia::AdoptRef(recorder.endRecordingAsPicture()); |
262 | 264 |
263 return picture; | 265 return picture; |
264 } | 266 } |
265 | 267 |
266 size_t PicturePileImpl::GetPictureMemoryUsage() const { | 268 size_t PicturePileImpl::GetPictureMemoryUsage() const { |
267 // Place all pictures in a set to de-dupe. | 269 // Place all pictures in a set to de-dupe. |
268 size_t total_size = 0; | 270 size_t total_size = 0; |
269 std::set<const Picture*> pictures_seen; | 271 std::set<const Picture*> pictures_seen; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 for (const auto& map_pair : picture_map_) { | 455 for (const auto& map_pair : picture_map_) { |
454 const Picture* picture = map_pair.second.get(); | 456 const Picture* picture = map_pair.second.get(); |
455 if (processed_pictures.count(picture) == 0) { | 457 if (processed_pictures.count(picture) == 0) { |
456 picture->EmitTraceSnapshot(); | 458 picture->EmitTraceSnapshot(); |
457 processed_pictures.insert(picture); | 459 processed_pictures.insert(picture); |
458 } | 460 } |
459 } | 461 } |
460 } | 462 } |
461 | 463 |
462 } // namespace cc | 464 } // namespace cc |
OLD | NEW |