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

Side by Side Diff: chrome/browser/thumbnails/simple_thumbnail_crop.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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_H_
6 #define CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_H_
7
8 #include "chrome/browser/thumbnails/thumbnailing_algorithm.h"
9
10 namespace thumbnails {
11
12 // The implementation of the 'classic' thumbnail cropping algorithm. It is not
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
15 // target sizes. The selected source region is then rescaled into the target
16 // thumbnail image.
17 class SimpleThumbnailCrop : public ThumbnailingAlgorithm {
18 public:
19 explicit SimpleThumbnailCrop(const gfx::Size& target_size);
20
21 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size,
22 ui::ScaleFactor scale_factor,
23 gfx::Rect* clipping_rect,
24 gfx::Size* target_size) const OVERRIDE;
25
26 virtual void ProcessBitmap(ThumbnailingContext* context,
27 const SkBitmap& bitmap,
28 const ConsumerCallback& callback) OVERRIDE;
29
30 // Calculates how "boring" a thumbnail is. The boring score is the
31 // 0,1 ranged percentage of pixels that are the most common
32 // luma. Higher boring scores indicate that a higher percentage of a
33 // bitmap are all the same brightness.
34 // Statically exposed for use by tests only.
35 static double CalculateBoringScore(const SkBitmap& bitmap);
36
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
39 // bitmap is vertically long (ex. 400x900) and the desired size is
40 // square (ex. 100x100), the clipped bitmap will be the top half of the
41 // input bitmap (400x400).
42 // Statically exposed for use by tests only.
43 static SkBitmap GetClippedBitmap(const SkBitmap& bitmap,
44 int desired_width,
45 int desired_height,
46 thumbnails::ClipResult* clip_result);
47 static gfx::Size GetCopySizeForThumbnail(ui::ScaleFactor scale_factor,
48 const gfx::Size& thumbnail_size);
49
50 protected:
51 virtual ~SimpleThumbnailCrop();
52
53 private:
54 gfx::Size GetThumbnailSizeInPixel() const;
55 static gfx::Rect GetClippingRect(const gfx::Size& source_size,
56 const gfx::Size& desired_size,
57 ClipResult* clip_result);
58 static SkBitmap CreateThumbnail(const SkBitmap& bitmap,
59 const gfx::Size& desired_size,
60 ClipResult* clip_result);
61
62
63 gfx::Size target_size_;
sky 2013/01/17 20:18:36 const
motek. 2013/01/18 18:38:41 Done.
64 };
sky 2013/01/17 20:18:36 DISALLOW_...
motek. 2013/01/18 18:38:41 Done.
65
66 }
67
68 #endif // CHROME_BROWSER_THUMBNAILS_SIMPLE_THUMBNAIL_CROP_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/thumbnails/simple_thumbnail_crop.cc » ('j') | chrome/browser/thumbnails/simple_thumbnail_crop.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698