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 "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
6 #include "cc/picture_pile_impl.h" | 6 #include "cc/picture_pile_impl.h" |
7 #include "cc/rendering_stats.h" | 7 #include "cc/rendering_stats.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
9 #include "third_party/skia/include/core/SkSize.h" | 9 #include "third_party/skia/include/core/SkSize.h" |
10 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void PicturePileImpl::GatherPixelRefs( | 90 void PicturePileImpl::GatherPixelRefs( |
91 const gfx::Rect& rect, std::list<skia::LazyPixelRef*>& pixel_refs) { | 91 const gfx::Rect& rect, std::list<skia::LazyPixelRef*>& pixel_refs) { |
92 std::list<skia::LazyPixelRef*> result; | 92 std::list<skia::LazyPixelRef*> result; |
93 for (PicturePile::Pile::const_iterator i = pile_.begin(); | 93 for (PicturePile::Pile::const_iterator i = pile_.begin(); |
94 i != pile_.end(); ++i) { | 94 i != pile_.end(); ++i) { |
95 (*i)->GatherPixelRefs(rect, result); | 95 (*i)->GatherPixelRefs(rect, result); |
96 pixel_refs.splice(pixel_refs.end(), result); | 96 pixel_refs.splice(pixel_refs.end(), result); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
| 100 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { |
| 101 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); |
| 102 |
| 103 gfx::Rect layer_rect; |
| 104 for (PicturePile::Pile::const_iterator i = pile_.begin(); |
| 105 i != pile_.end(); ++i) { |
| 106 layer_rect.Union((*i)->LayerRect()); |
| 107 } |
| 108 |
| 109 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); |
| 110 if (layer_rect.IsEmpty()) |
| 111 return picture; |
| 112 |
| 113 SkCanvas* canvas = picture->beginRecording( |
| 114 layer_rect.width(), |
| 115 layer_rect.height(), |
| 116 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
| 117 |
| 118 RenderingStats stats; |
| 119 Raster(canvas, layer_rect, 1.0, &stats); |
| 120 picture->endRecording(); |
| 121 |
| 122 return picture; |
| 123 } |
| 124 |
100 } // namespace cc | 125 } // namespace cc |
OLD | NEW |