summaryrefslogtreecommitdiffstats
path: root/content/renderer/skia_benchmarking_extension.cc
diff options
context:
space:
mode:
authorfmalita@chromium.org <fmalita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-14 20:20:50 +0000
committerfmalita@chromium.org <fmalita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-14 20:20:50 +0000
commit3fcc7b4d8ea1eaa79ed72cd2218e022fe19325d3 (patch)
tree42953502cce6954f6028ec61b512d61efc9ee719 /content/renderer/skia_benchmarking_extension.cc
parent2cefb6900138b9899eda98a830aa5fb6c26b2397 (diff)
downloadchromium_src-3fcc7b4d8ea1eaa79ed72cd2218e022fe19325d3.zip
chromium_src-3fcc7b4d8ea1eaa79ed72cd2218e022fe19325d3.tar.gz
chromium_src-3fcc7b4d8ea1eaa79ed72cd2218e022fe19325d3.tar.bz2
Convert Skia benchmarking extension rasterize() output to RGBA.
The native Skia packing format varies depending on platform, compile flags, etc. R=piman@chromium.org Review URL: https://codereview.chromium.org/15004023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/skia_benchmarking_extension.cc')
-rw-r--r--content/renderer/skia_benchmarking_extension.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/content/renderer/skia_benchmarking_extension.cc b/content/renderer/skia_benchmarking_extension.cc
index 7adb77d..2cd44a6 100644
--- a/content/renderer/skia_benchmarking_extension.cc
+++ b/content/renderer/skia_benchmarking_extension.cc
@@ -7,6 +7,7 @@
#include "cc/resources/picture.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBuffer.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "v8/include/v8.h"
@@ -68,7 +69,16 @@ class SkiaBenchmarkingWrapper : public v8::Extension {
WebKit::WebArrayBuffer buffer =
WebKit::WebArrayBuffer::create(bitmap.getSize(), 1);
- memcpy(buffer.data(), bitmap.getPixels(), bitmap.getSize());
+ uint32* packed_pixels = reinterpret_cast<uint32*>(bitmap.getPixels());
+ uint8* buffer_pixels = reinterpret_cast<uint8*>(buffer.data());
+ // Swizzle from native Skia format to RGBA as we copy out.
+ for (size_t i = 0; i < bitmap.getSize(); i += 4) {
+ uint32 c = packed_pixels[i >> 2];
+ buffer_pixels[i] = SkGetPackedR32(c);
+ buffer_pixels[i + 1] = SkGetPackedG32(c);
+ buffer_pixels[i + 2] = SkGetPackedB32(c);
+ buffer_pixels[i + 3] = SkGetPackedA32(c);
+ }
v8::Handle<v8::Object> result = v8::Object::New();
result->Set(v8::String::New("width"), v8::Number::New(rect.width()));