Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ | |
| 6 #define CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ | |
| 7 | |
| 8 #include "chrome/browser/thumbnails/thumbnailing_algorithm.h" | |
| 9 | |
| 10 namespace thumbnails { | |
| 11 | |
|
mazda
2013/05/29 21:50:27
Could you add a brief comment?
motek.
2013/05/30 15:00:03
Done.
| |
| 12 class ContentBasedThumbnailingAlgorithm : public ThumbnailingAlgorithm { | |
| 13 public: | |
| 14 explicit ContentBasedThumbnailingAlgorithm(const gfx::Size& target_size); | |
| 15 | |
| 16 virtual ClipResult GetCanvasCopyInfo(const gfx::Size& source_size, | |
| 17 ui::ScaleFactor scale_factor, | |
| 18 gfx::Rect* clipping_rect, | |
| 19 gfx::Size* target_size) const OVERRIDE; | |
| 20 | |
| 21 virtual void ProcessBitmap(scoped_refptr<ThumbnailingContext> context, | |
| 22 const ConsumerCallback& callback, | |
| 23 const SkBitmap& bitmap) OVERRIDE; | |
| 24 | |
| 25 // Prepares (clips to size, copies etc.) the bitmap passed to ProcessBitmap. | |
| 26 // Always returns a bitmap that can be properly refcounted. | |
| 27 // Extracted and exposed as a test seam. | |
| 28 static SkBitmap PrepareSourceBitmap(const SkBitmap& received_bitmap, | |
| 29 const gfx::Size& thumbnail_size, | |
| 30 ThumbnailingContext* context); | |
| 31 | |
| 32 // The function processes |source_bitmap| into a thumbnail of |thumbnail_size| | |
| 33 // and passes the result into |callback| (on UI thread). |context| describes | |
| 34 // how the thumbnail is being created. | |
| 35 static void CreateRetargettedThumbnail( | |
| 36 const SkBitmap& source_bitmap, | |
| 37 const gfx::Size& thumbnail_size, | |
| 38 scoped_refptr<ThumbnailingContext> context, | |
| 39 const ConsumerCallback& callback); | |
| 40 | |
| 41 protected: | |
| 42 virtual ~ContentBasedThumbnailingAlgorithm(); | |
| 43 | |
| 44 private: | |
| 45 static gfx::Rect GetClippingRect(const gfx::Size& source_size, | |
| 46 const gfx::Size& thumbnail_size, | |
| 47 gfx::Size* target_size, | |
| 48 ClipResult* clip_result); | |
| 49 | |
| 50 const gfx::Size target_size_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(ContentBasedThumbnailingAlgorithm); | |
| 53 }; | |
| 54 | |
| 55 } // namespace thumbnails | |
| 56 | |
| 57 #endif // CHROME_BROWSER_THUMBNAILS_CONTENT_BASED_THUMBNAILING_ALGORITHM_H_ | |
| OLD | NEW |