OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer_host/backing_store_proxy.h" | 5 #include "chrome/browser/renderer_host/backing_store_proxy.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/gpu_process_host.h" | 8 #include "chrome/browser/gpu_process_host_ui_shim.h" |
9 #include "chrome/browser/renderer_host/render_process_host.h" | 9 #include "chrome/browser/renderer_host/render_process_host.h" |
10 #include "chrome/browser/renderer_host/render_widget_host.h" | 10 #include "chrome/browser/renderer_host/render_widget_host.h" |
11 #include "chrome/common/gpu_messages.h" | 11 #include "chrome/common/gpu_messages.h" |
12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
13 #include "gfx/rect.h" | 13 #include "gfx/rect.h" |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
16 #include <windows.h> | 16 #include <windows.h> |
17 #endif | 17 #endif |
18 | 18 |
19 BackingStoreProxy::BackingStoreProxy(RenderWidgetHost* widget, | 19 BackingStoreProxy::BackingStoreProxy(RenderWidgetHost* widget, |
20 const gfx::Size& size, | 20 const gfx::Size& size, |
21 GpuProcessHost* process, | 21 GpuProcessHostUIShim* process_shim, |
22 int32 routing_id) | 22 int32 routing_id) |
23 : BackingStore(widget, size), | 23 : BackingStore(widget, size), |
24 process_(process), | 24 process_shim_(process_shim), |
25 routing_id_(routing_id), | 25 routing_id_(routing_id), |
26 waiting_for_paint_ack_(false) { | 26 waiting_for_paint_ack_(false) { |
27 process_->AddRoute(routing_id_, this); | 27 process_shim_->AddRoute(routing_id_, this); |
28 } | 28 } |
29 | 29 |
30 BackingStoreProxy::~BackingStoreProxy() { | 30 BackingStoreProxy::~BackingStoreProxy() { |
31 process_->RemoveRoute(routing_id_); | 31 process_shim_->RemoveRoute(routing_id_); |
32 } | 32 } |
33 | 33 |
34 void BackingStoreProxy::PaintToBackingStore( | 34 void BackingStoreProxy::PaintToBackingStore( |
35 RenderProcessHost* process, | 35 RenderProcessHost* process, |
36 TransportDIB::Id bitmap, | 36 TransportDIB::Id bitmap, |
37 const gfx::Rect& bitmap_rect, | 37 const gfx::Rect& bitmap_rect, |
38 const std::vector<gfx::Rect>& copy_rects, | 38 const std::vector<gfx::Rect>& copy_rects, |
39 bool* painted_synchronously) { | 39 bool* painted_synchronously) { |
40 DCHECK(!waiting_for_paint_ack_); | 40 DCHECK(!waiting_for_paint_ack_); |
41 | 41 |
42 base::ProcessId process_id; | 42 base::ProcessId process_id; |
43 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
44 process_id = ::GetProcessId(process->GetHandle()); | 44 process_id = ::GetProcessId(process->GetHandle()); |
45 #elif defined(OS_POSIX) | 45 #elif defined(OS_POSIX) |
46 process_id = process->GetHandle(); | 46 process_id = process->GetHandle(); |
47 #endif | 47 #endif |
48 | 48 |
49 if (process_->Send(new GpuMsg_PaintToBackingStore( | 49 if (process_shim_->Send(new GpuMsg_PaintToBackingStore( |
50 routing_id_, process_id, bitmap, bitmap_rect, copy_rects))) { | 50 routing_id_, process_id, bitmap, bitmap_rect, copy_rects))) { |
51 // Message sent successfully, so the caller can not destroy the | 51 // Message sent successfully, so the caller can not destroy the |
52 // TransportDIB. OnDonePaintingToBackingStore will free it later. | 52 // TransportDIB. OnDonePaintingToBackingStore will free it later. |
53 *painted_synchronously = false; | 53 *painted_synchronously = false; |
54 waiting_for_paint_ack_ = true; | 54 waiting_for_paint_ack_ = true; |
55 } else { | 55 } else { |
56 // On error, we're done with the TransportDIB and the caller can free it. | 56 // On error, we're done with the TransportDIB and the caller can free it. |
57 *painted_synchronously = true; | 57 *painted_synchronously = true; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 bool BackingStoreProxy::CopyFromBackingStore(const gfx::Rect& rect, | 61 bool BackingStoreProxy::CopyFromBackingStore(const gfx::Rect& rect, |
62 skia::PlatformCanvas* output) { | 62 skia::PlatformCanvas* output) { |
63 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
64 return false; | 64 return false; |
65 } | 65 } |
66 | 66 |
67 void BackingStoreProxy::ScrollBackingStore(int dx, int dy, | 67 void BackingStoreProxy::ScrollBackingStore(int dx, int dy, |
68 const gfx::Rect& clip_rect, | 68 const gfx::Rect& clip_rect, |
69 const gfx::Size& view_size) { | 69 const gfx::Size& view_size) { |
70 process_->Send(new GpuMsg_ScrollBackingStore(routing_id_, dx, dy, | 70 process_shim_->Send(new GpuMsg_ScrollBackingStore(routing_id_, dx, dy, |
71 clip_rect, view_size)); | 71 clip_rect, view_size)); |
72 } | 72 } |
73 | 73 |
74 void BackingStoreProxy::OnMessageReceived(const IPC::Message& msg) { | 74 void BackingStoreProxy::OnMessageReceived(const IPC::Message& msg) { |
75 IPC_BEGIN_MESSAGE_MAP(BackingStoreProxy, msg) | 75 IPC_BEGIN_MESSAGE_MAP(BackingStoreProxy, msg) |
76 IPC_MESSAGE_HANDLER(GpuHostMsg_PaintToBackingStore_ACK, | 76 IPC_MESSAGE_HANDLER(GpuHostMsg_PaintToBackingStore_ACK, |
77 OnPaintToBackingStoreACK) | 77 OnPaintToBackingStoreACK) |
78 IPC_END_MESSAGE_MAP_EX() | 78 IPC_END_MESSAGE_MAP_EX() |
79 } | 79 } |
80 | 80 |
81 void BackingStoreProxy::OnChannelConnected(int32 peer_pid) { | 81 void BackingStoreProxy::OnChannelConnected(int32 peer_pid) { |
(...skipping 10 matching lines...) Expand all Loading... |
92 | 92 |
93 // FIXME(brettw) does this mean we aren't getting any more messages and we | 93 // FIXME(brettw) does this mean we aren't getting any more messages and we |
94 // should delete outselves? | 94 // should delete outselves? |
95 } | 95 } |
96 | 96 |
97 void BackingStoreProxy::OnPaintToBackingStoreACK() { | 97 void BackingStoreProxy::OnPaintToBackingStoreACK() { |
98 DCHECK(waiting_for_paint_ack_); | 98 DCHECK(waiting_for_paint_ack_); |
99 render_widget_host()->DonePaintingToBackingStore(); | 99 render_widget_host()->DonePaintingToBackingStore(); |
100 waiting_for_paint_ack_ = false; | 100 waiting_for_paint_ack_ = false; |
101 } | 101 } |
OLD | NEW |