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

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

Issue 2702093002: Consistent CopyFromSurface() API, consolidated to RWHV (Closed)
Patch Set: REBASE Created 3 years, 10 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 01f90564b60794239da94522326a7aeff68fead5..aa740cb6efd81a995a3b5a7f75dd49dd290d75e2 100644
--- a/content/browser/frame_host/navigation_entry_screenshot_manager.cc
+++ b/content/browser/frame_host/navigation_entry_screenshot_manager.cc
@@ -83,6 +83,7 @@ void NavigationEntryScreenshotManager::TakeScreenshot() {
return;
RenderViewHost* render_view_host = owner_->delegate()->GetRenderViewHost();
+ DCHECK(render_view_host && render_view_host->GetWidget());
content::RenderWidgetHostView* view =
render_view_host->GetWidget()->GetView();
if (!view)
@@ -95,9 +96,18 @@ void NavigationEntryScreenshotManager::TakeScreenshot() {
return;
}
+ WillTakeScreenshot(render_view_host);
+
last_screenshot_time_ = now;
- TakeScreenshotImpl(render_view_host, entry);
+ // This screenshot is destined for the UI, so size the result to the actual
+ // on-screen size of the view (and not its device-rendering size).
+ const gfx::Size view_size_on_screen = view->GetViewBounds().size();
+ view->CopyFromSurface(
+ gfx::Rect(), view_size_on_screen,
+ base::Bind(&NavigationEntryScreenshotManager::OnScreenshotTaken,
+ screenshot_factory_.GetWeakPtr(), entry->GetUniqueID()),
+ kAlpha_8_SkColorType);
}
// Implemented here and not in NavigationEntry because this manager keeps track
@@ -110,18 +120,6 @@ void NavigationEntryScreenshotManager::ClearAllScreenshots() {
DCHECK_EQ(GetScreenshotCount(), 0);
}
-void NavigationEntryScreenshotManager::TakeScreenshotImpl(
- RenderViewHost* host,
- NavigationEntryImpl* entry) {
- DCHECK(host && host->GetWidget()->GetView());
- DCHECK(entry);
- host->GetWidget()->CopyFromBackingStore(
- gfx::Rect(), host->GetWidget()->GetView()->GetViewBounds().size(),
- base::Bind(&NavigationEntryScreenshotManager::OnScreenshotTaken,
- screenshot_factory_.GetWeakPtr(), entry->GetUniqueID()),
- kAlpha_8_SkColorType);
-}
-
void NavigationEntryScreenshotManager::SetMinScreenshotIntervalMS(
int interval_ms) {
DCHECK_GE(interval_ms, 0);

Powered by Google App Engine
This is Rietveld 408576698