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 const SkIRect skr = skpicture->cullRect().roundOut(); |
125 gfx::Rect layer_rect(skr.x(), skr.y(), skr.width(), skr.height()); | |
danakj
2014/12/12 17:11:37
You can use this https://code.google.com/p/chromiu
reed1
2014/12/12 18:51:35
perfect, thanks.
| |
125 return make_scoped_refptr(new Picture(skpicture, layer_rect)); | 126 return make_scoped_refptr(new Picture(skpicture, layer_rect)); |
126 } | 127 } |
127 | 128 |
128 scoped_refptr<Picture> Picture::CreateFromValue(const base::Value* raw_value) { | 129 scoped_refptr<Picture> Picture::CreateFromValue(const base::Value* raw_value) { |
129 const base::DictionaryValue* value = NULL; | 130 const base::DictionaryValue* value = NULL; |
130 if (!raw_value->GetAsDictionary(&value)) | 131 if (!raw_value->GetAsDictionary(&value)) |
131 return NULL; | 132 return NULL; |
132 | 133 |
133 // Decode the picture from base64. | 134 // Decode the picture from base64. |
134 std::string encoded; | 135 std::string encoded; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 scoped_refptr<base::debug::TracedValue> record_data = | 516 scoped_refptr<base::debug::TracedValue> record_data = |
516 new base::debug::TracedValue(); | 517 new base::debug::TracedValue(); |
517 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); | 518 TracedValue::SetIDRef(this, record_data.get(), "picture_id"); |
518 record_data->BeginArray("layer_rect"); | 519 record_data->BeginArray("layer_rect"); |
519 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); | 520 MathUtil::AddToTracedValue(layer_rect_, record_data.get()); |
520 record_data->EndArray(); | 521 record_data->EndArray(); |
521 return record_data; | 522 return record_data; |
522 } | 523 } |
523 | 524 |
524 } // namespace cc | 525 } // namespace cc |
OLD | NEW |