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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
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/gfx/color_utils.h" 10 #include "ui/gfx/color_utils.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 bitmap, 48 bitmap,
49 ComputeTargetSizeAtMaximumScale(target_size_), 49 ComputeTargetSizeAtMaximumScale(target_size_),
50 &context->clip_result); 50 &context->clip_result);
51 51
52 context->score.boring_score = CalculateBoringScore(thumbnail); 52 context->score.boring_score = CalculateBoringScore(thumbnail);
53 context->score.good_clipping = 53 context->score.good_clipping =
54 (context->clip_result == CLIP_RESULT_WIDER_THAN_TALL || 54 (context->clip_result == CLIP_RESULT_WIDER_THAN_TALL ||
55 context->clip_result == CLIP_RESULT_TALLER_THAN_WIDE || 55 context->clip_result == CLIP_RESULT_TALLER_THAN_WIDE ||
56 context->clip_result == CLIP_RESULT_NOT_CLIPPED); 56 context->clip_result == CLIP_RESULT_NOT_CLIPPED);
57 57
58 callback.Run(*context, thumbnail); 58 callback.Run(*context.get(), thumbnail);
59 } 59 }
60 60
61 double SimpleThumbnailCrop::CalculateBoringScore(const SkBitmap& bitmap) { 61 double SimpleThumbnailCrop::CalculateBoringScore(const SkBitmap& bitmap) {
62 if (bitmap.isNull() || bitmap.empty()) 62 if (bitmap.isNull() || bitmap.empty())
63 return 1.0; 63 return 1.0;
64 int histogram[256] = {0}; 64 int histogram[256] = {0};
65 color_utils::BuildLumaHistogram(bitmap, histogram); 65 color_utils::BuildLumaHistogram(bitmap, histogram);
66 66
67 int color_count = *std::max_element(histogram, histogram + 256); 67 int color_count = *std::max_element(histogram, histogram + 256);
68 int pixel_count = bitmap.width() * bitmap.height(); 68 int pixel_count = bitmap.width() * bitmap.height();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 clipped_bitmap.height() == result.height()) 238 clipped_bitmap.height() == result.height())
239 clipped_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); 239 clipped_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
240 #endif 240 #endif
241 241
242 HISTOGRAM_TIMES(kThumbnailHistogramName, 242 HISTOGRAM_TIMES(kThumbnailHistogramName,
243 base::TimeTicks::Now() - begin_compute_thumbnail); 243 base::TimeTicks::Now() - begin_compute_thumbnail);
244 return result; 244 return result;
245 } 245 }
246 246
247 } 247 }
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/content_based_thumbnailing_algorithm_unittest.cc ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698