OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 10 #include "base/bind.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 int desired_height, | 70 int desired_height, |
71 int options, | 71 int options, |
72 ThumbnailGenerator::ClipResult* clip_result) { | 72 ThumbnailGenerator::ClipResult* clip_result) { |
73 base::TimeTicks begin_compute_thumbnail = base::TimeTicks::Now(); | 73 base::TimeTicks begin_compute_thumbnail = base::TimeTicks::Now(); |
74 | 74 |
75 SkBitmap result; | 75 SkBitmap result; |
76 | 76 |
77 // Get the bitmap as a Skia object so we can resample it. This is a large | 77 // Get the bitmap as a Skia object so we can resample it. This is a large |
78 // allocation and we can tolerate failure here, so give up if the allocation | 78 // allocation and we can tolerate failure here, so give up if the allocation |
79 // fails. | 79 // fails. |
| 80 // TODO(mazda): Copy a shrinked size of image instead of the whole view size. |
80 skia::PlatformCanvas temp_canvas; | 81 skia::PlatformCanvas temp_canvas; |
81 if (!render_widget_host->CopyFromBackingStore(&temp_canvas)) | 82 if (!render_widget_host->CopyFromBackingStore(gfx::Size(), &temp_canvas)) |
82 return result; | 83 return result; |
83 const SkBitmap& bmp_with_scrollbars = | 84 const SkBitmap& bmp_with_scrollbars = |
84 skia::GetTopDevice(temp_canvas)->accessBitmap(false); | 85 skia::GetTopDevice(temp_canvas)->accessBitmap(false); |
85 // Clip the edgemost 15 pixels as that will commonly hold a scrollbar, which | 86 // Clip the edgemost 15 pixels as that will commonly hold a scrollbar, which |
86 // looks bad in thumbnails. | 87 // looks bad in thumbnails. |
87 SkIRect scrollbarless_rect = | 88 SkIRect scrollbarless_rect = |
88 { 0, 0, | 89 { 0, 0, |
89 std::max(1, bmp_with_scrollbars.width() - 15), | 90 std::max(1, bmp_with_scrollbars.width() - 15), |
90 std::max(1, bmp_with_scrollbars.height() - 15) }; | 91 std::max(1, bmp_with_scrollbars.height() - 15) }; |
91 SkBitmap bmp; | 92 SkBitmap bmp; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 513 |
513 void ThumbnailGenerator::DidStartLoading() { | 514 void ThumbnailGenerator::DidStartLoading() { |
514 load_interrupted_ = false; | 515 load_interrupted_ = false; |
515 } | 516 } |
516 | 517 |
517 void ThumbnailGenerator::StopNavigation() { | 518 void ThumbnailGenerator::StopNavigation() { |
518 // This function gets called when the page loading is interrupted by the | 519 // This function gets called when the page loading is interrupted by the |
519 // stop button. | 520 // stop button. |
520 load_interrupted_ = true; | 521 load_interrupted_ = true; |
521 } | 522 } |
OLD | NEW |