summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorscroggo@google.com <scroggo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 21:27:21 +0000
committerscroggo@google.com <scroggo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-22 21:27:21 +0000
commitcd6b154dc5edb27b796a92b52004d8e6ea478ef8 (patch)
treedc6ebfe988ebcd640804e288a4ed0a070d4b2324 /content
parentc13fca6bff97f6254b4396be6b15d3ce5977e29f (diff)
downloadchromium_src-cd6b154dc5edb27b796a92b52004d8e6ea478ef8.zip
chromium_src-cd6b154dc5edb27b796a92b52004d8e6ea478ef8.tar.gz
chromium_src-cd6b154dc5edb27b796a92b52004d8e6ea478ef8.tar.bz2
Use a bitmap encoder when serializing to SkPicture
BUG=168220 Review URL: https://chromiumcodereview.appspot.com/14270002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195602 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/renderer/gpu/gpu_benchmarking_extension.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc
index 8238b42..36d27e3 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -22,6 +22,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSupport.h"
+#include "ui/gfx/codec/png_codec.h"
#include "v8/include/v8.h"
#include "webkit/compositor_bindings/web_rendering_stats_impl.h"
@@ -35,6 +36,15 @@ using WebKit::WebViewBenchmarkSupport;
const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking";
+static bool PNGEncodeBitmapToStream(SkWStream* stream, const SkBitmap& bm) {
+ std::vector<unsigned char> vector;
+ if (gfx::PNGCodec::EncodeBGRASkBitmap(bm, true, &vector)) {
+ if (stream->write(&vector.front() , vector.size()))
+ return true;
+ }
+ return false;
+}
+
namespace {
// Always called on the main render thread.
@@ -73,7 +83,7 @@ class SkPictureRecorder : public WebViewBenchmarkSupport::PaintClient {
DCHECK(!filepath.empty());
SkFILEWStream file(filepath.c_str());
DCHECK(file.isValid());
- picture_.serialize(&file);
+ picture_.serialize(&file, &PNGEncodeBitmapToStream);
}
private: