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

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

Issue 15496006: Use the new function signature for EncodeBitmap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | « cc/resources/picture.cc ('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 146769b5a4f998cb3dbb848d54204786d0a10371..84b3346b7199162ac137bcdb4bd64dacd158ecfb 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -21,8 +21,10 @@
#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 "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "third_party/skia/include/core/SkPicture.h"
+#include "third_party/skia/include/core/SkPixelRef.h"
#include "third_party/skia/include/core/SkStream.h"
#include "ui/gfx/codec/png_codec.h"
#include "v8/include/v8.h"
@@ -38,13 +40,20 @@ using WebKit::WebViewBenchmarkSupport;
const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking";
-static bool PNGEncodeBitmapToStream(SkWStream* stream, const SkBitmap& bm) {
+static SkData* EncodeBitmapToData(size_t* offset, const SkBitmap& bm) {
+ SkPixelRef* pr = bm.pixelRef();
+ if (pr != NULL) {
+ SkData* data = pr->refEncodedData();
+ if (data != NULL) {
+ *offset = bm.pixelRefOffset();
+ return data;
+ }
+ }
std::vector<unsigned char> vector;
if (gfx::PNGCodec::EncodeBGRASkBitmap(bm, true, &vector)) {
- if (stream->write(&vector.front() , vector.size()))
- return true;
+ return SkData::NewWithCopy(&vector.front() , vector.size());
}
- return false;
+ return NULL;
}
namespace {
@@ -75,7 +84,7 @@ class SkPictureRecorder : public WebViewBenchmarkSupport::PaintClient {
DCHECK(!filepath.empty());
SkFILEWStream file(filepath.c_str());
DCHECK(file.isValid());
- picture_.serialize(&file, &PNGEncodeBitmapToStream);
+ picture_.serialize(&file, &EncodeBitmapToData);
}
private:
« no previous file with comments | « cc/resources/picture.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698