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 |
| 14 namespace { |
| 15 // URI label for a lazily decoded SkPixelRef. |
| 16 const char labelLazyDecoded[] = "lazy"; |
| 17 } |
| 18 |
12 namespace cc { | 19 namespace cc { |
13 | 20 |
14 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { | 21 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
15 return make_scoped_refptr(new Picture(layer_rect)); | 22 return make_scoped_refptr(new Picture(layer_rect)); |
16 } | 23 } |
17 | 24 |
18 Picture::Picture(gfx::Rect layer_rect) | 25 Picture::Picture(gfx::Rect layer_rect) |
19 : layer_rect_(layer_rect) { | 26 : layer_rect_(layer_rect) { |
20 } | 27 } |
21 | 28 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 88 |
82 void Picture::Raster(SkCanvas* canvas) { | 89 void Picture::Raster(SkCanvas* canvas) { |
83 TRACE_EVENT0("cc", "Picture::Raster"); | 90 TRACE_EVENT0("cc", "Picture::Raster"); |
84 DCHECK(picture_); | 91 DCHECK(picture_); |
85 canvas->save(); | 92 canvas->save(); |
86 canvas->translate(layer_rect_.x(), layer_rect_.y()); | 93 canvas->translate(layer_rect_.x(), layer_rect_.y()); |
87 canvas->drawPicture(*picture_); | 94 canvas->drawPicture(*picture_); |
88 canvas->restore(); | 95 canvas->restore(); |
89 } | 96 } |
90 | 97 |
| 98 void Picture::GatherPixelRefs(const gfx::Rect& rect, |
| 99 std::list<skia::LazyPixelRef*>& result) { |
| 100 DCHECK(picture_); |
| 101 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( |
| 102 picture_.get(), SkRect::MakeXYWH(rect.x(), |
| 103 rect.y(), |
| 104 rect.width(), |
| 105 rect.height())); |
| 106 if (!pixel_refs) |
| 107 return; |
| 108 |
| 109 void* data = const_cast<void*>(pixel_refs->data()); |
| 110 if (!data) { |
| 111 pixel_refs->unref(); |
| 112 return; |
| 113 } |
| 114 |
| 115 SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); |
| 116 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { |
| 117 if (*refs && (*refs)->getURI() && !strncmp( |
| 118 (*refs)->getURI(), labelLazyDecoded, 4)) { |
| 119 result.push_back(static_cast<skia::LazyPixelRef*>(*refs)); |
| 120 } |
| 121 refs++; |
| 122 } |
| 123 pixel_refs->unref(); |
| 124 } |
| 125 |
91 } // namespace cc | 126 } // namespace cc |
OLD | NEW |