Chromium Code Reviews| 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..c82c0c40f66d90dfa1485746f932b5554f40308c 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,19 @@ 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; |
| + paint.setColorFilter(SkLumaColorFilter::Create()); |
|
bsalomon
2014/02/06 20:09:14
The color filter is leaking here. One fix is:
pai
mfomitchev
2014/02/07 19:05:44
Think we have to unref the filter, not the paint?
|
| + 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); |
| } |