OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/thumbnail_generator.h" | 5 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/history/top_sites.h" | 15 #include "chrome/browser/history/top_sites.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/thumbnail_score.h" | 17 #include "chrome/common/thumbnail_score.h" |
18 #include "content/browser/renderer_host/backing_store.h" | 18 #include "content/browser/renderer_host/backing_store.h" |
19 #include "content/browser/renderer_host/render_process_host.h" | 19 #include "content/browser/renderer_host/render_process_host.h" |
20 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
21 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
22 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
24 #include "skia/ext/bitmap_platform_device.h" | |
25 #include "skia/ext/image_operations.h" | 24 #include "skia/ext/image_operations.h" |
26 #include "skia/ext/platform_canvas.h" | 25 #include "skia/ext/platform_canvas.h" |
27 #include "third_party/skia/include/core/SkBitmap.h" | 26 #include "third_party/skia/include/core/SkBitmap.h" |
28 #include "ui/gfx/color_utils.h" | 27 #include "ui/gfx/color_utils.h" |
29 #include "ui/gfx/rect.h" | 28 #include "ui/gfx/rect.h" |
30 #include "ui/gfx/skbitmap_operations.h" | 29 #include "ui/gfx/skbitmap_operations.h" |
31 | 30 |
32 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
33 #include "content/common/section_util_win.h" | 32 #include "content/common/section_util_win.h" |
34 #endif | 33 #endif |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 72 |
74 SkBitmap result; | 73 SkBitmap result; |
75 | 74 |
76 // Get the bitmap as a Skia object so we can resample it. This is a large | 75 // Get the bitmap as a Skia object so we can resample it. This is a large |
77 // allocation and we can tolerate failure here, so give up if the allocation | 76 // allocation and we can tolerate failure here, so give up if the allocation |
78 // fails. | 77 // fails. |
79 skia::PlatformCanvas temp_canvas; | 78 skia::PlatformCanvas temp_canvas; |
80 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), | 79 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), |
81 &temp_canvas)) | 80 &temp_canvas)) |
82 return result; | 81 return result; |
83 const SkBitmap& bmp = temp_canvas.getTopPlatformDevice().accessBitmap(false); | 82 const SkBitmap& bmp = skia::GetTopDevice(temp_canvas)->accessBitmap(false); |
84 | 83 |
85 // Check if a clipped thumbnail is requested. | 84 // Check if a clipped thumbnail is requested. |
86 if (options & ThumbnailGenerator::kClippedThumbnail) { | 85 if (options & ThumbnailGenerator::kClippedThumbnail) { |
87 SkBitmap clipped_bitmap = ThumbnailGenerator::GetClippedBitmap( | 86 SkBitmap clipped_bitmap = ThumbnailGenerator::GetClippedBitmap( |
88 bmp, desired_width, desired_height, clip_result); | 87 bmp, desired_width, desired_height, clip_result); |
89 | 88 |
90 // Need to resize it to the size we want, so downsample until it's | 89 // Need to resize it to the size we want, so downsample until it's |
91 // close, and let the caller make it the exact size if desired. | 90 // close, and let the caller make it the exact size if desired. |
92 result = SkBitmapOperations::DownsampleByTwoUntilSize( | 91 result = SkBitmapOperations::DownsampleByTwoUntilSize( |
93 clipped_bitmap, desired_width, desired_height); | 92 clipped_bitmap, desired_width, desired_height); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 return false; | 471 return false; |
473 // Skip if we don't have to udpate the temporary thumbnail (i.e. the one | 472 // Skip if we don't have to udpate the temporary thumbnail (i.e. the one |
474 // not yet saved). | 473 // not yet saved). |
475 ThumbnailScore temporary_score; | 474 ThumbnailScore temporary_score; |
476 if (top_sites->GetTemporaryPageThumbnailScore(url, &temporary_score) && | 475 if (top_sites->GetTemporaryPageThumbnailScore(url, &temporary_score) && |
477 !temporary_score.ShouldConsiderUpdating()) | 476 !temporary_score.ShouldConsiderUpdating()) |
478 return false; | 477 return false; |
479 | 478 |
480 return true; | 479 return true; |
481 } | 480 } |
OLD | NEW |