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

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: Move scroll offset into ViewHostMsg_UpdateRect_Params 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
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..46cc117fe6f8551d2e398804be915f375d3e5256 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.h
+++ b/chrome/browser/tab_contents/thumbnail_generator.h
@@ -26,6 +26,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.
+ kNone = 0,
brettw 2011/01/21 00:09:17 Can you rename this to kNoOptions (or something si
satorux1 2011/01/21 04:53:43 Done.
+ // 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 +82,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 +101,21 @@ 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);
brettw 2011/01/21 00:09:17 Moving the thumbnail computation, you can remove t
+
+ // 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);
private:
// RenderWidgetHostPaintingObserver implementation.
virtual void WidgetWillDestroyBackingStore(RenderWidgetHost* widget,

Powered by Google App Engine
This is Rietveld 408576698