| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 RasterCommon(canvas, NULL, canvas_rect, contents_scale); | 93 RasterCommon(canvas, NULL, canvas_rect, contents_scale); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void PicturePileImpl::RasterForAnalysis(skia::AnalysisCanvas* canvas, | 96 void PicturePileImpl::RasterForAnalysis(skia::AnalysisCanvas* canvas, |
| 97 const gfx::Rect& canvas_rect, | 97 const gfx::Rect& canvas_rect, |
| 98 float contents_scale) const { | 98 float contents_scale) const { |
| 99 RasterCommon(canvas, canvas, canvas_rect, contents_scale); | 99 RasterCommon(canvas, canvas, canvas_rect, contents_scale); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas, | 102 void PicturePileImpl::PlaybackToCanvas(SkCanvas* canvas, |
| 103 const gfx::Rect& canvas_rect, | 103 const gfx::Rect& canvas_bitmap_rect, |
| 104 const gfx::Rect& canvas_playback_rect, |
| 104 float contents_scale) const { | 105 float contents_scale) const { |
| 105 RasterSourceHelper::PrepareForPlaybackToCanvas( | 106 RasterSourceHelper::PrepareForPlaybackToCanvas( |
| 106 canvas, canvas_rect, gfx::Rect(tiling_.tiling_size()), contents_scale, | 107 canvas, canvas_bitmap_rect, canvas_bitmap_rect, |
| 107 background_color_, clear_canvas_with_debug_color_, requires_clear_); | 108 gfx::Rect(tiling_.tiling_size()), contents_scale, background_color_, |
| 108 RasterCommon(canvas, NULL, canvas_rect, contents_scale); | 109 clear_canvas_with_debug_color_, requires_clear_); |
| 110 RasterCommon(canvas, NULL, canvas_bitmap_rect, contents_scale); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, | 113 void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, |
| 112 const gfx::Rect& content_rect, | 114 const gfx::Rect& content_rect, |
| 113 float contents_scale, | 115 float contents_scale, |
| 114 PictureRegionMap* results) const { | 116 PictureRegionMap* results) const { |
| 115 DCHECK(results); | 117 DCHECK(results); |
| 116 // Rasterize the collection of relevant picture piles. | 118 // Rasterize the collection of relevant picture piles. |
| 117 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 119 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
| 118 content_rect, 1.f / contents_scale); | 120 content_rect, 1.f / contents_scale); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 261 } |
| 260 | 262 |
| 261 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { | 263 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { |
| 262 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); | 264 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); |
| 263 | 265 |
| 264 gfx::Rect tiling_rect(tiling_.tiling_size()); | 266 gfx::Rect tiling_rect(tiling_.tiling_size()); |
| 265 SkPictureRecorder recorder; | 267 SkPictureRecorder recorder; |
| 266 SkCanvas* canvas = | 268 SkCanvas* canvas = |
| 267 recorder.beginRecording(tiling_rect.width(), tiling_rect.height()); | 269 recorder.beginRecording(tiling_rect.width(), tiling_rect.height()); |
| 268 if (!tiling_rect.IsEmpty()) | 270 if (!tiling_rect.IsEmpty()) |
| 269 PlaybackToCanvas(canvas, tiling_rect, 1.0); | 271 PlaybackToCanvas(canvas, tiling_rect, tiling_rect, 1.0); |
| 270 skia::RefPtr<SkPicture> picture = | 272 skia::RefPtr<SkPicture> picture = |
| 271 skia::AdoptRef(recorder.endRecordingAsPicture()); | 273 skia::AdoptRef(recorder.endRecordingAsPicture()); |
| 272 | 274 |
| 273 return picture; | 275 return picture; |
| 274 } | 276 } |
| 275 | 277 |
| 276 size_t PicturePileImpl::GetPictureMemoryUsage() const { | 278 size_t PicturePileImpl::GetPictureMemoryUsage() const { |
| 277 return picture_memory_usage_; | 279 return picture_memory_usage_; |
| 278 } | 280 } |
| 279 | 281 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 for (const auto& map_pair : picture_map_) { | 456 for (const auto& map_pair : picture_map_) { |
| 455 const Picture* picture = map_pair.second.get(); | 457 const Picture* picture = map_pair.second.get(); |
| 456 if (processed_pictures.count(picture) == 0) { | 458 if (processed_pictures.count(picture) == 0) { |
| 457 picture->EmitTraceSnapshot(); | 459 picture->EmitTraceSnapshot(); |
| 458 processed_pictures.insert(picture); | 460 processed_pictures.insert(picture); |
| 459 } | 461 } |
| 460 } | 462 } |
| 461 } | 463 } |
| 462 | 464 |
| 463 } // namespace cc | 465 } // namespace cc |
| OLD | NEW |