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

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

Issue 11985003: Refactored-out the code of thumbnaling algorithm from thumbnail_tab_helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a unit test. Created 7 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/thumbnails/thumbnailing_algorithm.h
diff --git a/chrome/browser/thumbnails/thumbnailing_algorithm.h b/chrome/browser/thumbnails/thumbnailing_algorithm.h
new file mode 100644
index 0000000000000000000000000000000000000000..421c12f1a6320ea4add81ae4300bf599cdf4309a
--- /dev/null
+++ b/chrome/browser/thumbnails/thumbnailing_algorithm.h
@@ -0,0 +1,48 @@
+// 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_THUMBNAILING_ALGORITHM_H_
+#define CHROME_BROWSER_THUMBNAILS_THUMBNAILING_ALGORITHM_H_
+
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/thumbnails/thumbnailing_context.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/size.h"
+
+class SkBitmap;
+
+namespace thumbnails {
+
+// An interface abstracting thumbnailing algorithms. Instances are intended to
+// be created by ThumbnailService's implementations and used by
+// ThumbnailTabHelper as consumers of captured source images.
+class ThumbnailingAlgorithm
+ : public base::RefCountedThreadSafe<ThumbnailingAlgorithm> {
+ public:
+ typedef base::Callback<void(ThumbnailingContext*, const SkBitmap&)>
+ ConsumerCallback;
+ // Provides information necessary to crop-and-resize image data from a source
+ // canvas of |source_size|. Auxiliary |scale_factor| helps compute the target
+ // thumbnail size. Parameters of the required copy operation are assigned to
+ // |clipping_rect| (cropping rectangle for the source canvas) and
+ // |target_size| (the size of the target bitmap).
+ // The return value indicates the type of clipping that will be done.
+ virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size,
+ ui::ScaleFactor scale_factor,
+ gfx::Rect* clipping_rect,
+ gfx::Size* target_size) const = 0;
+
+
+ virtual void ProcessBitmap(ThumbnailingContext* context,
mazda 2013/01/17 18:08:43 Please add a comment.
motek. 2013/01/17 18:39:42 Done.
+ const SkBitmap& bitmap,
+ const ConsumerCallback& callback) = 0;
+
+ protected:
+ virtual ~ThumbnailingAlgorithm() {}
+ friend class base::RefCountedThreadSafe<ThumbnailingAlgorithm>;
+};
+
+}
+
+#endif // CHROME_BROWSER_THUMBNAILS_THUMBNAILING_ALGORITHM_H_

Powered by Google App Engine
This is Rietveld 408576698