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 27 matching lines...) Expand all Loading... |
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_CURRENTLY_ON(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 ClipResult clip_result; | 48 ClipResult clip_result = context->clip_result(); |
49 SkBitmap thumbnail = CreateThumbnail( | 49 SkBitmap thumbnail = CreateThumbnail( |
50 bitmap, | 50 bitmap, |
51 ComputeTargetSizeAtMaximumScale(target_size_), | 51 ComputeTargetSizeAtMaximumScale(target_size_), |
52 &clip_result); | 52 &clip_result); |
53 | 53 |
54 context->SetBoringScore(color_utils::CalculateBoringScore(thumbnail)); | 54 context->SetBoringScore(color_utils::CalculateBoringScore(thumbnail)); |
55 context->set_clip_result(clip_result); | 55 context->set_clip_result(clip_result); |
56 bool good_clipping = | 56 bool good_clipping = |
57 (clip_result == CLIP_RESULT_WIDER_THAN_TALL || | 57 (clip_result == CLIP_RESULT_WIDER_THAN_TALL || |
58 clip_result == CLIP_RESULT_TALLER_THAN_WIDE || | 58 clip_result == CLIP_RESULT_TALLER_THAN_WIDE || |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 clipped_bitmap.height() == result.height()) | 197 clipped_bitmap.height() == result.height()) |
198 clipped_bitmap.copyTo(&result, kN32_SkColorType); | 198 clipped_bitmap.copyTo(&result, kN32_SkColorType); |
199 #endif | 199 #endif |
200 | 200 |
201 LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName, | 201 LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName, |
202 base::TimeTicks::Now() - begin_compute_thumbnail); | 202 base::TimeTicks::Now() - begin_compute_thumbnail); |
203 return result; | 203 return result; |
204 } | 204 } |
205 | 205 |
206 } // namespace thumbnails | 206 } // namespace thumbnails |
OLD | NEW |