OLD | NEW |
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ClipResult clip_result; | 172 ClipResult clip_result; |
173 gfx::Rect clipping_rect = SimpleThumbnailCrop::GetClippingRect( | 173 gfx::Rect clipping_rect = SimpleThumbnailCrop::GetClippingRect( |
174 gfx::Size(source_bitmap.width(), source_bitmap.height()), | 174 gfx::Size(source_bitmap.width(), source_bitmap.height()), |
175 thumbnail_size, | 175 thumbnail_size, |
176 &clip_result); | 176 &clip_result); |
177 source_bitmap.extractSubset(&thumbnail, gfx::RectToSkIRect(clipping_rect)); | 177 source_bitmap.extractSubset(&thumbnail, gfx::RectToSkIRect(clipping_rect)); |
178 thumbnail = SkBitmapOperations::DownsampleByTwoUntilSize( | 178 thumbnail = SkBitmapOperations::DownsampleByTwoUntilSize( |
179 thumbnail, thumbnail_size.width(), thumbnail_size.height()); | 179 thumbnail, thumbnail_size.width(), thumbnail_size.height()); |
180 } | 180 } |
181 | 181 |
182 HISTOGRAM_TIMES( | 182 if (processing_failed) { |
183 processing_failed ? kFailureHistogramName : kThumbnailHistogramName, | 183 LOCAL_HISTOGRAM_TIMES(kFailureHistogramName, |
184 base::TimeTicks::Now() - begin_compute_thumbnail); | 184 base::TimeTicks::Now() - begin_compute_thumbnail); |
| 185 } else { |
| 186 LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName, |
| 187 base::TimeTicks::Now() - begin_compute_thumbnail); |
| 188 } |
185 context->score.boring_score = | 189 context->score.boring_score = |
186 SimpleThumbnailCrop::CalculateBoringScore(source_bitmap); | 190 SimpleThumbnailCrop::CalculateBoringScore(source_bitmap); |
187 if (!processing_failed) | 191 if (!processing_failed) |
188 context->score.boring_score *= kScoreBoostFromSuccessfulRetargeting; | 192 context->score.boring_score *= kScoreBoostFromSuccessfulRetargeting; |
189 context->score.good_clipping = | 193 context->score.good_clipping = |
190 (context->clip_result == CLIP_RESULT_WIDER_THAN_TALL || | 194 (context->clip_result == CLIP_RESULT_WIDER_THAN_TALL || |
191 context->clip_result == CLIP_RESULT_TALLER_THAN_WIDE || | 195 context->clip_result == CLIP_RESULT_TALLER_THAN_WIDE || |
192 context->clip_result == CLIP_RESULT_NOT_CLIPPED || | 196 context->clip_result == CLIP_RESULT_NOT_CLIPPED || |
193 context->clip_result == CLIP_RESULT_SOURCE_SAME_AS_TARGET); | 197 context->clip_result == CLIP_RESULT_SOURCE_SAME_AS_TARGET); |
194 // Post the result (the bitmap) back to the callback. | 198 // Post the result (the bitmap) back to the callback. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } else { | 232 } else { |
229 clipping_rect = gfx::Rect(source_size); | 233 clipping_rect = gfx::Rect(source_size); |
230 target_size->SetSize(source_size.width() / 2, source_size.height() / 2); | 234 target_size->SetSize(source_size.width() / 2, source_size.height() / 2); |
231 *clip_result = CLIP_RESULT_NOT_CLIPPED; | 235 *clip_result = CLIP_RESULT_NOT_CLIPPED; |
232 } | 236 } |
233 | 237 |
234 return clipping_rect; | 238 return clipping_rect; |
235 } | 239 } |
236 | 240 |
237 } // namespace thumbnails | 241 } // namespace thumbnails |
OLD | NEW |