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 "cc/resources/picture.h" | 5 #include "cc/resources/picture.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 std::string decoded; | 115 std::string decoded; |
116 base::Base64Decode(encoded, &decoded); | 116 base::Base64Decode(encoded, &decoded); |
117 SkMemoryStream stream(decoded.data(), decoded.size()); | 117 SkMemoryStream stream(decoded.data(), decoded.size()); |
118 | 118 |
119 // Read the picture. This creates an empty picture on failure. | 119 // Read the picture. This creates an empty picture on failure. |
120 SkPicture* skpicture = SkPicture::CreateFromStream(&stream, &DecodeBitmap); | 120 SkPicture* skpicture = SkPicture::CreateFromStream(&stream, &DecodeBitmap); |
121 if (skpicture == NULL) | 121 if (skpicture == NULL) |
122 return NULL; | 122 return NULL; |
123 | 123 |
124 gfx::Rect layer_rect(skpicture->width(), skpicture->height()); | 124 gfx::Rect layer_rect(gfx::SkIRectToRect(skpicture->cullRect().roundOut())); |
125 return make_scoped_refptr(new Picture(skpicture, layer_rect)); | 125 return make_scoped_refptr(new Picture(skpicture, layer_rect)); |
126 } | 126 } |
127 | 127 |
128 scoped_refptr<Picture> Picture::CreateFromValue(const base::Value* raw_value) { | 128 scoped_refptr<Picture> Picture::CreateFromValue(const base::Value* raw_value) { |
129 const base::DictionaryValue* value = NULL; | 129 const base::DictionaryValue* value = NULL; |
130 if (!raw_value->GetAsDictionary(&value)) | 130 if (!raw_value->GetAsDictionary(&value)) |
131 return NULL; | 131 return NULL; |
132 | 132 |
133 // Decode the picture from base64. | 133 // Decode the picture from base64. |
134 std::string encoded; | 134 std::string encoded; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 scoped_refptr<base::debug::TracedValue> record_data = | 515 scoped_refptr<base::debug::TracedValue> record_data = |
516 new base::debug::TracedValue(); | 516 new base::debug::TracedValue(); |
517 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); | 517 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); |
518 record_data->BeginArray("layer_rect"); | 518 record_data->BeginArray("layer_rect"); |
519 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); | 519 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); |
520 record_data->EndArray(); | 520 record_data->EndArray(); |
521 return record_data; | 521 return record_data; |
522 } | 522 } |
523 | 523 |
524 } // namespace cc | 524 } // namespace cc |
OLD | NEW |