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/content_layer_client.h" | 6 #include "cc/content_layer_client.h" |
7 #include "cc/picture.h" | 7 #include "cc/picture.h" |
8 #include "cc/rendering_stats.h" | 8 #include "cc/rendering_stats.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkData.h" | |
11 #include "third_party/skia/include/utils/SkPictureUtils.h" | |
10 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
11 | 13 |
12 namespace cc { | 14 namespace cc { |
13 | 15 |
14 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { | 16 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
15 return make_scoped_refptr(new Picture(layer_rect)); | 17 return make_scoped_refptr(new Picture(layer_rect)); |
16 } | 18 } |
17 | 19 |
18 Picture::Picture(gfx::Rect layer_rect) | 20 Picture::Picture(gfx::Rect layer_rect) |
19 : layer_rect_(layer_rect) { | 21 : layer_rect_(layer_rect) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 | 83 |
82 void Picture::Raster(SkCanvas* canvas) { | 84 void Picture::Raster(SkCanvas* canvas) { |
83 TRACE_EVENT0("cc", "Picture::Raster"); | 85 TRACE_EVENT0("cc", "Picture::Raster"); |
84 DCHECK(picture_); | 86 DCHECK(picture_); |
85 canvas->save(); | 87 canvas->save(); |
86 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 88 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
87 canvas->drawPicture(*picture_); | 89 canvas->drawPicture(*picture_); |
88 canvas->restore(); | 90 canvas->restore(); |
89 } | 91 } |
90 | 92 |
93 std::vector<SkPixelRef*> Picture::GatherPixelRefs(const gfx::Rect& rect) { | |
94 DCHECK(picture_); | |
95 SkAutoDataUnref pixel_refs(SkPictureUtils::GatherPixelRefs( | |
Alpha Left Google
2012/12/05 20:24:28
Not all pixelrefs are sklazypixelref. You might ha
qinmin
2012/12/07 05:06:28
Good catch, fixed.
On 2012/12/05 20:24:28, Alpha
| |
96 picture_.get(), SkRect::MakeXYWH(rect.x(), | |
97 rect.y(), | |
98 rect.width(), | |
99 rect.height()))); | |
100 void* data = const_cast<void*>(pixel_refs->data()); | |
101 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); | |
102 std::vector<SkPixelRef*> result( | |
103 refs, refs + pixel_refs->size() / sizeof(SkPixelRef*)); | |
104 return result; | |
105 } | |
106 | |
91 } // namespace cc | 107 } // namespace cc |
OLD | NEW |