summaryrefslogtreecommitdiff
path: root/chromium/cc/resources/picture.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/resources/picture.cc')
-rw-r--r--chromium/cc/resources/picture.cc31
1 files changed, 30 insertions, 1 deletions
diff --git a/chromium/cc/resources/picture.cc b/chromium/cc/resources/picture.cc
index 8c5d8512ae3..f9afca9ee3d 100644
--- a/chromium/cc/resources/picture.cc
+++ b/chromium/cc/resources/picture.cc
@@ -93,6 +93,27 @@ Picture::Picture(gfx::Rect layer_rect)
// the picture to be recorded in Picture::Record.
}
+scoped_refptr<Picture> Picture::CreateFromSkpValue(const base::Value* value) {
+ // Decode the picture from base64.
+ std::string encoded;
+ if (!value->GetAsString(&encoded))
+ return NULL;
+
+ std::string decoded;
+ base::Base64Decode(encoded, &decoded);
+ SkMemoryStream stream(decoded.data(), decoded.size());
+
+ // Read the picture. This creates an empty picture on failure.
+ SkPicture* skpicture = SkPicture::CreateFromStream(&stream, &DecodeBitmap);
+ if (skpicture == NULL)
+ return NULL;
+
+ gfx::Rect layer_rect(skpicture->width(), skpicture->height());
+ gfx::Rect opaque_rect(skpicture->width(), skpicture->height());
+
+ return make_scoped_refptr(new Picture(skpicture, layer_rect, opaque_rect));
+}
+
scoped_refptr<Picture> Picture::CreateFromValue(const base::Value* raw_value) {
const base::DictionaryValue* value = NULL;
if (!raw_value->GetAsDictionary(&value))
@@ -178,7 +199,7 @@ void Picture::CloneForDrawing(int num_threads) {
pixel_refs_));
clones_.push_back(clone);
- clone->EmitTraceSnapshot();
+ clone->EmitTraceSnapshotAlias(this);
}
}
@@ -348,6 +369,14 @@ void Picture::EmitTraceSnapshot() {
"cc::Picture", this, TracedPicture::AsTraceablePicture(this));
}
+void Picture::EmitTraceSnapshotAlias(Picture* original) {
+ TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
+ TRACE_DISABLED_BY_DEFAULT("cc.debug"),
+ "cc::Picture",
+ this,
+ TracedPicture::AsTraceablePictureAlias(original));
+}
+
base::LazyInstance<Picture::PixelRefs>
Picture::PixelRefIterator::empty_pixel_refs_;