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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 void PicturePileImpl::GatherPixelRefs( | 82 void PicturePileImpl::GatherPixelRefs( |
83 const gfx::Rect& rect, std::list<skia::LazyPixelRef*>& pixel_refs) { | 83 const gfx::Rect& rect, std::list<skia::LazyPixelRef*>& pixel_refs) { |
84 std::list<skia::LazyPixelRef*> result; | 84 std::list<skia::LazyPixelRef*> result; |
85 for (PicturePile::Pile::const_iterator i = pile_.begin(); | 85 for (PicturePile::Pile::const_iterator i = pile_.begin(); |
86 i != pile_.end(); ++i) { | 86 i != pile_.end(); ++i) { |
87 (*i)->GatherPixelRefs(rect, result); | 87 (*i)->GatherPixelRefs(rect, result); |
88 pixel_refs.splice(pixel_refs.end(), result); | 88 pixel_refs.splice(pixel_refs.end(), result); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { | |
93 TRACE_EVENT0("cc", "PicturePileImpl::FlattenToPicture"); | |
94 | |
95 gfx::Rect layer_rect; | |
96 for (PicturePile::Pile::const_iterator i = pile_.begin(); | |
97 i != pile_.end(); ++i) { | |
98 layer_rect.Union((*i)->LayerRect()); | |
99 } | |
100 | |
101 if (layer_rect.IsEmpty()) | |
102 return skia::RefPtr<SkPicture>(); | |
103 | |
104 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); | |
danakj
2013/01/08 15:25:57
yay, great use of skia::RefPtr :)
| |
105 SkCanvas* canvas = picture->beginRecording( | |
106 layer_rect.width(), | |
107 layer_rect.height(), | |
108 SkPicture::kUsePathBoundsForClip_RecordingFlag); | |
109 | |
110 RenderingStats stats; | |
111 Raster(canvas, layer_rect, 1.0, &stats); | |
112 picture->endRecording(); | |
113 | |
114 return picture; | |
115 } | |
116 | |
92 } // namespace cc | 117 } // namespace cc |
OLD | NEW |