Chromium Code Reviews| Index: cc/debug/picture_debug_util.cc |
| diff --git a/cc/debug/picture_debug_util.cc b/cc/debug/picture_debug_util.cc |
| index f20715fc2960ffab9312f8998090caa18ee9eaf5..55a040f782cc5338ea45f6c8838f6c0ca3181a82 100644 |
| --- a/cc/debug/picture_debug_util.cc |
| +++ b/cc/debug/picture_debug_util.cc |
| @@ -28,23 +28,21 @@ class BitmapSerializer : public SkPixelSerializer { |
| bool onUseEncodedData(const void* data, size_t len) override { return true; } |
| SkData* onEncode(const SkPixmap& pixmap) override { |
| - const SkImageInfo& info = pixmap.info(); |
| - const void* pixels = pixmap.addr(); |
| - size_t row_bytes = pixmap.rowBytes(); |
| - const int kJpegQuality = 80; |
| std::vector<unsigned char> data; |
| // If bitmap is opaque, encode as JPEG. |
| // Otherwise encode as PNG. |
| bool encoding_succeeded = false; |
| - if (info.isOpaque()) { |
| - DCHECK_LE(row_bytes, |
| + if (pixmap.isOpaque()) { |
| + const int kJpegQuality = 80; |
|
dcheng
2017/06/12 20:35:43
Nit: constexpr
msarett1
2017/06/12 20:57:56
Will fix.
msarett1
2017/06/12 21:43:11
Done.
|
| + DCHECK_LE(pixmap.rowBytes(), |
| static_cast<size_t>(std::numeric_limits<int>::max())); |
|
dcheng
2017/06/12 20:35:43
This DCHECK probably isn't needed anymore.
msarett1
2017/06/12 20:57:56
Will fix.
msarett1
2017/06/12 21:43:11
Done.
|
| - encoding_succeeded = gfx::JPEGCodec::Encode( |
| - reinterpret_cast<const unsigned char*>(pixels), |
| - gfx::JPEGCodec::FORMAT_SkBitmap, info.width(), info.height(), |
| - static_cast<int>(row_bytes), kJpegQuality, &data); |
| + encoding_succeeded = gfx::JPEGCodec::Encode(pixmap, kJpegQuality, &data); |
| } else { |
| + const SkImageInfo& info = pixmap.info(); |
| + const void* pixels = pixmap.addr(); |
| + size_t row_bytes = pixmap.rowBytes(); |
| + |
| SkBitmap bm; |
| // The cast is ok, since we only read the bm. |
| if (!bm.installPixels(info, const_cast<void*>(pixels), row_bytes)) { |