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

Side by Side Diff: chrome/browser/thumbnails/simple_thumbnail_crop.h

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
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 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 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 11 matching lines...) Expand all
50 const gfx::Size& desired_size, 50 const gfx::Size& desired_size,
51 ClipResult* clip_result); 51 ClipResult* clip_result);
52 52
53 // Computes the size of a thumbnail that should be stored in the database from 53 // Computes the size of a thumbnail that should be stored in the database from
54 // |given_size| (expected to be the thumbnail size we would normally want to 54 // |given_size| (expected to be the thumbnail size we would normally want to
55 // see). The returned size is expressed in pixels and is determined by 55 // see). The returned size is expressed in pixels and is determined by
56 // bumping the resolution up to the maximum scale factor. 56 // bumping the resolution up to the maximum scale factor.
57 static gfx::Size ComputeTargetSizeAtMaximumScale(const gfx::Size& given_size); 57 static gfx::Size ComputeTargetSizeAtMaximumScale(const gfx::Size& given_size);
58 58
59 protected: 59 protected:
60 virtual ~SimpleThumbnailCrop(); 60 ~SimpleThumbnailCrop() override;
61 61
62 private: 62 private:
63 static SkBitmap CreateThumbnail(const SkBitmap& bitmap, 63 static SkBitmap CreateThumbnail(const SkBitmap& bitmap,
64 const gfx::Size& desired_size, 64 const gfx::Size& desired_size,
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_
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h ('k') | chrome/browser/thumbnails/thumbnail_list_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698