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 1e476827703d617b9759edfe17c9d3d564ed2a66..4959ba8692830bd7491b356078090358257fff51 100644 |
--- a/content/browser/frame_host/navigation_entry_screenshot_manager.cc |
+++ b/content/browser/frame_host/navigation_entry_screenshot_manager.cc |
@@ -13,9 +13,6 @@ |
#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 { |
@@ -53,21 +50,8 @@ class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> { |
void EncodeOnWorker(const SkBitmap& bitmap) { |
std::vector<unsigned char> 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, SkIntToScalar(0), SkIntToScalar(0), &paint); |
- // Encode the a8Bitmap to grayscale PNG treating alpha as color intensity |
- if (gfx::PNGCodec::EncodeA8SkBitmap(a8Bitmap, &data)) |
+ // Encode the A8 bitmap to grayscale PNG treating alpha as color intensity. |
danakj
2014/07/10 19:13:02
you can dcheck the bitmap config here if you like?
mfomitchev
2014/07/11 19:46:07
Done. I did it in the other place because the stac
|
+ if (gfx::PNGCodec::EncodeA8SkBitmap(bitmap, &data)) |
data_ = new base::RefCountedBytes(data); |
} |
@@ -134,14 +118,13 @@ void NavigationEntryScreenshotManager::TakeScreenshotImpl( |
NavigationEntryImpl* entry) { |
DCHECK(host && host->GetView()); |
DCHECK(entry); |
- SkBitmap::Config preferred_format = host->PreferredReadbackFormat(); |
host->CopyFromBackingStore( |
gfx::Rect(), |
host->GetView()->GetViewBounds().size(), |
base::Bind(&NavigationEntryScreenshotManager::OnScreenshotTaken, |
screenshot_factory_.GetWeakPtr(), |
entry->GetUniqueID()), |
- preferred_format); |
+ SkBitmap::kA8_Config); |
} |
void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS( |
@@ -153,6 +136,8 @@ void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS( |
void NavigationEntryScreenshotManager::OnScreenshotTaken(int unique_id, |
bool success, |
const SkBitmap& bitmap) { |
+ LOG(ERROR) << "OnScreenshotTaken"; |
+ |
NavigationEntryImpl* entry = NULL; |
int entry_count = owner_->GetEntryCount(); |
for (int i = 0; i < entry_count; ++i) { |
@@ -174,6 +159,9 @@ void NavigationEntryScreenshotManager::OnScreenshotTaken(int unique_id, |
return; |
} |
+ CHECK(bitmap.getConfig() == SkBitmap::kA8_Config) |
danakj
2014/07/10 19:13:02
DCHECK_EQ, then you don't need the extra << either
mfomitchev
2014/07/11 19:46:07
Done.
|
+ << "Incorrect screenshot format: " << bitmap.getConfig(); |
+ |
scoped_refptr<ScreenshotData> screenshot = new ScreenshotData(); |
screenshot->EncodeScreenshot( |
bitmap, |