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

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

Issue 6246007: Generate thumbnails in the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the function name... Created 9 years, 11 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
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/tab_contents/thumbnail_generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/thumbnail_generator.h
diff --git a/chrome/browser/tab_contents/thumbnail_generator.h b/chrome/browser/tab_contents/thumbnail_generator.h
index 335b2cbcd8e4ea75f1aaa4ea4e32b3bd488f3635..c8d3167e3fb243312eb0d65f5f1b154fdbe3a743 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.h
+++ b/chrome/browser/tab_contents/thumbnail_generator.h
@@ -19,6 +19,7 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
+class GURL;
class RenderWidgetHost;
class SkBitmap;
class TabContents;
@@ -26,6 +27,27 @@ class TabContents;
class ThumbnailGenerator : NotificationObserver {
public:
typedef Callback1<const SkBitmap&>::Type ThumbnailReadyCallback;
+ // The result of clipping. This can be used to determine if the
+ // generated thumbnail is good or not.
+ enum ClipResult {
+ // The source image is smaller.
+ kSourceIsSmaller,
+ // Wider than tall, clip horizontally.
+ kWiderThanTall,
+ // Taller than wide, clip vertically.
+ kTallerThanWide,
+ // The source and destination aspect ratios are identical.
+ kNotClipped,
+ };
+
+ // Bitmasks of options for generating a thumbnail.
+ enum ThumbnailOptions {
+ // No options.
+ kNoOptions = 0,
+ // Request a clipped thumbnail with the aspect ratio preserved.
+ kClippedThumbnail = 1 << 0,
+ };
+
// This class will do nothing until you call StartThumbnailing.
ThumbnailGenerator();
~ThumbnailGenerator();
@@ -61,6 +83,13 @@ class ThumbnailGenerator : NotificationObserver {
// renderer.
SkBitmap GetThumbnailForRenderer(RenderWidgetHost* renderer) const;
+ // This returns a thumbnail of a fixed, small size for the given
+ // renderer. |options| is a bitmask of ThumbnailOptions. If
+ // |clip_result| is non-NULL, the result of clipping will be written.
+ SkBitmap GetThumbnailForRendererWithOptions(RenderWidgetHost* renderer,
+ int options,
+ ClipResult* clip_result) const;
+
// Start or stop monitoring notifications for |renderer| based on the value
// of |monitor|.
void MonitorRenderer(RenderWidgetHost* renderer, bool monitor);
@@ -73,6 +102,26 @@ class ThumbnailGenerator : NotificationObserver {
void set_no_timeout(bool no_timeout) { no_timeout_ = no_timeout; }
#endif
+ // Calculates how "boring" a thumbnail is. The boring score is the
+ // 0,1 ranged percentage of pixels that are the most common
+ // luma. Higher boring scores indicate that a higher percentage of a
+ // bitmap are all the same brightness.
+ static double CalculateBoringScore(SkBitmap* bitmap);
+
+ // Gets the clipped bitmap from |bitmap| per the aspect ratio of the
+ // desired width and the desired height. For instance, if the input
+ // bitmap is vertically long (ex. 400x900) and the desired size is
+ // square (ex. 100x100), the clipped bitmap will be the top half of the
+ // input bitmap (400x400).
+ static SkBitmap GetClippedBitmap(const SkBitmap& bitmap,
+ int desired_width,
+ int desired_height,
+ ClipResult* clip_result);
+
+ // Update the thumbnail of the given URL if necessary.
+ static void UpdateThumbnailIfNecessary(TabContents* tab_contents,
+ const GURL& url);
+
private:
// RenderWidgetHostPaintingObserver implementation.
virtual void WidgetWillDestroyBackingStore(RenderWidgetHost* widget,
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/tab_contents/thumbnail_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698