OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_SIMPLE_THUMBNAIL_CROP_H_ | 5 #ifndef CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_H_ |
6 #define CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_H_ | 6 #define CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_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 // The implementation of the 'classic' thumbnail cropping algorithm. It is not | 12 // The implementation of the 'classic' thumbnail cropping algorithm. It is not |
13 // content-driven in any meaningful way (save for score calculation). Rather, | 13 // content-driven in any meaningful way (save for score calculation). Rather, |
14 // the choice of a cropping region is based on relation between source and | 14 // the choice of a cropping region is based on relation between source and |
15 // target sizes. The selected source region is then rescaled into the target | 15 // target sizes. The selected source region is then rescaled into the target |
16 // thumbnail image. | 16 // thumbnail image. |
17 class SimpleThumbnailCrop : public ThumbnailingAlgorithm { | 17 class SimpleThumbnailCrop : public ThumbnailingAlgorithm { |
18 public: | 18 public: |
19 explicit SimpleThumbnailCrop(const gfx::Size& target_size); | 19 explicit SimpleThumbnailCrop(const gfx::Size& target_size); |
20 | 20 |
21 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size, | 21 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size, |
22 ui::ScaleFactor scale_factor, | 22 ui::ScaleFactor scale_factor, |
23 gfx::Rect* clipping_rect, | 23 gfx::Rect* clipping_rect, |
24 gfx::Size* target_size) const OVERRIDE; | 24 gfx::Size* target_size) const override; |
25 | 25 |
26 virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context, | 26 virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context, |
27 const ConsumerCallback& callback, | 27 const ConsumerCallback& callback, |
28 const SkBitmap& bitmap) OVERRIDE; | 28 const SkBitmap& bitmap) override; |
29 | 29 |
30 // Calculates how "boring" a thumbnail is. The boring score is the | 30 // Calculates how "boring" a thumbnail is. The boring score is the |
31 // 0,1 ranged percentage of pixels that are the most common | 31 // 0,1 ranged percentage of pixels that are the most common |
32 // luma. Higher boring scores indicate that a higher percentage of a | 32 // luma. Higher boring scores indicate that a higher percentage of a |
33 // bitmap are all the same brightness. | 33 // bitmap are all the same brightness. |
34 // Statically exposed for use by tests only. | 34 // Statically exposed for use by tests only. |
35 static double CalculateBoringScore(const SkBitmap& bitmap); | 35 static double CalculateBoringScore(const SkBitmap& bitmap); |
36 | 36 |
37 // Gets the clipped bitmap from |bitmap| per the aspect ratio of the | 37 // Gets the clipped bitmap from |bitmap| per the aspect ratio of the |
38 // desired width and the desired height. For instance, if the input | 38 // desired width and the desired height. For instance, if the input |
(...skipping 26 matching lines...) Expand all Loading... |
65 ClipResult* clip_result); | 65 ClipResult* clip_result); |
66 | 66 |
67 const gfx::Size target_size_; | 67 const gfx::Size target_size_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(SimpleThumbnailCrop); | 69 DISALLOW_COPY_AND_ASSIGN(SimpleThumbnailCrop); |
70 }; | 70 }; |
71 | 71 |
72 } | 72 } |
73 | 73 |
74 #endif // CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_H_ | 74 #endif // CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_H_ |
OLD | NEW |