| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/debug/picture_debug_util.h" | 5 #include "cc/debug/picture_debug_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } else { | 47 } else { |
| 48 SkBitmap bm; | 48 SkBitmap bm; |
| 49 // The cast is ok, since we only read the bm. | 49 // The cast is ok, since we only read the bm. |
| 50 if (!bm.installPixels(info, const_cast<void*>(pixels), row_bytes)) { | 50 if (!bm.installPixels(info, const_cast<void*>(pixels), row_bytes)) { |
| 51 return nullptr; | 51 return nullptr; |
| 52 } | 52 } |
| 53 encoding_succeeded = gfx::PNGCodec::EncodeBGRASkBitmap(bm, false, &data); | 53 encoding_succeeded = gfx::PNGCodec::EncodeBGRASkBitmap(bm, false, &data); |
| 54 } | 54 } |
| 55 | 55 |
| 56 if (encoding_succeeded) { | 56 if (encoding_succeeded) { |
| 57 return SkData::NewWithCopy(&data.front(), data.size()); | 57 return SkData::MakeWithCopy(&data.front(), data.size()).release(); |
| 58 } | 58 } |
| 59 return nullptr; | 59 return nullptr; |
| 60 } | 60 } |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 namespace cc { | 65 namespace cc { |
| 66 | 66 |
| 67 void PictureDebugUtil::SerializeAsBase64(const SkPicture* picture, | 67 void PictureDebugUtil::SerializeAsBase64(const SkPicture* picture, |
| 68 std::string* output) { | 68 std::string* output) { |
| 69 SkDynamicMemoryWStream stream; | 69 SkDynamicMemoryWStream stream; |
| 70 BitmapSerializer serializer; | 70 BitmapSerializer serializer; |
| 71 picture->serialize(&stream, &serializer); | 71 picture->serialize(&stream, &serializer); |
| 72 | 72 |
| 73 size_t serialized_size = stream.bytesWritten(); | 73 size_t serialized_size = stream.bytesWritten(); |
| 74 std::unique_ptr<char[]> serialized_picture(new char[serialized_size]); | 74 std::unique_ptr<char[]> serialized_picture(new char[serialized_size]); |
| 75 stream.copyTo(serialized_picture.get()); | 75 stream.copyTo(serialized_picture.get()); |
| 76 base::Base64Encode( | 76 base::Base64Encode( |
| 77 base::StringPiece(serialized_picture.get(), serialized_size), output); | 77 base::StringPiece(serialized_picture.get(), serialized_size), output); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace cc | 80 } // namespace cc |
| OLD | NEW |