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

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: 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 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 // An interface abstracting thumbnailing algorithms. Instances are intended to
mazda 2013/01/17 18:08:43 This is a concrete class. Could you change the com
motek. 2013/01/17 18:39:42 Done.
13 // be created by ThumbnailService's implementations and used by
14 // ThumbnailTabHelper as consumers of captured source images.
15 class SimpleThumbnailCrop : public ThumbnailingAlgorithm {
16 public:
17 explicit SimpleThumbnailCrop(const gfx::Size& target_size);
18
19 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size,
20 ui::ScaleFactor scale_factor,
21 gfx::Rect* clipping_rect,
22 gfx::Size* target_size) const OVERRIDE;
23
24 virtual void ProcessBitmap(ThumbnailingContext* context,
25 const SkBitmap& bitmap,
26 const ConsumerCallback& callback) OVERRIDE;
27
28 // Calculates how "boring" a thumbnail is. The boring score is the
29 // 0,1 ranged percentage of pixels that are the most common
30 // luma. Higher boring scores indicate that a higher percentage of a
31 // bitmap are all the same brightness.
32 // Statically exposed for use by tests only.
33 static double CalculateBoringScore(const SkBitmap& bitmap);
34
35 // Gets the clipped bitmap from |bitmap| per the aspect ratio of the
36 // desired width and the desired height. For instance, if the input
37 // bitmap is vertically long (ex. 400x900) and the desired size is
38 // square (ex. 100x100), the clipped bitmap will be the top half of the
39 // input bitmap (400x400).
40 // Statically exposed for use by tests only.
41 static SkBitmap GetClippedBitmap(const SkBitmap& bitmap,
42 int desired_width,
43 int desired_height,
44 thumbnails::ClipResult* clip_result);
45 static gfx::Size GetCopySizeForThumbnail(ui::ScaleFactor scale_factor,
46 const gfx::Size& thumbnail_size);
47
48 protected:
49 virtual ~SimpleThumbnailCrop();
50
51 private:
52 gfx::Size GetThumbnailSizeInPixel() const;
53 static gfx::Rect GetClippingRect(const gfx::Size& source_size,
54 const gfx::Size& desired_size,
55 ClipResult* clip_result);
56 static SkBitmap CreateThumbnail(const SkBitmap& bitmap,
57 const gfx::Size& desired_size,
58 ClipResult* clip_result);
59
60
61 gfx::Size target_size_;
62 };
63
64 }
65
66 #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