| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/plugin/webplugin_proxy.h" | 5 #include "chrome/plugin/webplugin_proxy.h" |
| 6 | 6 |
| 7 #include "base/gfx/gdi_util.h" | 7 #include "base/gfx/gdi_util.h" |
| 8 #include "base/gfx/platform_device_win.h" | 8 #include "base/gfx/platform_device_win.h" |
| 9 #include "base/scoped_handle.h" | 9 #include "base/scoped_handle.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // Before we send the invalidate, paint so that renderer uses the updated | 272 // Before we send the invalidate, paint so that renderer uses the updated |
| 273 // bitmap. | 273 // bitmap. |
| 274 delegate_->Paint(windowless_hdc_, offset_rect); | 274 delegate_->Paint(windowless_hdc_, offset_rect); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void WebPluginProxy::UpdateGeometry( | 277 void WebPluginProxy::UpdateGeometry( |
| 278 const gfx::Rect& window_rect, | 278 const gfx::Rect& window_rect, |
| 279 const gfx::Rect& clip_rect, | 279 const gfx::Rect& clip_rect, |
| 280 const std::vector<gfx::Rect>& cutout_rects, | 280 const std::vector<gfx::Rect>& cutout_rects, |
| 281 bool visible, | 281 bool visible, |
| 282 const SharedMemoryHandle& windowless_buffer, | 282 const base::SharedMemoryHandle& windowless_buffer, |
| 283 const SharedMemoryHandle& background_buffer) { | 283 const base::SharedMemoryHandle& background_buffer) { |
| 284 gfx::Rect old = delegate_->rect(); | 284 gfx::Rect old = delegate_->rect(); |
| 285 bool moved = delegate_->rect().x() != window_rect.x() || | 285 bool moved = delegate_->rect().x() != window_rect.x() || |
| 286 delegate_->rect().y() != window_rect.y(); | 286 delegate_->rect().y() != window_rect.y(); |
| 287 delegate_->UpdateGeometry(window_rect, clip_rect, cutout_rects, visible); | 287 delegate_->UpdateGeometry(window_rect, clip_rect, cutout_rects, visible); |
| 288 if (windowless_buffer) { | 288 if (windowless_buffer) { |
| 289 // The plugin's rect changed, so now we have a new buffer to draw into. | 289 // The plugin's rect changed, so now we have a new buffer to draw into. |
| 290 SetWindowlessBuffer(windowless_buffer, background_buffer); | 290 SetWindowlessBuffer(windowless_buffer, background_buffer); |
| 291 } else if (moved) { | 291 } else if (moved) { |
| 292 // The plugin moved, so update our world transform. | 292 // The plugin moved, so update our world transform. |
| 293 UpdateTransform(); | 293 UpdateTransform(); |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 | 296 |
| 297 void WebPluginProxy::SetWindowlessBuffer( | 297 void WebPluginProxy::SetWindowlessBuffer( |
| 298 const SharedMemoryHandle& windowless_buffer, | 298 const base::SharedMemoryHandle& windowless_buffer, |
| 299 const SharedMemoryHandle& background_buffer) { | 299 const base::SharedMemoryHandle& background_buffer) { |
| 300 // Convert the shared memory handle to a handle that works in our process, | 300 // Convert the shared memory handle to a handle that works in our process, |
| 301 // and then use that to create an HDC. | 301 // and then use that to create an HDC. |
| 302 ConvertBuffer(windowless_buffer, | 302 ConvertBuffer(windowless_buffer, |
| 303 &windowless_shared_section_, | 303 &windowless_shared_section_, |
| 304 &windowless_bitmap_, | 304 &windowless_bitmap_, |
| 305 &windowless_hdc_); | 305 &windowless_hdc_); |
| 306 if (background_buffer) { | 306 if (background_buffer) { |
| 307 ConvertBuffer(background_buffer, | 307 ConvertBuffer(background_buffer, |
| 308 &background_shared_section_, | 308 &background_shared_section_, |
| 309 &background_bitmap_, | 309 &background_bitmap_, |
| 310 &background_hdc_); | 310 &background_hdc_); |
| 311 } | 311 } |
| 312 UpdateTransform(); | 312 UpdateTransform(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void WebPluginProxy::ConvertBuffer(const SharedMemoryHandle& buffer, | 315 void WebPluginProxy::ConvertBuffer(const base::SharedMemoryHandle& buffer, |
| 316 ScopedHandle* shared_section, | 316 ScopedHandle* shared_section, |
| 317 ScopedBitmap* bitmap, | 317 ScopedBitmap* bitmap, |
| 318 ScopedHDC* hdc) { | 318 ScopedHDC* hdc) { |
| 319 shared_section->Set(win_util::GetSectionFromProcess( | 319 shared_section->Set(win_util::GetSectionFromProcess( |
| 320 buffer, channel_->renderer_handle(), false)); | 320 buffer, channel_->renderer_handle(), false)); |
| 321 if (shared_section->Get() == NULL) { | 321 if (shared_section->Get() == NULL) { |
| 322 NOTREACHED(); | 322 NOTREACHED(); |
| 323 return; | 323 return; |
| 324 } | 324 } |
| 325 | 325 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 void WebPluginProxy::InitiateHTTPRangeRequest(const char* url, | 369 void WebPluginProxy::InitiateHTTPRangeRequest(const char* url, |
| 370 const char* range_info, | 370 const char* range_info, |
| 371 void* existing_stream, | 371 void* existing_stream, |
| 372 bool notify_needed, | 372 bool notify_needed, |
| 373 HANDLE notify_data) { | 373 HANDLE notify_data) { |
| 374 | 374 |
| 375 Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, | 375 Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, |
| 376 range_info, existing_stream, | 376 range_info, existing_stream, |
| 377 notify_needed, notify_data)); | 377 notify_needed, notify_data)); |
| 378 } | 378 } |
| OLD | NEW |