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

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

Issue 1028393003: [Thumbnails] Specify copy size in Pixels, not DIPs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Specific scale to device Created 5 years, 9 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_THUMBNAILING_ALGORITHM_H_ 5 #ifndef CHROME_BROWSER_THUMBNAILS_THUMBNAILING_ALGORITHM_H_
6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAILING_ALGORITHM_H_ 6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAILING_ALGORITHM_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "chrome/browser/thumbnails/thumbnailing_context.h" 9 #include "chrome/browser/thumbnails/thumbnailing_context.h"
10 #include "ui/base/layout.h" 10 #include "ui/base/layout.h"
11 #include "ui/gfx/geometry/rect.h" 11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
13 13
14 class SkBitmap; 14 class SkBitmap;
15 15
16 namespace thumbnails { 16 namespace thumbnails {
17 17
18 // An interface abstracting thumbnailing algorithms. Instances are intended to 18 // An interface abstracting thumbnailing algorithms. Instances are intended to
19 // be created by ThumbnailService's implementations and used by 19 // be created by ThumbnailService's implementations and used by
20 // ThumbnailTabHelper as consumers of captured source images. 20 // ThumbnailTabHelper as consumers of captured source images.
21 class ThumbnailingAlgorithm 21 class ThumbnailingAlgorithm
22 : public base::RefCountedThreadSafe<ThumbnailingAlgorithm> { 22 : public base::RefCountedThreadSafe<ThumbnailingAlgorithm> {
23 public: 23 public:
24 typedef base::Callback<void(const ThumbnailingContext&, const SkBitmap&)> 24 typedef base::Callback<void(const ThumbnailingContext&, const SkBitmap&)>
25 ConsumerCallback; 25 ConsumerCallback;
26 // Provides information necessary to crop-and-resize image data from a source 26 // Provides information necessary to crop-and-resize image data from a source
27 // canvas of |source_size|. Auxiliary |scale_factor| helps compute the target 27 // canvas of |source_size|. Auxiliary |scale_factor| helps compute the target
Lei Zhang 2015/03/26 18:34:56 The comments still refer to target and |target_siz
Mathieu 2015/03/26 21:19:48 Done.
28 // thumbnail size. Parameters of the required copy operation are assigned to 28 // thumbnail size to be copied from the backing store, in pixels. Parameters
29 // |clipping_rect| (cropping rectangle for the source canvas) and 29 // of the required copy operation are assigned to |clipping_rect| (cropping
30 // |target_size| (the size of the target bitmap). 30 // rectangle for the source canvas) and |target_size| (the size of the target
31 // The return value indicates the type of clipping that will be done. 31 // bitmap in pixels). The return value indicates the type of clipping that
32 // will be done.
32 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size, 33 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size,
33 ui::ScaleFactor scale_factor, 34 ui::ScaleFactor scale_factor,
34 gfx::Rect* clipping_rect, 35 gfx::Rect* clipping_rect,
35 gfx::Size* target_size) const = 0; 36 gfx::Size* copy_size) const = 0;
36 37
37 // Invoked to produce a thumbnail image from a |bitmap| extracted by the 38 // Invoked to produce a thumbnail image from a |bitmap| extracted by the
38 // callee from source canvas according to instructions provided by a call 39 // callee from source canvas according to instructions provided by a call
39 // to GetCanvasCopyInfo. 40 // to GetCanvasCopyInfo.
40 // Note that ProcessBitmap must be able to handle bitmaps which might have not 41 // Note that ProcessBitmap must be able to handle bitmaps which might have not
41 // been processed (scalled/cropped) as requested. |context| gives additional 42 // been processed (scalled/cropped) as requested. |context| gives additional
42 // information on the source, including if and how it was clipped. 43 // information on the source, including if and how it was clipped.
43 // The function shall invoke |callback| once done, passing in fully populated 44 // The function shall invoke |callback| once done, passing in fully populated
44 // |context| along with resulting thumbnail bitmap. 45 // |context| along with resulting thumbnail bitmap.
45 virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context, 46 virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context,
46 const ConsumerCallback& callback, 47 const ConsumerCallback& callback,
47 const SkBitmap& bitmap) = 0; 48 const SkBitmap& bitmap) = 0;
48 49
49 protected: 50 protected:
50 virtual ~ThumbnailingAlgorithm() {} 51 virtual ~ThumbnailingAlgorithm() {}
51 friend class base::RefCountedThreadSafe<ThumbnailingAlgorithm>; 52 friend class base::RefCountedThreadSafe<ThumbnailingAlgorithm>;
52 }; 53 };
53 54
54 } 55 } // namespace thumbnails
55 56
56 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAILING_ALGORITHM_H_ 57 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAILING_ALGORITHM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698