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

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

Issue 2702093002: Consistent CopyFromSurface() API, consolidated to RWHV (Closed)
Patch Set: REBASE Created 3 years, 9 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 GetClippingRect(gfx::Size(bitmap.width(), bitmap.height()), 68 GetClippingRect(gfx::Size(bitmap.width(), bitmap.height()),
69 gfx::Size(desired_width, desired_height), 69 gfx::Size(desired_width, desired_height),
70 clip_result); 70 clip_result);
71 SkIRect src_rect = { clipping_rect.x(), clipping_rect.y(), 71 SkIRect src_rect = { clipping_rect.x(), clipping_rect.y(),
72 clipping_rect.right(), clipping_rect.bottom() }; 72 clipping_rect.right(), clipping_rect.bottom() };
73 SkBitmap clipped_bitmap; 73 SkBitmap clipped_bitmap;
74 bitmap.extractSubset(&clipped_bitmap, src_rect); 74 bitmap.extractSubset(&clipped_bitmap, src_rect);
75 return clipped_bitmap; 75 return clipped_bitmap;
76 } 76 }
77 77
78 // RenderWidgetHost::CopyFromBackingStore can be costly especially when it is 78 // RenderWidgetHostView::CopyFromSurface() can be costly especially when it is
79 // necessary to read back the web contents image data from GPU. As the cost is 79 // necessary to read back the web contents image data from GPU. As the cost is
80 // roughly proportional to the number of the copied pixels, the size of the 80 // roughly proportional to the number of the copied pixels, the size of the
81 // copied pixels should be as small as possible. 81 // copied pixels should be as small as possible.
82 // static 82 // static
83 gfx::Size SimpleThumbnailCrop::GetCopySizeForThumbnail( 83 gfx::Size SimpleThumbnailCrop::GetCopySizeForThumbnail(
84 ui::ScaleFactor scale_factor, 84 ui::ScaleFactor scale_factor,
85 const gfx::Size& thumbnail_size) { 85 const gfx::Size& thumbnail_size) {
86 // The copy size returned is the pixel equivalent of |thumbnail_size|, which 86 // The copy size returned is the pixel equivalent of |thumbnail_size|, which
87 // is in DIPs. 87 // is in DIPs.
88 if (scale_factor == ui::SCALE_FACTOR_100P) { 88 if (scale_factor == ui::SCALE_FACTOR_100P) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 clipped_bitmap.height() == result.height()) 195 clipped_bitmap.height() == result.height())
196 clipped_bitmap.copyTo(&result, kN32_SkColorType); 196 clipped_bitmap.copyTo(&result, kN32_SkColorType);
197 #endif 197 #endif
198 198
199 LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName, 199 LOCAL_HISTOGRAM_TIMES(kThumbnailHistogramName,
200 base::TimeTicks::Now() - begin_compute_thumbnail); 200 base::TimeTicks::Now() - begin_compute_thumbnail);
201 return result; 201 return result;
202 } 202 }
203 203
204 } // namespace thumbnails 204 } // namespace thumbnails
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_power_saver_browsertest.cc ('k') | chrome/browser/thumbnails/thumbnail_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698