Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2962)

Unified Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 1710553002: Add option for SKP capture without reencoding images (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0011324a554179ba6e0d7900906b68e74b0e52d5 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -9,11 +9,13 @@
#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"
#include "base/strings/string_number_conversions.h"
#include "cc/layers/layer.h"
+// #include "chrome/common/chrome_switches.h"
msarett 2016/02/17 20:47:31 This seems to work (it builds), but the presubmit
#include "content/common/gpu/gpu_messages.h"
#include "content/common/input/synthetic_gesture_params.h"
#include "content/common/input/synthetic_pinch_gesture_params.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();
+ 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();
}
« no previous file with comments | « content/renderer/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698