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

Unified Diff: content/browser/frame_host/navigation_entry_screenshot_manager.cc

Issue 389683002: Improving GestureNav screenshotting performance - part 2 - GestureNav (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@slow_readback_final_GL_HELPER
Patch Set: Comment Created 6 years, 4 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
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 4c521176058025bb2d40fdfc1af08dbff6454379..9a038f7e72ee62d03ad8557db7855d2aa1d1e0ee 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 {
@@ -52,18 +49,10 @@ class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> {
}
void EncodeOnWorker(const SkBitmap& bitmap) {
+ DCHECK_EQ(bitmap.colorType(), kAlpha_8_SkColorType);
+ // Encode the A8 bitmap to grayscale PNG treating alpha as color intensity.
std::vector<unsigned char> data;
- // Paint |bitmap| to a kAlpha_8_SkColorType SkBitmap
- SkBitmap a8Bitmap;
- a8Bitmap.allocPixels(SkImageInfo::MakeA8(bitmap.width(), bitmap.height()));
- 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))
+ if (gfx::PNGCodec::EncodeA8SkBitmap(bitmap, &data))
data_ = new base::RefCountedBytes(data);
}
@@ -130,14 +119,13 @@ void NavigationEntryScreenshotManager::TakeScreenshotImpl(
NavigationEntryImpl* entry) {
DCHECK(host && host->GetView());
DCHECK(entry);
- SkColorType preferred_format = host->PreferredReadbackFormat();
host->CopyFromBackingStore(
gfx::Rect(),
host->GetView()->GetViewBounds().size(),
base::Bind(&NavigationEntryScreenshotManager::OnScreenshotTaken,
screenshot_factory_.GetWeakPtr(),
entry->GetUniqueID()),
- preferred_format);
+ kAlpha_8_SkColorType);
}
void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS(

Powered by Google App Engine
This is Rietveld 408576698