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

Unified Diff: chrome/browser/tab_contents/thumbnail_generator.cc

Issue 9582003: Support browser side thumbnailing for GPU composited pages on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 9 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: chrome/browser/tab_contents/thumbnail_generator.cc
diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc
index 51e4f9d4b6a4528f298a1e8f4f5689e570e0e4c2..37f1cc30b90a8a6286672769d99f16da6ac5e4e7 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"
#include "skia/ext/image_operations.h"
@@ -70,14 +71,24 @@ SkBitmap GetBitmapForRenderWidgetHost(
ThumbnailGenerator::ClipResult* clip_result) {
base::TimeTicks begin_compute_thumbnail = base::TimeTicks::Now();
- SkBitmap result;
-
// Get the bitmap as a Skia object so we can resample it. This is a large
// allocation and we can tolerate failure here, so give up if the allocation
- // fails.
+ // fails. First try to read from the compositing surface, then to read from
+ // the backing store.
+ content::RenderWidgetHostView* view = render_widget_host->GetView();
skia::PlatformCanvas temp_canvas;
- if (!render_widget_host->CopyFromBackingStore(&temp_canvas))
- return result;
+ bool copy_result = false;
+ // TODO(mazda): Copy the shrinked size of compositing surface instead of the
+ // view size for better performance.
+ if (view)
apatrick_chromium 2012/03/07 20:39:37 nit: braces around multiline body.
mazda 2012/03/08 13:14:28 Done.
+ copy_result = render_widget_host->CopyFromCompositingSurface(
+ view->GetViewBounds().size(),
+ &temp_canvas);
+ if (!copy_result)
+ copy_result = render_widget_host->CopyFromBackingStore(&temp_canvas);
+ if (!copy_result)
+ return SkBitmap();
+
const SkBitmap& bmp_with_scrollbars =
skia::GetTopDevice(temp_canvas)->accessBitmap(false);
// Clip the edgemost 15 pixels as that will commonly hold a scrollbar, which
@@ -89,6 +100,7 @@ SkBitmap GetBitmapForRenderWidgetHost(
SkBitmap bmp;
bmp_with_scrollbars.extractSubset(&bmp, scrollbarless_rect);
+ SkBitmap result;
// Check if a clipped thumbnail is requested.
if (options & ThumbnailGenerator::kClippedThumbnail) {
SkBitmap clipped_bitmap = ThumbnailGenerator::GetClippedBitmap(
« no previous file with comments | « no previous file | content/browser/gpu/gpu_surface_reader_win.h » ('j') | content/browser/gpu/gpu_surface_reader_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698