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

Side by Side Diff: chrome/browser/thumbnails/content_based_thumbnailing_algorithm.cc

Issue 1028393003: [Thumbnails] Specify copy size in Pixels, not DIPs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: correct rebase 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h" 5 #include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "chrome/browser/thumbnails/content_analysis.h" 9 #include "chrome/browser/thumbnails/content_analysis.h"
10 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" 10 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h"
(...skipping 27 matching lines...) Expand all
38 ContentBasedThumbnailingAlgorithm::ContentBasedThumbnailingAlgorithm( 38 ContentBasedThumbnailingAlgorithm::ContentBasedThumbnailingAlgorithm(
39 const gfx::Size& target_size) 39 const gfx::Size& target_size)
40 : target_size_(target_size) { 40 : target_size_(target_size) {
41 DCHECK(!target_size.IsEmpty()); 41 DCHECK(!target_size.IsEmpty());
42 } 42 }
43 43
44 ClipResult ContentBasedThumbnailingAlgorithm::GetCanvasCopyInfo( 44 ClipResult ContentBasedThumbnailingAlgorithm::GetCanvasCopyInfo(
45 const gfx::Size& source_size, 45 const gfx::Size& source_size,
46 ui::ScaleFactor scale_factor, 46 ui::ScaleFactor scale_factor,
47 gfx::Rect* clipping_rect, 47 gfx::Rect* clipping_rect,
48 gfx::Size* target_size) const { 48 gfx::Size* copy_size) const {
49 DCHECK(!source_size.IsEmpty()); 49 DCHECK(!source_size.IsEmpty());
50 gfx::Size target_thumbnail_size = 50 gfx::Size copy_thumbnail_size =
51 SimpleThumbnailCrop::GetCopySizeForThumbnail(scale_factor, target_size_); 51 SimpleThumbnailCrop::GetCopySizeForThumbnail(scale_factor, target_size_);
52 52
53 ClipResult clipping_method = thumbnails::CLIP_RESULT_NOT_CLIPPED; 53 ClipResult clipping_method = thumbnails::CLIP_RESULT_NOT_CLIPPED;
54 *clipping_rect = GetClippingRect( 54 *clipping_rect = GetClippingRect(source_size, copy_thumbnail_size, copy_size,
55 source_size, target_thumbnail_size, target_size, &clipping_method); 55 &clipping_method);
56 return clipping_method; 56 return clipping_method;
57 } 57 }
58 58
59 void ContentBasedThumbnailingAlgorithm::ProcessBitmap( 59 void ContentBasedThumbnailingAlgorithm::ProcessBitmap(
60 scoped_refptr<ThumbnailingContext> context, 60 scoped_refptr<ThumbnailingContext> context,
61 const ConsumerCallback& callback, 61 const ConsumerCallback& callback,
62 const SkBitmap& bitmap) { 62 const SkBitmap& bitmap) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
64 DCHECK(context.get()); 64 DCHECK(context.get());
65 if (bitmap.isNull() || bitmap.empty()) 65 if (bitmap.isNull() || bitmap.empty())
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } else { 233 } else {
234 clipping_rect = gfx::Rect(source_size); 234 clipping_rect = gfx::Rect(source_size);
235 target_size->SetSize(source_size.width() / 2, source_size.height() / 2); 235 target_size->SetSize(source_size.width() / 2, source_size.height() / 2);
236 *clip_result = CLIP_RESULT_NOT_CLIPPED; 236 *clip_result = CLIP_RESULT_NOT_CLIPPED;
237 } 237 }
238 238
239 return clipping_rect; 239 return clipping_rect;
240 } 240 }
241 241
242 } // namespace thumbnails 242 } // namespace thumbnails
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h ('k') | chrome/browser/thumbnails/simple_thumbnail_crop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698