Index: cc/picture.cc |
diff --git a/cc/picture.cc b/cc/picture.cc |
index 47d1b23d59d04e808837d423d7a9fdccaf0fd2b2..f190430a79844dc5f4f816773f7d88f47ec69f3c 100644 |
--- a/cc/picture.cc |
+++ b/cc/picture.cc |
@@ -7,8 +7,15 @@ |
#include "cc/picture.h" |
#include "cc/rendering_stats.h" |
#include "third_party/skia/include/core/SkCanvas.h" |
+#include "third_party/skia/include/core/SkData.h" |
+#include "third_party/skia/include/utils/SkPictureUtils.h" |
#include "ui/gfx/rect_conversions.h" |
+namespace { |
+// URI label for a lazily decoded SkPixelRef. |
+const char labelLazyDecoded[] = "lazy"; |
+} |
+ |
namespace cc { |
scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
@@ -88,4 +95,32 @@ void Picture::Raster(SkCanvas* canvas) { |
canvas->restore(); |
} |
+void Picture::GatherPixelRefs(const gfx::Rect& rect, |
+ std::vector<SkPixelRef*>& result) { |
reveman
2012/12/10 17:58:12
should this be a std::vector<LazyPixelRef*> and we
qinmin
2012/12/10 22:52:51
Done.
|
+ DCHECK(picture_); |
+ SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( |
+ picture_.get(), SkRect::MakeXYWH(rect.x(), |
+ rect.y(), |
+ rect.width(), |
+ rect.height())); |
+ if (!pixel_refs) |
+ return; |
+ |
+ void* data = const_cast<void*>(pixel_refs->data()); |
+ if (!data) { |
+ pixel_refs->unref(); |
+ return; |
+ } |
+ |
+ SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data); |
+ for (int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { |
+ if (*refs && (*refs)->getURI() && strncmp( |
+ (*refs)->getURI(), labelLazyDecoded, sizeof(labelLazyDecoded))) { |
+ result.push_back(*refs); |
+ } |
+ refs++; |
+ } |
+ pixel_refs->unref(); |
+} |
+ |
} // namespace cc |