| 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/gpu/gpu_backing_store_win.h" | 5 #include "chrome/gpu/gpu_backing_store_win.h" |
| 6 | 6 |
| 7 #include "app/win_util.h" | 7 #include "app/win_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/common/gpu_messages.h" | 9 #include "chrome/common/gpu_messages.h" |
| 10 #include "chrome/gpu/gpu_view_win.h" | 10 #include "chrome/gpu/gpu_view_win.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 void GpuBackingStoreWin::OnChannelConnected(int32 peer_pid) { | 110 void GpuBackingStoreWin::OnChannelConnected(int32 peer_pid) { |
| 111 } | 111 } |
| 112 | 112 |
| 113 void GpuBackingStoreWin::OnChannelError() { | 113 void GpuBackingStoreWin::OnChannelError() { |
| 114 // FIXME(brettw) does this mean we aren't getting any more messages and we | 114 // FIXME(brettw) does this mean we aren't getting any more messages and we |
| 115 // should delete outselves? | 115 // should delete outselves? |
| 116 } | 116 } |
| 117 | 117 |
| 118 void GpuBackingStoreWin::OnPaintToBackingStore( | 118 void GpuBackingStoreWin::OnPaintToBackingStore( |
| 119 base::ProcessId source_process_id, | 119 TransportDIB::Handle dib_handle, |
| 120 TransportDIB::Id id, | |
| 121 const gfx::Rect& bitmap_rect, | 120 const gfx::Rect& bitmap_rect, |
| 122 const std::vector<gfx::Rect>& copy_rects) { | 121 const std::vector<gfx::Rect>& copy_rects) { |
| 123 HANDLE source_process_handle = OpenProcess(PROCESS_ALL_ACCESS, | 122 scoped_ptr<TransportDIB> dib(TransportDIB::Map(dib_handle)); |
| 124 FALSE, source_process_id); | |
| 125 CHECK(source_process_handle); | |
| 126 | |
| 127 // On Windows we need to duplicate the handle from the remote process. | |
| 128 // See BrowserRenderProcessHost::MapTransportDIB for how to do this on other | |
| 129 // platforms. | |
| 130 HANDLE section = win_util::GetSectionFromProcess( | |
| 131 id.handle, source_process_handle, false /* read write */); | |
| 132 CHECK(section); | |
| 133 scoped_ptr<TransportDIB> dib(TransportDIB::Map(section)); | |
| 134 CHECK(dib.get()); | 123 CHECK(dib.get()); |
| 135 | 124 |
| 136 if (!backing_store_dib_) { | 125 if (!backing_store_dib_) { |
| 137 backing_store_dib_ = CreateDIB(hdc_, size_.width(), | 126 backing_store_dib_ = CreateDIB(hdc_, size_.width(), |
| 138 size_.height(), color_depth_); | 127 size_.height(), color_depth_); |
| 139 if (!backing_store_dib_) { | 128 if (!backing_store_dib_) { |
| 140 NOTREACHED(); | 129 NOTREACHED(); |
| 141 | 130 |
| 142 // TODO(brettw): do this in such a way that we can't forget to | 131 // TODO(brettw): do this in such a way that we can't forget to |
| 143 // send the ACK. | 132 // send the ACK. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 paint_rect.height(), | 150 paint_rect.height(), |
| 162 paint_rect.x() - bitmap_rect.x(), | 151 paint_rect.x() - bitmap_rect.x(), |
| 163 paint_rect.y() - bitmap_rect.y(), | 152 paint_rect.y() - bitmap_rect.y(), |
| 164 paint_rect.width(), | 153 paint_rect.width(), |
| 165 paint_rect.height(), | 154 paint_rect.height(), |
| 166 dib->memory(), | 155 dib->memory(), |
| 167 reinterpret_cast<BITMAPINFO*>(&hdr)); | 156 reinterpret_cast<BITMAPINFO*>(&hdr)); |
| 168 view_->InvalidateRect(&paint_rect.ToRECT()); | 157 view_->InvalidateRect(&paint_rect.ToRECT()); |
| 169 } | 158 } |
| 170 | 159 |
| 171 CloseHandle(source_process_handle); | |
| 172 gpu_thread_->Send(new GpuHostMsg_PaintToBackingStore_ACK(routing_id_)); | 160 gpu_thread_->Send(new GpuHostMsg_PaintToBackingStore_ACK(routing_id_)); |
| 173 } | 161 } |
| 174 | 162 |
| 175 void GpuBackingStoreWin::OnScrollBackingStore(int dx, int dy, | 163 void GpuBackingStoreWin::OnScrollBackingStore(int dx, int dy, |
| 176 const gfx::Rect& clip_rect, | 164 const gfx::Rect& clip_rect, |
| 177 const gfx::Size& view_size) { | 165 const gfx::Size& view_size) { |
| 178 RECT damaged_rect, r = clip_rect.ToRECT(); | 166 RECT damaged_rect, r = clip_rect.ToRECT(); |
| 179 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); | 167 ScrollDC(hdc_, dx, dy, NULL, &r, NULL, &damaged_rect); |
| 180 | 168 |
| 181 // TODO(darin): this doesn't work if dx and dy are both non-zero! | 169 // TODO(darin): this doesn't work if dx and dy are both non-zero! |
| 182 DCHECK(dx == 0 || dy == 0); | 170 DCHECK(dx == 0 || dy == 0); |
| 183 | 171 |
| 184 view_->DidScrollBackingStoreRect(dx, dy, clip_rect); | 172 view_->DidScrollBackingStoreRect(dx, dy, clip_rect); |
| 185 } | 173 } |
| OLD | NEW |