| 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_ui_shim.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) | |
| 16 #include <windows.h> | |
| 17 #endif | |
| 18 | |
| 19 BackingStoreProxy::BackingStoreProxy(RenderWidgetHost* widget, | 15 BackingStoreProxy::BackingStoreProxy(RenderWidgetHost* widget, |
| 20 const gfx::Size& size, | 16 const gfx::Size& size, |
| 21 GpuProcessHostUIShim* process_shim, | 17 GpuProcessHostUIShim* process_shim, |
| 22 int32 routing_id) | 18 int32 routing_id) |
| 23 : BackingStore(widget, size), | 19 : BackingStore(widget, size), |
| 24 process_shim_(process_shim), | 20 process_shim_(process_shim), |
| 25 routing_id_(routing_id), | 21 routing_id_(routing_id), |
| 26 waiting_for_paint_ack_(false) { | 22 waiting_for_paint_ack_(false) { |
| 27 process_shim_->AddRoute(routing_id_, this); | 23 process_shim_->AddRoute(routing_id_, this); |
| 28 } | 24 } |
| 29 | 25 |
| 30 BackingStoreProxy::~BackingStoreProxy() { | 26 BackingStoreProxy::~BackingStoreProxy() { |
| 31 process_shim_->RemoveRoute(routing_id_); | 27 process_shim_->RemoveRoute(routing_id_); |
| 32 } | 28 } |
| 33 | 29 |
| 34 void BackingStoreProxy::PaintToBackingStore( | 30 void BackingStoreProxy::PaintToBackingStore( |
| 35 RenderProcessHost* process, | 31 RenderProcessHost* process, |
| 36 TransportDIB::Id bitmap, | 32 TransportDIB::Id dib_id, |
| 33 TransportDIB::Handle dib_handle, |
| 37 const gfx::Rect& bitmap_rect, | 34 const gfx::Rect& bitmap_rect, |
| 38 const std::vector<gfx::Rect>& copy_rects, | 35 const std::vector<gfx::Rect>& copy_rects, |
| 39 bool* painted_synchronously) { | 36 bool* painted_synchronously) { |
| 40 DCHECK(!waiting_for_paint_ack_); | 37 DCHECK(!waiting_for_paint_ack_); |
| 41 | 38 TransportDIB::ScopedHandle scoped_dib_handle(dib_handle); |
| 42 base::ProcessId process_id; | |
| 43 #if defined(OS_WIN) | |
| 44 process_id = ::GetProcessId(process->GetHandle()); | |
| 45 #elif defined(OS_POSIX) | |
| 46 process_id = process->GetHandle(); | |
| 47 #endif | |
| 48 | 39 |
| 49 if (process_shim_->Send(new GpuMsg_PaintToBackingStore( | 40 if (process_shim_->Send(new GpuMsg_PaintToBackingStore( |
| 50 routing_id_, process_id, bitmap, bitmap_rect, copy_rects))) { | 41 routing_id_, scoped_dib_handle.release(), bitmap_rect, copy_rects))) { |
| 51 // Message sent successfully, so the caller can not destroy the | 42 // Message sent successfully, so the caller can not destroy the |
| 52 // TransportDIB. OnDonePaintingToBackingStore will free it later. | 43 // TransportDIB. OnDonePaintingToBackingStore will free it later. |
| 53 *painted_synchronously = false; | 44 *painted_synchronously = false; |
| 54 waiting_for_paint_ack_ = true; | 45 waiting_for_paint_ack_ = true; |
| 55 } else { | 46 } else { |
| 56 // On error, we're done with the TransportDIB and the caller can free it. | 47 // On error, we're done with the TransportDIB and the caller can free it. |
| 57 *painted_synchronously = true; | 48 *painted_synchronously = true; |
| 58 } | 49 } |
| 59 } | 50 } |
| 60 | 51 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 83 |
| 93 // TODO(brettw): does this mean we aren't getting any more messages and we | 84 // TODO(brettw): does this mean we aren't getting any more messages and we |
| 94 // should delete outselves? | 85 // should delete outselves? |
| 95 } | 86 } |
| 96 | 87 |
| 97 void BackingStoreProxy::OnPaintToBackingStoreACK() { | 88 void BackingStoreProxy::OnPaintToBackingStoreACK() { |
| 98 DCHECK(waiting_for_paint_ack_); | 89 DCHECK(waiting_for_paint_ack_); |
| 99 render_widget_host()->DonePaintingToBackingStore(); | 90 render_widget_host()->DonePaintingToBackingStore(); |
| 100 waiting_for_paint_ack_ = false; | 91 waiting_for_paint_ack_ = false; |
| 101 } | 92 } |
| OLD | NEW |