OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 #include "chrome/renderer/visitedlink_slave.h" | 85 #include "chrome/renderer/visitedlink_slave.h" |
86 #include "chrome/renderer/webplugin_delegate_pepper.h" | 86 #include "chrome/renderer/webplugin_delegate_pepper.h" |
87 #include "chrome/renderer/webplugin_delegate_proxy.h" | 87 #include "chrome/renderer/webplugin_delegate_proxy.h" |
88 #include "chrome/renderer/websharedworker_proxy.h" | 88 #include "chrome/renderer/websharedworker_proxy.h" |
89 #include "chrome/renderer/webworker_proxy.h" | 89 #include "chrome/renderer/webworker_proxy.h" |
90 #include "gfx/color_utils.h" | 90 #include "gfx/color_utils.h" |
91 #include "gfx/favicon_size.h" | 91 #include "gfx/favicon_size.h" |
92 #include "gfx/native_widget_types.h" | 92 #include "gfx/native_widget_types.h" |
93 #include "gfx/point.h" | 93 #include "gfx/point.h" |
94 #include "gfx/rect.h" | 94 #include "gfx/rect.h" |
| 95 #include "gfx/skbitmap_operations.h" |
95 #include "grit/generated_resources.h" | 96 #include "grit/generated_resources.h" |
96 #include "grit/renderer_resources.h" | 97 #include "grit/renderer_resources.h" |
97 #include "media/base/media_switches.h" | 98 #include "media/base/media_switches.h" |
98 #include "net/base/data_url.h" | 99 #include "net/base/data_url.h" |
99 #include "net/base/escape.h" | 100 #include "net/base/escape.h" |
100 #include "net/base/net_errors.h" | 101 #include "net/base/net_errors.h" |
101 #include "skia/ext/bitmap_platform_device.h" | 102 #include "skia/ext/bitmap_platform_device.h" |
102 #include "skia/ext/image_operations.h" | 103 #include "skia/ext/image_operations.h" |
103 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" | 104 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" |
104 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" | 105 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 static_cast<S16CPU>(src_bmp.width() / dest_aspect)); | 1045 static_cast<S16CPU>(src_bmp.width() / dest_aspect)); |
1045 score->good_clipping = true; | 1046 score->good_clipping = true; |
1046 } | 1047 } |
1047 } | 1048 } |
1048 | 1049 |
1049 score->at_top = (view->mainFrame()->scrollOffset().height == 0); | 1050 score->at_top = (view->mainFrame()->scrollOffset().height == 0); |
1050 | 1051 |
1051 SkBitmap subset; | 1052 SkBitmap subset; |
1052 device.accessBitmap(false).extractSubset(&subset, src_rect); | 1053 device.accessBitmap(false).extractSubset(&subset, src_rect); |
1053 | 1054 |
1054 // Resample the subset that we want to get it the right size. | 1055 // First do a fast downsample by powers of two to get close to the final size. |
| 1056 SkBitmap downsampled_subset = |
| 1057 SkBitmapOperations::DownsampleByTwoUntilSize(subset, w, h); |
| 1058 |
| 1059 // Do a high-quality resize from the downscaled size to the final size. |
1055 *thumbnail = skia::ImageOperations::Resize( | 1060 *thumbnail = skia::ImageOperations::Resize( |
1056 subset, skia::ImageOperations::RESIZE_LANCZOS3, w, h); | 1061 downsampled_subset, skia::ImageOperations::RESIZE_LANCZOS3, w, h); |
1057 | 1062 |
1058 score->boring_score = CalculateBoringScore(thumbnail); | 1063 score->boring_score = CalculateBoringScore(thumbnail); |
1059 | 1064 |
1060 HISTOGRAM_TIMES("Renderer4.Thumbnail", | 1065 HISTOGRAM_TIMES("Renderer4.Thumbnail", |
1061 base::TimeTicks::Now() - beginning_time); | 1066 base::TimeTicks::Now() - beginning_time); |
| 1067 |
1062 return true; | 1068 return true; |
1063 } | 1069 } |
1064 | 1070 |
1065 bool RenderView::CaptureSnapshot(WebView* view, SkBitmap* snapshot) { | 1071 bool RenderView::CaptureSnapshot(WebView* view, SkBitmap* snapshot) { |
1066 base::TimeTicks beginning_time = base::TimeTicks::Now(); | 1072 base::TimeTicks beginning_time = base::TimeTicks::Now(); |
1067 | 1073 |
1068 skia::PlatformCanvas canvas; | 1074 skia::PlatformCanvas canvas; |
1069 if (!PaintViewIntoCanvas(view, canvas)) | 1075 if (!PaintViewIntoCanvas(view, canvas)) |
1070 return false; | 1076 return false; |
1071 | 1077 |
(...skipping 4956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6028 } | 6034 } |
6029 | 6035 |
6030 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, | 6036 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, |
6031 IPC::PlatformFileForTransit file_for_transit, | 6037 IPC::PlatformFileForTransit file_for_transit, |
6032 int message_id) { | 6038 int message_id) { |
6033 pepper_delegate_.OnAsyncFileOpened( | 6039 pepper_delegate_.OnAsyncFileOpened( |
6034 error_code, | 6040 error_code, |
6035 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), | 6041 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
6036 message_id); | 6042 message_id); |
6037 } | 6043 } |
OLD | NEW |