OLD | NEW |
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 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" | 5 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
10 #include "ui/base/layout.h" | 10 #include "ui/base/layout.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 ClipResult clip_result = thumbnails::CLIP_RESULT_NOT_CLIPPED; | 34 ClipResult clip_result = thumbnails::CLIP_RESULT_NOT_CLIPPED; |
35 *clipping_rect = GetClippingRect(source_size, target_size_, &clip_result); | 35 *clipping_rect = GetClippingRect(source_size, target_size_, &clip_result); |
36 *copy_size = GetCopySizeForThumbnail(scale_factor, target_size_); | 36 *copy_size = GetCopySizeForThumbnail(scale_factor, target_size_); |
37 return clip_result; | 37 return clip_result; |
38 } | 38 } |
39 | 39 |
40 void SimpleThumbnailCrop::ProcessBitmap( | 40 void SimpleThumbnailCrop::ProcessBitmap( |
41 scoped_refptr<ThumbnailingContext> context, | 41 scoped_refptr<ThumbnailingContext> context, |
42 const ConsumerCallback& callback, | 42 const ConsumerCallback& callback, |
43 const SkBitmap& bitmap) { | 43 const SkBitmap& bitmap) { |
44 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 44 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
45 if (bitmap.isNull() || bitmap.empty()) | 45 if (bitmap.isNull() || bitmap.empty()) |
46 return; | 46 return; |
47 | 47 |
48 SkBitmap thumbnail = CreateThumbnail( | 48 SkBitmap thumbnail = CreateThumbnail( |
49 bitmap, | 49 bitmap, |
50 ComputeTargetSizeAtMaximumScale(target_size_), | 50 ComputeTargetSizeAtMaximumScale(target_size_), |
51 &context->clip_result); | 51 &context->clip_result); |
52 | 52 |
53 context->score.boring_score = color_utils::CalculateBoringScore(thumbnail); | 53 context->score.boring_score = color_utils::CalculateBoringScore(thumbnail); |
54 context->score.good_clipping = | 54 context->score.good_clipping = |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 clipped_bitmap.height() == result.height()) | 194 clipped_bitmap.height() == result.height()) |
195 clipped_bitmap.copyTo(&result, kN32_SkColorType); | 195 clipped_bitmap.copyTo(&result, kN32_SkColorType); |
196 #endif | 196 #endif |
197 | 197 |
198 LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName, | 198 LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName, |
199 base::TimeTicks::Now() - begin_compute_thumbnail); | 199 base::TimeTicks::Now() - begin_compute_thumbnail); |
200 return result; | 200 return result; |
201 } | 201 } |
202 | 202 |
203 } // namespace thumbnails | 203 } // namespace thumbnails |
OLD | NEW |