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/render_widget_snapshot_taker.h" | 5 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/public/browser/notification_details.h" | 9 #include "content/public/browser/notification_details.h" |
10 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
11 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
14 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
15 #include "ui/base/layout.h" | 15 #include "ui/base/layout.h" |
16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 17 #include "ui/gfx/size_conversions.h" |
17 #include "ui/surface/transport_dib.h" | 18 #include "ui/surface/transport_dib.h" |
18 | 19 |
19 using content::RenderWidgetHost; | 20 using content::RenderWidgetHost; |
20 | 21 |
21 struct RenderWidgetSnapshotTaker::AsyncRequestInfo { | 22 struct RenderWidgetSnapshotTaker::AsyncRequestInfo { |
22 SnapshotReadyCallback callback; | 23 SnapshotReadyCallback callback; |
23 scoped_ptr<TransportDIB> thumbnail_dib; | 24 scoped_ptr<TransportDIB> thumbnail_dib; |
24 RenderWidgetHost* renderer; // Not owned. | 25 RenderWidgetHost* renderer; // Not owned. |
25 }; | 26 }; |
26 | 27 |
(...skipping 12 matching lines...) Expand all Loading... |
39 RenderWidgetHost* renderer, | 40 RenderWidgetHost* renderer, |
40 const SnapshotReadyCallback& callback, | 41 const SnapshotReadyCallback& callback, |
41 gfx::Size page_size, | 42 gfx::Size page_size, |
42 gfx::Size desired_size) { | 43 gfx::Size desired_size) { |
43 // We are going to render the thumbnail asynchronously now, so keep | 44 // We are going to render the thumbnail asynchronously now, so keep |
44 // this callback for later lookup when the rendering is done. | 45 // this callback for later lookup when the rendering is done. |
45 static int sequence_num = 0; | 46 static int sequence_num = 0; |
46 sequence_num++; | 47 sequence_num++; |
47 float scale_factor = ui::GetScaleFactorScale(ui::GetScaleFactorForNativeView( | 48 float scale_factor = ui::GetScaleFactorScale(ui::GetScaleFactorForNativeView( |
48 renderer->GetView()->GetNativeView())); | 49 renderer->GetView()->GetNativeView())); |
49 gfx::Size desired_size_in_pixel = desired_size.Scale(scale_factor); | 50 gfx::Size desired_size_in_pixel = gfx::ToFlooredSize( |
| 51 desired_size.Scale(scale_factor)); |
50 scoped_ptr<TransportDIB> thumbnail_dib(TransportDIB::Create( | 52 scoped_ptr<TransportDIB> thumbnail_dib(TransportDIB::Create( |
51 desired_size_in_pixel.GetArea() * 4, sequence_num)); | 53 desired_size_in_pixel.GetArea() * 4, sequence_num)); |
52 | 54 |
53 #if defined(USE_X11) | 55 #if defined(USE_X11) |
54 // TODO: IPC a handle to the renderer like Windows. | 56 // TODO: IPC a handle to the renderer like Windows. |
55 // http://code.google.com/p/chromium/issues/detail?id=89777 | 57 // http://code.google.com/p/chromium/issues/detail?id=89777 |
56 NOTIMPLEMENTED(); | 58 NOTIMPLEMENTED(); |
57 return; | 59 return; |
58 #else | 60 #else |
59 | 61 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 int new_count = --host_monitor_counts_[renderer]; | 184 int new_count = --host_monitor_counts_[renderer]; |
183 if (new_count == 0) { | 185 if (new_count == 0) { |
184 host_monitor_counts_.erase(renderer); | 186 host_monitor_counts_.erase(renderer); |
185 registrar_.Remove( | 187 registrar_.Remove( |
186 this, | 188 this, |
187 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK
, | 189 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK
, |
188 renderer_source); | 190 renderer_source); |
189 } | 191 } |
190 } | 192 } |
191 } | 193 } |
OLD | NEW |