Chromium Code Reviews| Index: content/renderer/gpu/gpu_benchmarking_extension.cc |
| diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc |
| index 1eb6ef33c09af37fb66fa8e02df2b9d3e6fa2d0c..99c2366fdedf4b6a3e20ec9440aa56ea65fb2fd5 100644 |
| --- a/content/renderer/gpu/gpu_benchmarking_extension.cc |
| +++ b/content/renderer/gpu/gpu_benchmarking_extension.cc |
| @@ -9,6 +9,7 @@ |
| #include <utility> |
| #include "base/base64.h" |
| +#include "base/command_line.h" |
| #include "base/files/file_path.h" |
| #include "base/files/file_util.h" |
| #include "base/macros.h" |
| @@ -21,6 +22,7 @@ |
| #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| #include "content/common/input/synthetic_tap_gesture_params.h" |
| #include "content/public/child/v8_value_converter.h" |
| +#include "content/public/common/content_switches.h" |
| #include "content/public/renderer/chrome_object_extensions_utils.h" |
| #include "content/public/renderer/render_thread.h" |
| #include "content/renderer/gpu/render_widget_compositor.h" |
| @@ -54,7 +56,7 @@ namespace content { |
| namespace { |
| -class PNGSerializer : public SkPixelSerializer { |
| +class EncodingSerializer : public SkPixelSerializer { |
| protected: |
| bool onUseEncodedData(const void* data, size_t len) override { return true; } |
| @@ -65,8 +67,41 @@ class PNGSerializer : public SkPixelSerializer { |
| const_cast<void*>(pixmap.addr()), |
| pixmap.rowBytes())) { |
| std::vector<unsigned char> vector; |
| - if (gfx::PNGCodec::EncodeBGRASkBitmap(bm, false, &vector)) { |
| + |
| + const base::CommandLine& commandLine = |
| + *base::CommandLine::ForCurrentProcess(); |
| + if (commandLine.HasSwitch(switches::kSkipReencodingOnSKPCapture)) { |
| + // In this case, we just want to store some useful information |
| + // about the image to replace the missing encoded data. |
| + |
| + // First make sure that the data does not accidentally match any |
| + // image signatures. |
| + vector.push_back(0xFF); |
| + vector.push_back(0xFF); |
| + vector.push_back(0xFF); |
| + vector.push_back(0xFF); |
| + |
| + // Save the width and height. |
| + uint32_t width = bm.width(); |
|
scroggo
2016/02/17 23:13:30
I think you can get all this info from the pixmap
msarett
2016/02/18 16:44:39
Restructured the code to check the flag before ins
|
| + uint32_t height = bm.height(); |
| + vector.push_back(width & 0xFF); |
| + vector.push_back((width >> 8) & 0xFF); |
| + vector.push_back((width >> 16) & 0xFF); |
| + vector.push_back((width >> 24) & 0xFF); |
| + vector.push_back(height & 0xFF); |
| + vector.push_back((height >> 8) & 0xFF); |
| + vector.push_back((height >> 16) & 0xFF); |
| + vector.push_back((height >> 24) & 0xFF); |
| + |
| + // Save any additional information about the bitmap that may be |
| + // interesting. |
| + vector.push_back(bm.colorType()); |
| + vector.push_back(bm.alphaType()); |
| return SkData::NewWithCopy(&vector.front(), vector.size()); |
| + } else { |
| + if (gfx::PNGCodec::EncodeBGRASkBitmap(bm, false, &vector)) { |
| + return SkData::NewWithCopy(&vector.front(), vector.size()); |
| + } |
| } |
| } |
| return nullptr; |
| @@ -106,7 +141,7 @@ class SkPictureSerializer { |
| SkFILEWStream file(filepath.c_str()); |
| DCHECK(file.isValid()); |
| - PNGSerializer serializer; |
| + EncodingSerializer serializer; |
| picture->serialize(&file, &serializer); |
| file.fsync(); |
| } |