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

Unified Diff: chrome/renderer/render_view.cc

Issue 4846002: Downsample thumbnail by powers of two before doing lanczos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: goog style Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 2378d9e083cc89aeda16507de1a41d0b8bc147a3..1752af0715d3a14c37e18be38f642e54717ab124 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -95,6 +95,7 @@
#include "gfx/native_widget_types.h"
#include "gfx/point.h"
#include "gfx/rect.h"
+#include "gfx/skbitmap_operations.h"
#include "grit/generated_resources.h"
#include "grit/renderer_resources.h"
#include "media/base/media_switches.h"
@@ -1105,14 +1106,19 @@ bool RenderView::CaptureThumbnail(WebView* view,
SkBitmap subset;
device.accessBitmap(false).extractSubset(&subset, src_rect);
- // Resample the subset that we want to get it the right size.
+ // First do a fast downsample by powers of two to get close to the final size.
+ SkBitmap downsampled_subset =
+ SkBitmapOperations::DownsampleByTwoUntilSize(subset, w, h);
+
+ // Do a high-quality resize from the downscaled size to the final size.
*thumbnail = skia::ImageOperations::Resize(
- subset, skia::ImageOperations::RESIZE_LANCZOS3, w, h);
+ downsampled_subset, skia::ImageOperations::RESIZE_LANCZOS3, w, h);
score->boring_score = CalculateBoringScore(thumbnail);
HISTOGRAM_TIMES("Renderer4.Thumbnail",
base::TimeTicks::Now() - beginning_time);
+
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698