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

Unified Diff: chrome/browser/thumbnails/simple_thumbnail_crop.cc

Issue 15458003: Plugs in the new thumbnailing algorithm to ThumbnailTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed up a compile problem (indpendent change). Created 7 years, 7 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/thumbnails/simple_thumbnail_crop.cc
diff --git a/chrome/browser/thumbnails/simple_thumbnail_crop.cc b/chrome/browser/thumbnails/simple_thumbnail_crop.cc
index f010e84b4d21aaf9dad30754874c0b7a1eec5532..1a0ce5fcbda068a07513f5313f0ebdb973009a64 100644
--- a/chrome/browser/thumbnails/simple_thumbnail_crop.cc
+++ b/chrome/browser/thumbnails/simple_thumbnail_crop.cc
@@ -36,16 +36,18 @@ ClipResult SimpleThumbnailCrop::GetCanvasCopyInfo(
return clip_result;
}
-void SimpleThumbnailCrop::ProcessBitmap(ThumbnailingContext* context,
- const ConsumerCallback& callback,
- const SkBitmap& bitmap) {
+void SimpleThumbnailCrop::ProcessBitmap(
+ scoped_refptr<ThumbnailingContext> context,
+ const ConsumerCallback& callback,
+ const SkBitmap& bitmap) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (bitmap.isNull() || bitmap.empty())
return;
- SkBitmap thumbnail = CreateThumbnail(bitmap,
- GetThumbnailSizeInPixel(),
- &context->clip_result);
+ SkBitmap thumbnail = CreateThumbnail(
+ bitmap,
+ ComputeTargetSizeAtMaximumScale(target_size_),
+ &context->clip_result);
context->score.boring_score = CalculateBoringScore(thumbnail);
context->score.good_clipping =
@@ -134,20 +136,6 @@ gfx::Size SimpleThumbnailCrop::GetCopySizeForThumbnail(
return copy_size;
}
-SimpleThumbnailCrop::~SimpleThumbnailCrop() {
-}
-
-// Returns the size of the thumbnail stored in the database in pixel.
-gfx::Size SimpleThumbnailCrop::GetThumbnailSizeInPixel() const {
- // Determine the resolution of the thumbnail based on the maximum scale
- // factor.
- // TODO(mazda|oshima): Update thumbnail when the max scale factor changes.
- // crbug.com/159157.
- float max_scale_factor =
- ui::GetScaleFactorScale(ui::GetMaxScaleFactor());
- return gfx::ToFlooredSize(gfx::ScaleSize(target_size_, max_scale_factor));
-}
-
gfx::Rect SimpleThumbnailCrop::GetClippingRect(const gfx::Size& source_size,
const gfx::Size& desired_size,
ClipResult* clip_result) {
@@ -190,6 +178,19 @@ gfx::Rect SimpleThumbnailCrop::GetClippingRect(const gfx::Size& source_size,
return clipping_rect;
}
+// static
+gfx::Size SimpleThumbnailCrop::ComputeTargetSizeAtMaximumScale(
+ const gfx::Size& given_size) {
+ // TODO(mazda|oshima): Update thumbnail when the max scale factor changes.
+ // crbug.com/159157.
+ float max_scale_factor =
+ ui::GetScaleFactorScale(ui::GetMaxScaleFactor());
+ return gfx::ToFlooredSize(gfx::ScaleSize(given_size, max_scale_factor));
+}
+
+SimpleThumbnailCrop::~SimpleThumbnailCrop() {
+}
+
// Creates a downsampled thumbnail from the given bitmap.
// store. The returned bitmap will be isNull if there was an error creating it.
SkBitmap SimpleThumbnailCrop::CreateThumbnail(const SkBitmap& bitmap,
« no previous file with comments | « chrome/browser/thumbnails/simple_thumbnail_crop.h ('k') | chrome/browser/thumbnails/simple_thumbnail_crop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698