Chromium Code Reviews| Index: cc/resources/picture.cc |
| diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc |
| index 4c85e7d2092def7d2ce79297abeb3d57fb7b79cd..0beea2f73c2adc2897ff7ee23a8772e9f3272286 100644 |
| --- a/cc/resources/picture.cc |
| +++ b/cc/resources/picture.cc |
| @@ -86,61 +86,62 @@ scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { |
| return make_scoped_refptr(new Picture(layer_rect)); |
| } |
| -scoped_refptr<Picture> Picture::CreateFromValue(const base::Value* value) { |
| - bool success; |
| - scoped_refptr<Picture> picture = |
| - make_scoped_refptr(new Picture(value, &success)); |
| - if (!success) |
| - picture = NULL; |
| - return picture; |
| -} |
| - |
| Picture::Picture(gfx::Rect layer_rect) |
| : layer_rect_(layer_rect) { |
| // Instead of recording a trace event for object creation here, we wait for |
| // the picture to be recorded in Picture::Record. |
| } |
| -Picture::Picture(const base::Value* raw_value, bool* success) { |
| +scoped_refptr<Picture> Picture::CreateFromValue(const base::Value* raw_value) { |
| const base::DictionaryValue* value = NULL; |
| if (!raw_value->GetAsDictionary(&value)) { |
|
vmpstr
2013/06/27 17:22:53
nit: you don't need braces here and below (where t
scroggo
2013/06/27 18:28:59
Done.
|
| - *success = false; |
| - return; |
| + return NULL; |
| } |
| // Decode the picture from base64. |
| std::string encoded; |
| if (!value->GetString("skp64", &encoded)) { |
| - *success = false; |
| - return; |
| + return NULL; |
| } |
| std::string decoded; |
| base::Base64Decode(encoded, &decoded); |
| SkMemoryStream stream(decoded.data(), decoded.size()); |
| - const base::Value* layer_rect = NULL; |
| - if (!value->Get("params.layer_rect", &layer_rect)) { |
| - *success = false; |
| - return; |
| + const base::Value* layer_rect_value = NULL; |
| + if (!value->Get("params.layer_rect", &layer_rect_value)) { |
| + return NULL; |
| } |
| - if (!MathUtil::FromValue(layer_rect, &layer_rect_)) { |
| - *success = false; |
| - return; |
| + |
| + gfx::Rect layer_rect; |
| + if (!MathUtil::FromValue(layer_rect_value, &layer_rect)) { |
| + return NULL; |
| } |
| - const base::Value* opaque_rect = NULL; |
| - if (!value->Get("params.opaque_rect", &opaque_rect)) { |
| - *success = false; |
| - return; |
| + const base::Value* opaque_rect_value = NULL; |
| + if (!value->Get("params.opaque_rect", &opaque_rect_value)) { |
| + return NULL; |
| } |
| - if (!MathUtil::FromValue(opaque_rect, &opaque_rect_)) { |
| - *success = false; |
| - return; |
| + |
| + gfx::Rect opaque_rect; |
| + if (!MathUtil::FromValue(opaque_rect_value, &opaque_rect)) { |
| + return NULL; |
| } |
| // Read the picture. This creates an empty picture on failure. |
| - picture_ = skia::AdoptRef(new SkPicture(&stream, success, &DecodeBitmap)); |
| + SkPicture* skpicture = SkPicture::CreateFromStream(&stream, &DecodeBitmap); |
| + if (NULL == skpicture) { |
|
vmpstr
2013/06/27 17:22:53
nit: I think we typically do the skpicture == NULL
scroggo
2013/06/27 18:28:59
Done.
|
| + return NULL; |
| + } |
| + return make_scoped_refptr(new Picture(skpicture, layer_rect, opaque_rect)); |
| +} |
| + |
| +Picture::Picture(SkPicture* picture, |
| + gfx::Rect layer_rect, |
| + gfx::Rect opaque_rect) : |
| + layer_rect_(layer_rect), |
| + opaque_rect_(opaque_rect), |
| + picture_(skia::AdoptRef(picture)) { |
| } |
| Picture::Picture(const skia::RefPtr<SkPicture>& picture, |