Index: content/browser/frame_host/navigation_entry_screenshot_manager.cc |
diff --git a/content/browser/frame_host/navigation_entry_screenshot_manager.cc b/content/browser/frame_host/navigation_entry_screenshot_manager.cc |
index 0b955fc6d7c5aca41e1a07b02b0a42f5c7fffe66..b2bf429dc0a6c66a34266a5267ed62267a8aacb6 100644 |
--- a/content/browser/frame_host/navigation_entry_screenshot_manager.cc |
+++ b/content/browser/frame_host/navigation_entry_screenshot_manager.cc |
@@ -12,6 +12,9 @@ |
#include "content/public/browser/render_widget_host.h" |
#include "content/public/browser/render_widget_host_view.h" |
#include "content/public/common/content_switches.h" |
+#include "third_party/skia/include/core/SkCanvas.h" |
+#include "third_party/skia/include/core/SkPaint.h" |
+#include "third_party/skia/include/effects/SkLumaColorFilter.h" |
#include "ui/gfx/codec/png_codec.h" |
namespace { |
@@ -23,7 +26,7 @@ const int kMinScreenshotIntervalMS = 1000; |
namespace content { |
-// Encodes an SkBitmap to PNG data in a worker thread. |
+// Converts SkBitmap to grayscale and encodes to PNG data in a worker thread. |
class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> { |
public: |
ScreenshotData() { |
@@ -49,7 +52,21 @@ class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> { |
void EncodeOnWorker(const SkBitmap& bitmap) { |
std::vector<unsigned char> data; |
- if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &data)) |
+ // Paint |bitmap| to a kA8_Config SkBitmap |
+ SkBitmap a8Bitmap; |
+ a8Bitmap.setConfig(SkBitmap::kA8_Config, |
+ bitmap.width(), |
+ bitmap.height(), |
+ 0); |
+ a8Bitmap.allocPixels(); |
+ SkCanvas canvas(a8Bitmap); |
+ SkPaint paint; |
+ SkColorFilter* filter = SkLumaColorFilter::Create(); |
+ paint.setColorFilter(filter); |
+ filter->unref(); |
+ canvas.drawBitmap(bitmap, SK_Scalar1, SK_Scalar1, &paint); |
+ // Encode the a8Bitmap to grayscale PNG treating alpha as color intensity |
+ if (gfx::PNGCodec::EncodeA8SkBitmap(a8Bitmap, &data)) |
data_ = new base::RefCountedBytes(data); |
} |