Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/browser/render_widget_host_view.h" | 25 #include "content/public/browser/render_widget_host_view.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| 28 #include "skia/ext/image_operations.h" | 28 #include "skia/ext/image_operations.h" |
| 29 #include "skia/ext/platform_canvas.h" | 29 #include "skia/ext/platform_canvas.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "ui/base/layout.h" | |
| 31 #include "ui/gfx/color_utils.h" | 32 #include "ui/gfx/color_utils.h" |
| 32 #include "ui/gfx/rect.h" | 33 #include "ui/gfx/rect.h" |
| 33 #include "ui/gfx/skbitmap_operations.h" | 34 #include "ui/gfx/skbitmap_operations.h" |
| 34 | 35 |
| 35 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 36 #include "base/win/windows_version.h" | 37 #include "base/win/windows_version.h" |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 // Overview | 40 // Overview |
| 40 // -------- | 41 // -------- |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 } | 212 } |
| 212 | 213 |
| 213 void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer, | 214 void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer, |
| 214 const ThumbnailReadyCallback& callback, | 215 const ThumbnailReadyCallback& callback, |
| 215 gfx::Size page_size, | 216 gfx::Size page_size, |
| 216 gfx::Size desired_size) { | 217 gfx::Size desired_size) { |
| 217 // We are going to render the thumbnail asynchronously now, so keep | 218 // We are going to render the thumbnail asynchronously now, so keep |
| 218 // this callback for later lookup when the rendering is done. | 219 // this callback for later lookup when the rendering is done. |
| 219 static int sequence_num = 0; | 220 static int sequence_num = 0; |
| 220 sequence_num++; | 221 sequence_num++; |
| 222 float scale_factor = ui::GetScaleFactorScale(ui::GetScaleFactorForNativeView( | |
| 223 renderer->GetView()->GetNativeView())); | |
| 224 gfx::Size desired_pixel_size = desired_size.Scale(scale_factor); | |
|
oshima
2012/08/07 03:22:21
I think desired_size_in_pixel is more clear and be
mazda
2012/08/07 03:55:50
Done.
| |
| 221 scoped_ptr<TransportDIB> thumbnail_dib(TransportDIB::Create( | 225 scoped_ptr<TransportDIB> thumbnail_dib(TransportDIB::Create( |
| 222 desired_size.width() * desired_size.height() * 4, sequence_num)); | 226 desired_pixel_size.GetArea() * 4, sequence_num)); |
| 223 | 227 |
| 224 #if defined(USE_X11) | 228 #if defined(USE_X11) |
| 225 // TODO: IPC a handle to the renderer like Windows. | 229 // TODO: IPC a handle to the renderer like Windows. |
| 226 // http://code.google.com/p/chromium/issues/detail?id=89777 | 230 // http://code.google.com/p/chromium/issues/detail?id=89777 |
| 227 NOTIMPLEMENTED(); | 231 NOTIMPLEMENTED(); |
| 228 return; | 232 return; |
| 229 #else | 233 #else |
| 230 | 234 |
| 231 #if defined(OS_WIN) | 235 #if defined(OS_WIN) |
| 232 // Duplicate the handle to the DIB here because the renderer process does not | 236 // Duplicate the handle to the DIB here because the renderer process does not |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 void ThumbnailGenerator::DidStartLoading( | 572 void ThumbnailGenerator::DidStartLoading( |
| 569 content::RenderViewHost* render_view_host) { | 573 content::RenderViewHost* render_view_host) { |
| 570 load_interrupted_ = false; | 574 load_interrupted_ = false; |
| 571 } | 575 } |
| 572 | 576 |
| 573 void ThumbnailGenerator::StopNavigation() { | 577 void ThumbnailGenerator::StopNavigation() { |
| 574 // This function gets called when the page loading is interrupted by the | 578 // This function gets called when the page loading is interrupted by the |
| 575 // stop button. | 579 // stop button. |
| 576 load_interrupted_ = true; | 580 load_interrupted_ = true; |
| 577 } | 581 } |
| OLD | NEW |