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

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

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new usage of scale in FastShowPickler Created 7 years, 2 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"
11 #include "ui/gfx/image/image_skia.h"
11 #include "ui/gfx/screen.h" 12 #include "ui/gfx/screen.h"
12 #include "ui/gfx/scrollbar_size.h" 13 #include "ui/gfx/scrollbar_size.h"
13 #include "ui/gfx/size_conversions.h" 14 #include "ui/gfx/size_conversions.h"
14 #include "ui/gfx/skbitmap_operations.h" 15 #include "ui/gfx/skbitmap_operations.h"
15 16
16 namespace { 17 namespace {
17 static const char kThumbnailHistogramName[] = "Thumbnail.ComputeMS"; 18 static const char kThumbnailHistogramName[] = "Thumbnail.ComputeMS";
18 } 19 }
19 20
20 namespace thumbnails { 21 namespace thumbnails {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // TODO(mazda): Copy the pixels with the smaller size in the case of 115 // TODO(mazda): Copy the pixels with the smaller size in the case of
115 // ui::SCALE_FACTOR_100P once the resampling method has been improved. 116 // ui::SCALE_FACTOR_100P once the resampling method has been improved.
116 // static 117 // static
117 gfx::Size SimpleThumbnailCrop::GetCopySizeForThumbnail( 118 gfx::Size SimpleThumbnailCrop::GetCopySizeForThumbnail(
118 ui::ScaleFactor scale_factor, 119 ui::ScaleFactor scale_factor,
119 const gfx::Size& thumbnail_size) { 120 const gfx::Size& thumbnail_size) {
120 gfx::Size copy_size(thumbnail_size); 121 gfx::Size copy_size(thumbnail_size);
121 switch (scale_factor) { 122 switch (scale_factor) {
122 case ui::SCALE_FACTOR_100P: 123 case ui::SCALE_FACTOR_100P:
123 copy_size = gfx::ToFlooredSize(gfx::ScaleSize( 124 copy_size = gfx::ToFlooredSize(gfx::ScaleSize(
124 copy_size, ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P))); 125 copy_size, ui::GetImageScale(ui::SCALE_FACTOR_200P)));
125 break; 126 break;
126 case ui::SCALE_FACTOR_200P: 127 case ui::SCALE_FACTOR_200P:
127 // Use the size as-is. 128 // Use the size as-is.
128 break; 129 break;
129 default: 130 default:
130 DLOG(WARNING) << "Unsupported scale factor. Use the same copy size as " 131 DLOG(WARNING) << "Unsupported scale factor. Use the same copy size as "
131 << "ui::SCALE_FACTOR_100P"; 132 << "ui::SCALE_FACTOR_100P";
132 copy_size = gfx::ToFlooredSize(gfx::ScaleSize( 133 copy_size = gfx::ToFlooredSize(gfx::ScaleSize(
133 copy_size, ui::GetMaxScaleFactor())); 134 copy_size, gfx::ImageSkia::GetMaxSupportedScale()));
134 break; 135 break;
135 } 136 }
136 return copy_size; 137 return copy_size;
137 } 138 }
138 139
139 gfx::Rect SimpleThumbnailCrop::GetClippingRect(const gfx::Size& source_size, 140 gfx::Rect SimpleThumbnailCrop::GetClippingRect(const gfx::Size& source_size,
140 const gfx::Size& desired_size, 141 const gfx::Size& desired_size,
141 ClipResult* clip_result) { 142 ClipResult* clip_result) {
142 DCHECK(clip_result); 143 DCHECK(clip_result);
143 144
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 177 }
177 } 178 }
178 return clipping_rect; 179 return clipping_rect;
179 } 180 }
180 181
181 // static 182 // static
182 gfx::Size SimpleThumbnailCrop::ComputeTargetSizeAtMaximumScale( 183 gfx::Size SimpleThumbnailCrop::ComputeTargetSizeAtMaximumScale(
183 const gfx::Size& given_size) { 184 const gfx::Size& given_size) {
184 // TODO(mazda|oshima): Update thumbnail when the max scale factor changes. 185 // TODO(mazda|oshima): Update thumbnail when the max scale factor changes.
185 // crbug.com/159157. 186 // crbug.com/159157.
186 float max_scale_factor = 187 float max_scale_factor = gfx::ImageSkia::GetMaxSupportedScale();
187 ui::GetScaleFactorScale(ui::GetMaxScaleFactor());
188 return gfx::ToFlooredSize(gfx::ScaleSize(given_size, max_scale_factor)); 188 return gfx::ToFlooredSize(gfx::ScaleSize(given_size, max_scale_factor));
189 } 189 }
190 190
191 SimpleThumbnailCrop::~SimpleThumbnailCrop() { 191 SimpleThumbnailCrop::~SimpleThumbnailCrop() {
192 } 192 }
193 193
194 // Creates a downsampled thumbnail from the given bitmap. 194 // Creates a downsampled thumbnail from the given bitmap.
195 // store. The returned bitmap will be isNull if there was an error creating it. 195 // store. The returned bitmap will be isNull if there was an error creating it.
196 SkBitmap SimpleThumbnailCrop::CreateThumbnail(const SkBitmap& bitmap, 196 SkBitmap SimpleThumbnailCrop::CreateThumbnail(const SkBitmap& bitmap,
197 const gfx::Size& desired_size, 197 const gfx::Size& desired_size,
(...skipping 40 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 } // namespace thumbnails 247 } // namespace thumbnails
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698