OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ | 5 #ifndef CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ |
6 #define CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ | 6 #define CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ |
7 | 7 |
8 #include "chrome/browser/thumbnails/thumbnailing_algorithm.h" | 8 #include "chrome/browser/thumbnails/thumbnailing_algorithm.h" |
9 | 9 |
10 namespace thumbnails { | 10 namespace thumbnails { |
11 | 11 |
12 // Encapsulates a method of creating a thumbnail from a captured tab shot which | 12 // Encapsulates a method of creating a thumbnail from a captured tab shot which |
13 // attempts to preserve only relevant fragments of the original image. | 13 // attempts to preserve only relevant fragments of the original image. |
14 // The algorithm detects areas of high activity at low resolution and discards | 14 // The algorithm detects areas of high activity at low resolution and discards |
15 // rows and columns which do not intersect with these areas. | 15 // rows and columns which do not intersect with these areas. |
16 class ContentBasedThumbnailingAlgorithm : public ThumbnailingAlgorithm { | 16 class ContentBasedThumbnailingAlgorithm : public ThumbnailingAlgorithm { |
17 public: | 17 public: |
18 explicit ContentBasedThumbnailingAlgorithm(const gfx::Size& target_size); | 18 explicit ContentBasedThumbnailingAlgorithm(const gfx::Size& target_size); |
19 | 19 |
20 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size, | 20 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size, |
21 ui::ScaleFactor scale_factor, | 21 ui::ScaleFactor scale_factor, |
22 gfx::Rect* clipping_rect, | 22 gfx::Rect* clipping_rect, |
23 gfx::Size* target_size) const OVERRIDE; | 23 gfx::Size* target_size) const override; |
24 | 24 |
25 virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context, | 25 virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context, |
26 const ConsumerCallback& callback, | 26 const ConsumerCallback& callback, |
27 const SkBitmap& bitmap) OVERRIDE; | 27 const SkBitmap& bitmap) override; |
28 | 28 |
29 // Prepares (clips to size, copies etc.) the bitmap passed to ProcessBitmap. | 29 // Prepares (clips to size, copies etc.) the bitmap passed to ProcessBitmap. |
30 // Always returns a bitmap that can be properly refcounted. | 30 // Always returns a bitmap that can be properly refcounted. |
31 // Extracted and exposed as a test seam. | 31 // Extracted and exposed as a test seam. |
32 static SkBitmap PrepareSourceBitmap(const SkBitmap& received_bitmap, | 32 static SkBitmap PrepareSourceBitmap(const SkBitmap& received_bitmap, |
33 const gfx::Size& thumbnail_size, | 33 const gfx::Size& thumbnail_size, |
34 ThumbnailingContext* context); | 34 ThumbnailingContext* context); |
35 | 35 |
36 // The function processes |source_bitmap| into a thumbnail of |thumbnail_size| | 36 // The function processes |source_bitmap| into a thumbnail of |thumbnail_size| |
37 // and passes the result into |callback| (on UI thread). |context| describes | 37 // and passes the result into |callback| (on UI thread). |context| describes |
(...skipping 14 matching lines...) Expand all Loading... |
52 ClipResult* clip_result); | 52 ClipResult* clip_result); |
53 | 53 |
54 const gfx::Size target_size_; | 54 const gfx::Size target_size_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(ContentBasedThumbnailingAlgorithm); | 56 DISALLOW_COPY_AND_ASSIGN(ContentBasedThumbnailingAlgorithm); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace thumbnails | 59 } // namespace thumbnails |
60 | 60 |
61 #endif // CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ | 61 #endif // CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ |
OLD | NEW |