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

Unified Diff: chrome/browser/thumbnails/advanced_thumbnail_crop.h

Issue 15458003: Plugs in the new thumbnailing algorithm to ThumbnailTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests. 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/advanced_thumbnail_crop.h
diff --git a/chrome/browser/thumbnails/advanced_thumbnail_crop.h b/chrome/browser/thumbnails/advanced_thumbnail_crop.h
new file mode 100644
index 0000000000000000000000000000000000000000..233e0b9f3d1c038764f94c91f44a23539fb652fb
--- /dev/null
+++ b/chrome/browser/thumbnails/advanced_thumbnail_crop.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_THUMBNAILS_ADVANCED_THUMBNAIL_CROP_H_
+#define CHROME_BROWSER_THUMBNAILS_ADVANCED_THUMBNAIL_CROP_H_
+
+#include "chrome/browser/thumbnails/thumbnailing_algorithm.h"
+
+namespace thumbnails {
+
+class AdvancedThumbnailCrop : public ThumbnailingAlgorithm {
mazda 2013/05/23 19:13:57 Can you make the name more descriptive?
motek. 2013/05/27 16:54:54 Done.
+ public:
+ explicit AdvancedThumbnailCrop(const gfx::Size& target_size);
+
+ virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size,
+ ui::ScaleFactor scale_factor,
+ gfx::Rect* clipping_rect,
+ gfx::Size* target_size) const OVERRIDE;
+
+ virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context,
+ const ConsumerCallback& callback,
+ const SkBitmap& bitmap) OVERRIDE;
+
+ // Prepares (clips to size, copies etc.) the bitmap passed to ProcessBitmap.
+ // Always returns a bitmap that can be properly refcounted.
+ // Extracted and exposed as a test seam.
+ static SkBitmap PrepareSourceBitmap(const SkBitmap& received_bitmap,
+ const gfx::Size& thumbnail_size,
+ ThumbnailingContext* context);
+
+ // The function processes |source_bitmap| into a thumbnail of |thumbnail_size|
+ // and passes the result into |callback| (on UI thread). |context| describes
+ // how the thumbnail is being created.
+ static void CreateRetargettedThumbnail(
+ const SkBitmap& source_bitmap,
+ const gfx::Size& thumbnail_size,
+ scoped_refptr<ThumbnailingContext> context,
+ const ConsumerCallback& callback);
+
+ protected:
+ ~AdvancedThumbnailCrop();
+
+
mazda 2013/05/23 19:13:57 nit: delete one empty line.
motek. 2013/05/27 16:54:54 Done.
+ private:
+ static gfx::Rect GetClippingRect(const gfx::Size& source_size,
+ const gfx::Size& thumbnail_size,
+ gfx::Size* target_size,
+ ClipResult* clip_result);
+
+ const gfx::Size target_size_;
+
+ DISALLOW_COPY_AND_ASSIGN(AdvancedThumbnailCrop);
+};
+
+} // namespace thumbnails
+
+#endif // CHROME_BROWSER_THUMBNAILS_ADVANCED_THUMBNAIL_CROP_H_

Powered by Google App Engine
This is Rietveld 408576698