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/thumbnails/thumbnail_tab_helper.h" | 5 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h" | 10 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // ui::SCALE_FACTOR_200P because the high resolution thumbnail on high density | 81 // ui::SCALE_FACTOR_200P because the high resolution thumbnail on high density |
82 // display alleviates the aliasing. | 82 // display alleviates the aliasing. |
83 // TODO(mazda): Copy the pixels with the smaller size in the case of | 83 // TODO(mazda): Copy the pixels with the smaller size in the case of |
84 // ui::SCALE_FACTOR_100P once the resampling method has been improved. | 84 // ui::SCALE_FACTOR_100P once the resampling method has been improved. |
85 gfx::Size GetCopySizeForThumbnail(content::RenderWidgetHostView* view) { | 85 gfx::Size GetCopySizeForThumbnail(content::RenderWidgetHostView* view) { |
86 gfx::Size copy_size(kThumbnailWidth, kThumbnailHeight); | 86 gfx::Size copy_size(kThumbnailWidth, kThumbnailHeight); |
87 ui::ScaleFactor scale_factor = | 87 ui::ScaleFactor scale_factor = |
88 ui::GetScaleFactorForNativeView(view->GetNativeView()); | 88 ui::GetScaleFactorForNativeView(view->GetNativeView()); |
89 switch (scale_factor) { | 89 switch (scale_factor) { |
90 case ui::SCALE_FACTOR_100P: | 90 case ui::SCALE_FACTOR_100P: |
91 copy_size = gfx::ToFlooredSize( | 91 copy_size = gfx::ToFlooredSize(gfx::ScaleSize( |
92 copy_size.Scale(ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P))); | 92 copy_size, ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P))); |
93 break; | 93 break; |
94 case ui::SCALE_FACTOR_200P: | 94 case ui::SCALE_FACTOR_200P: |
95 // Use the size as-is. | 95 // Use the size as-is. |
96 break; | 96 break; |
97 default: | 97 default: |
98 DLOG(WARNING) << "Unsupported scale factor. Use the same copy size as " | 98 DLOG(WARNING) << "Unsupported scale factor. Use the same copy size as " |
99 << "ui::SCALE_FACTOR_100P"; | 99 << "ui::SCALE_FACTOR_100P"; |
100 copy_size = gfx::ToFlooredSize( | 100 copy_size = gfx::ToFlooredSize(gfx::ScaleSize( |
101 copy_size.Scale(ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P))); | 101 copy_size, ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P))); |
102 break; | 102 break; |
103 } | 103 } |
104 return copy_size; | 104 return copy_size; |
105 } | 105 } |
106 | 106 |
107 // Returns the size of the thumbnail stored in the database in pixel. | 107 // Returns the size of the thumbnail stored in the database in pixel. |
108 gfx::Size GetThumbnailSizeInPixel() { | 108 gfx::Size GetThumbnailSizeInPixel() { |
109 gfx::Size thumbnail_size(kThumbnailWidth, kThumbnailHeight); | 109 gfx::Size thumbnail_size(kThumbnailWidth, kThumbnailHeight); |
110 // Determine the resolution of the thumbnail based on the maximum scale | 110 // Determine the resolution of the thumbnail based on the maximum scale |
111 // factor. | 111 // factor. |
112 // TODO(mazda|oshima): Update thumbnail when the max scale factor changes. | 112 // TODO(mazda|oshima): Update thumbnail when the max scale factor changes. |
113 // crbug.com/159157. | 113 // crbug.com/159157. |
114 float max_scale_factor = | 114 float max_scale_factor = |
115 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); | 115 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); |
116 return gfx::ToFlooredSize(thumbnail_size.Scale(max_scale_factor)); | 116 return gfx::ToFlooredSize(gfx::ScaleSize(thumbnail_size, max_scale_factor)); |
117 } | 117 } |
118 | 118 |
119 // Returns the clipping rectangle that is used for creating a thumbnail with | 119 // Returns the clipping rectangle that is used for creating a thumbnail with |
120 // the size of |desired_size| from the bitmap with the size of |source_size|. | 120 // the size of |desired_size| from the bitmap with the size of |source_size|. |
121 // The type of clipping that needs to be done is assigned to |clip_result|. | 121 // The type of clipping that needs to be done is assigned to |clip_result|. |
122 gfx::Rect GetClippingRect(const gfx::Size& source_size, | 122 gfx::Rect GetClippingRect(const gfx::Size& source_size, |
123 const gfx::Size& desired_size, | 123 const gfx::Size& desired_size, |
124 ThumbnailTabHelper::ClipResult* clip_result) { | 124 ThumbnailTabHelper::ClipResult* clip_result) { |
125 DCHECK(clip_result); | 125 DCHECK(clip_result); |
126 | 126 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 void ThumbnailTabHelper::DidStartLoading( | 466 void ThumbnailTabHelper::DidStartLoading( |
467 content::RenderViewHost* render_view_host) { | 467 content::RenderViewHost* render_view_host) { |
468 load_interrupted_ = false; | 468 load_interrupted_ = false; |
469 } | 469 } |
470 | 470 |
471 void ThumbnailTabHelper::StopNavigation() { | 471 void ThumbnailTabHelper::StopNavigation() { |
472 // This function gets called when the page loading is interrupted by the | 472 // This function gets called when the page loading is interrupted by the |
473 // stop button. | 473 // stop button. |
474 load_interrupted_ = true; | 474 load_interrupted_ = true; |
475 } | 475 } |
OLD | NEW |