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/renderer/webplugin_delegate_proxy.h" | 5 #include "chrome/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 | 8 |
9 #include "generated_resources.h" | 9 #include "generated_resources.h" |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 : render_view_(render_view), | 136 : render_view_(render_view), |
137 mime_type_(mime_type), | 137 mime_type_(mime_type), |
138 clsid_(clsid), | 138 clsid_(clsid), |
139 plugin_(NULL), | 139 plugin_(NULL), |
140 windowless_(false), | 140 windowless_(false), |
141 first_paint_(true), | 141 first_paint_(true), |
142 npobject_(NULL), | 142 npobject_(NULL), |
143 send_deferred_update_geometry_(false), | 143 send_deferred_update_geometry_(false), |
144 visible_(false), | 144 visible_(false), |
145 sad_plugin_(NULL), | 145 sad_plugin_(NULL), |
146 window_script_object_(NULL) { | 146 window_script_object_(NULL), |
| 147 transparent_(false), |
| 148 invalidate_pending_(false) { |
147 } | 149 } |
148 | 150 |
149 WebPluginDelegateProxy::~WebPluginDelegateProxy() { | 151 WebPluginDelegateProxy::~WebPluginDelegateProxy() { |
150 if (npobject_) | 152 if (npobject_) |
151 NPN_ReleaseObject(npobject_); | 153 NPN_ReleaseObject(npobject_); |
152 | 154 |
153 if (window_script_object_) { | 155 if (window_script_object_) { |
154 window_script_object_->set_proxy(NULL); | 156 window_script_object_->set_proxy(NULL); |
155 window_script_object_->set_invalid(); | 157 window_script_object_->set_invalid(); |
156 } | 158 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 217 |
216 channel_host_->AddRoute(instance_id_, this, false); | 218 channel_host_->AddRoute(instance_id_, this, false); |
217 | 219 |
218 // Now tell the PluginInstance in the plugin process to initialize. | 220 // Now tell the PluginInstance in the plugin process to initialize. |
219 PluginMsg_Init_Params params; | 221 PluginMsg_Init_Params params; |
220 params.containing_window = render_view_->host_window(); | 222 params.containing_window = render_view_->host_window(); |
221 params.url = url; | 223 params.url = url; |
222 for (int i = 0; i < argc; ++i) { | 224 for (int i = 0; i < argc; ++i) { |
223 params.arg_names.push_back(argn[i]); | 225 params.arg_names.push_back(argn[i]); |
224 params.arg_values.push_back(argv[i]); | 226 params.arg_values.push_back(argv[i]); |
| 227 |
| 228 if (LowerCaseEqualsASCII(params.arg_names.back(), "wmode") && |
| 229 LowerCaseEqualsASCII(params.arg_values.back(), "transparent")) { |
| 230 transparent_ = true; |
| 231 } |
225 } | 232 } |
226 params.load_manually = load_manually; | 233 params.load_manually = load_manually; |
227 params.modal_dialog_event = render_view_->modal_dialog_event(); | 234 params.modal_dialog_event = render_view_->modal_dialog_event(); |
228 | 235 |
229 plugin_ = plugin; | 236 plugin_ = plugin; |
230 | 237 |
231 result = false; | 238 result = false; |
232 IPC::Message* msg = new PluginMsg_Init(instance_id_, params, &result); | 239 IPC::Message* msg = new PluginMsg_Init(instance_id_, params, &result); |
233 Send(msg); | 240 Send(msg); |
234 | 241 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 299 } |
293 | 300 |
294 void WebPluginDelegateProxy::InstallMissingPlugin() { | 301 void WebPluginDelegateProxy::InstallMissingPlugin() { |
295 Send(new PluginMsg_InstallMissingPlugin(instance_id_)); | 302 Send(new PluginMsg_InstallMissingPlugin(instance_id_)); |
296 } | 303 } |
297 | 304 |
298 void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { | 305 void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { |
299 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) | 306 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) |
300 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) | 307 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) |
301 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource) | 308 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource) |
302 IPC_MESSAGE_HANDLER(PluginHostMsg_Invalidate, OnInvalidate) | |
303 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) | 309 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) |
304 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, | 310 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, |
305 OnGetWindowScriptNPObject) | 311 OnGetWindowScriptNPObject) |
306 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement, | 312 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement, |
307 OnGetPluginElement) | 313 OnGetPluginElement) |
308 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) | 314 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) |
309 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) | 315 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) |
310 IPC_MESSAGE_HANDLER(PluginHostMsg_ShowModalHTMLDialog, | 316 IPC_MESSAGE_HANDLER(PluginHostMsg_ShowModalHTMLDialog, |
311 OnShowModalHTMLDialog) | 317 OnShowModalHTMLDialog) |
312 IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, | 318 IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, |
313 OnMissingPluginStatus) | 319 OnMissingPluginStatus) |
314 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) | 320 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) |
315 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCPBrowsingContext, | 321 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCPBrowsingContext, |
316 OnGetCPBrowsingContext) | 322 OnGetCPBrowsingContext) |
317 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad) | 323 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad) |
318 IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest, | 324 IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest, |
319 OnInitiateHTTPRangeRequest) | 325 OnInitiateHTTPRangeRequest) |
320 IPC_MESSAGE_UNHANDLED_ERROR() | 326 IPC_MESSAGE_UNHANDLED_ERROR() |
321 IPC_END_MESSAGE_MAP() | 327 IPC_END_MESSAGE_MAP() |
322 } | 328 } |
323 | 329 |
324 void WebPluginDelegateProxy::OnChannelError() { | 330 void WebPluginDelegateProxy::OnChannelError() { |
325 OnInvalidate(); | 331 if (plugin_) |
| 332 plugin_->Invalidate(); |
326 render_view_->PluginCrashed(plugin_path_); | 333 render_view_->PluginCrashed(plugin_path_); |
327 } | 334 } |
328 | 335 |
329 // Copied from render_widget.cc | |
330 static size_t GetPaintBufSize(const gfx::Rect& rect) { | |
331 // TODO(darin): protect against overflow | |
332 return 4 * rect.width() * rect.height(); | |
333 } | |
334 | |
335 void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect, | 336 void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect, |
336 const gfx::Rect& clip_rect, | 337 const gfx::Rect& clip_rect, |
337 bool visible) { | 338 bool visible) { |
338 bool moved = plugin_rect_.x() != window_rect.x() || | |
339 plugin_rect_.y() != window_rect.y(); | |
340 plugin_rect_ = window_rect; | 339 plugin_rect_ = window_rect; |
341 if (!windowless_) { | 340 if (!windowless_) { |
342 deferred_clip_rect_ = clip_rect; | 341 deferred_clip_rect_ = clip_rect; |
343 visible_ = visible; | 342 visible_ = visible; |
344 send_deferred_update_geometry_ = true; | 343 send_deferred_update_geometry_ = true; |
345 return; | 344 return; |
346 } | 345 } |
347 | 346 |
348 HANDLE windowless_buffer_handle = NULL; | 347 HANDLE transport_store_handle = NULL; |
349 if (!windowless_canvas_.get() || | 348 HANDLE background_store_handle = NULL; |
350 (window_rect.width() != windowless_canvas_->getDevice()->width() || | 349 if (!backing_store_canvas_.get() || |
351 window_rect.height() != windowless_canvas_->getDevice()->height())) { | 350 (window_rect.width() != backing_store_canvas_->getDevice()->width() || |
352 // Create a shared memory section that the plugin paints asynchronously. | 351 window_rect.height() != backing_store_canvas_->getDevice()->height())) { |
353 windowless_canvas_.reset(); | 352 // Create a shared memory section that the plugin paints into |
354 if (!windowless_buffer_lock_) | 353 // asynchronously. |
355 windowless_buffer_lock_.Set(CreateMutex(NULL, FALSE, NULL)); | 354 ResetWindowlessBitmaps(); |
356 windowless_buffer_.reset(new SharedMemory()); | 355 if (!window_rect.IsEmpty()) { |
357 size_t size = GetPaintBufSize(plugin_rect_); | 356 if (!CreateBitmap(&backing_store_, &backing_store_canvas_) || |
358 if (!windowless_buffer_->Create(L"", false, true, size)) { | 357 !CreateBitmap(&transport_store_, &transport_store_canvas_) || |
359 DCHECK(false); | 358 (transparent_ && |
360 windowless_buffer_.reset(); | 359 !CreateBitmap(&background_store_, &background_store_canvas_))) { |
361 return; | 360 DCHECK(false); |
| 361 ResetWindowlessBitmaps(); |
| 362 return; |
| 363 } |
| 364 |
| 365 transport_store_handle = transport_store_->handle(); |
| 366 if (background_store_.get()) |
| 367 background_store_handle = background_store_->handle(); |
362 } | 368 } |
363 | |
364 windowless_canvas_.reset(new gfx::PlatformCanvasWin( | |
365 plugin_rect_.width(), plugin_rect_.height(), false, | |
366 windowless_buffer_->handle())); | |
367 windowless_canvas_->translate(static_cast<SkScalar>(-plugin_rect_.x()), | |
368 static_cast<SkScalar>(-plugin_rect_.y())); | |
369 windowless_canvas_->getTopPlatformDevice().accessBitmap(true). | |
370 eraseARGB(0, 0, 0, 0); | |
371 windowless_buffer_handle = windowless_buffer_->handle(); | |
372 } else if (moved) { | |
373 windowless_canvas_->resetMatrix(); | |
374 windowless_canvas_->translate(static_cast<SkScalar>(-plugin_rect_.x()), | |
375 static_cast<SkScalar>(-plugin_rect_.y())); | |
376 } | 369 } |
377 | 370 |
378 IPC::Message* msg = new PluginMsg_UpdateGeometry( | 371 IPC::Message* msg = new PluginMsg_UpdateGeometry( |
379 instance_id_, window_rect, clip_rect, visible, windowless_buffer_handle, | 372 instance_id_, window_rect, clip_rect, visible, transport_store_handle, |
380 windowless_buffer_lock_); | 373 background_store_handle); |
381 msg->set_unblock(true); | 374 msg->set_unblock(true); |
382 Send(msg); | 375 Send(msg); |
383 } | 376 } |
384 | 377 |
| 378 // Copied from render_widget.cc |
| 379 static size_t GetPaintBufSize(const gfx::Rect& rect) { |
| 380 // TODO(darin): protect against overflow |
| 381 return 4 * rect.width() * rect.height(); |
| 382 } |
| 383 |
| 384 void WebPluginDelegateProxy::ResetWindowlessBitmaps() { |
| 385 backing_store_.reset(); |
| 386 transport_store_.reset(); |
| 387 backing_store_canvas_.reset(); |
| 388 transport_store_canvas_.reset(); |
| 389 background_store_.reset(); |
| 390 background_store_canvas_.release(); |
| 391 } |
| 392 |
| 393 bool WebPluginDelegateProxy::CreateBitmap( |
| 394 scoped_ptr<SharedMemory>* memory, |
| 395 scoped_ptr<gfx::PlatformCanvasWin>* canvas) { |
| 396 size_t size = GetPaintBufSize(plugin_rect_); |
| 397 memory->reset(new SharedMemory()); |
| 398 if (!(*memory)->Create(L"", false, true, size)) |
| 399 return false; |
| 400 |
| 401 canvas->reset(new gfx::PlatformCanvasWin( |
| 402 plugin_rect_.width(), plugin_rect_.height(), true, (*memory)->handle())); |
| 403 return true; |
| 404 } |
| 405 |
385 void WebPluginDelegateProxy::Paint(HDC hdc, const gfx::Rect& damaged_rect) { | 406 void WebPluginDelegateProxy::Paint(HDC hdc, const gfx::Rect& damaged_rect) { |
386 // If the plugin is no longer connected (channel crashed) draw a crashed | 407 // If the plugin is no longer connected (channel crashed) draw a crashed |
387 // plugin bitmap | 408 // plugin bitmap |
388 if (!channel_host_->channel_valid()) { | 409 if (!channel_host_->channel_valid()) { |
389 PaintSadPlugin(hdc, damaged_rect); | 410 PaintSadPlugin(hdc, damaged_rect); |
390 return; | 411 return; |
391 } | 412 } |
392 | 413 |
393 // No paint events for windowed plugins. However, if it is the first paint | 414 // No paint events for windowed plugins. However, if it is the first paint |
394 // we don't know yet whether the plugin is windowless or not, so we have to | 415 // we don't know yet whether the plugin is windowless or not, so we have to |
395 // send the event. | 416 // send the event. |
396 if (!windowless_ && !first_paint_) { | 417 if (!windowless_ && !first_paint_) { |
397 // TODO(maruel): That's not true for printing and thumbnail capture. | 418 // TODO(maruel): That's not true for printing and thumbnail capture. |
398 // We shall use PrintWindow() to draw the window. | 419 // We shall use PrintWindow() to draw the window. |
399 return; | 420 return; |
400 } | 421 } |
401 first_paint_ = false; | |
402 | 422 |
403 // We got a paint before the plugin's coordinates, so there's no buffer to | 423 // We got a paint before the plugin's coordinates, so there's no buffer to |
404 // copy from. | 424 // copy from. |
405 if (!windowless_buffer_.get()) | 425 if (!backing_store_canvas_.get()) |
406 return; | 426 return; |
407 | 427 |
408 // Limit the damaged rectangle to whatever is contained inside the plugin | 428 // Limit the damaged rectangle to whatever is contained inside the plugin |
409 // rectangle, as that's the rectangle that we'll bitblt to the hdc. | 429 // rectangle, as that's the rectangle that we'll bitblt to the hdc. |
410 gfx::Rect rect = damaged_rect.Intersect(plugin_rect_); | 430 gfx::Rect rect = damaged_rect.Intersect(plugin_rect_); |
411 | 431 |
412 DWORD wait_result = WaitForSingleObject(windowless_buffer_lock_, INFINITE); | 432 bool background_changed = false; |
413 DCHECK(wait_result == WAIT_OBJECT_0); | 433 if (background_store_canvas_.get() && BackgroundChanged(hdc, rect)) { |
| 434 background_changed = true; |
| 435 HDC background_hdc = |
| 436 background_store_canvas_->getTopPlatformDevice().getBitmapDC(); |
| 437 BitBlt(background_hdc, rect.x()-plugin_rect_.x(), rect.y()-plugin_rect_.y(), |
| 438 rect.width(), rect.height(), hdc, rect.x(), rect.y(), SRCCOPY); |
| 439 } |
414 | 440 |
415 BLENDFUNCTION m_bf; | 441 if (first_paint_ || background_changed) { |
416 m_bf.BlendOp = AC_SRC_OVER; | 442 gfx::Rect offset_rect = rect; |
417 m_bf.BlendFlags = 0; | 443 offset_rect.Offset(-plugin_rect_.x(), -plugin_rect_.y()); |
418 m_bf.SourceConstantAlpha = 255; | 444 Send(new PluginMsg_Paint(instance_id_, offset_rect)); |
419 m_bf.AlphaFormat = AC_SRC_ALPHA; | 445 CopyFromTransportToBacking(offset_rect); |
| 446 } |
420 | 447 |
421 HDC new_hdc = windowless_canvas_->getTopPlatformDevice().getBitmapDC(); | 448 first_paint_ = false; |
422 AlphaBlend(hdc, rect.x(), rect.y(), rect.width(), rect.height(), | 449 HDC backing_hdc = backing_store_canvas_->getTopPlatformDevice().getBitmapDC(); |
423 new_hdc, rect.x(), rect.y(), rect.width(), rect.height(), m_bf); | 450 BitBlt(hdc, rect.x(), rect.y(), rect.width(), rect.height(), backing_hdc, |
| 451 rect.x()-plugin_rect_.x(), rect.y()-plugin_rect_.y(), SRCCOPY); |
424 | 452 |
425 BOOL result = ReleaseMutex(windowless_buffer_lock_); | 453 if (invalidate_pending_) { |
426 DCHECK(result); | 454 // Only send the PaintAck message if this paint is in response to an |
| 455 // invalidate from the plugin, since this message acts as an access token |
| 456 // to ensure only one process is using the transport dib at a time. |
| 457 invalidate_pending_ = false; |
| 458 Send(new PluginMsg_DidPaint(instance_id_)); |
| 459 } |
| 460 } |
| 461 |
| 462 bool WebPluginDelegateProxy::BackgroundChanged( |
| 463 HDC hdc, |
| 464 const gfx::Rect& rect) { |
| 465 HBITMAP hbitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP)); |
| 466 if (hbitmap == NULL) { |
| 467 NOTREACHED(); |
| 468 return true; |
| 469 } |
| 470 |
| 471 BITMAP bitmap = { 0 }; |
| 472 int result = GetObject(hbitmap, sizeof(bitmap), &bitmap); |
| 473 if (!result) { |
| 474 NOTREACHED(); |
| 475 return true; |
| 476 } |
| 477 |
| 478 XFORM xf; |
| 479 if (!GetWorldTransform(hdc, &xf)) { |
| 480 NOTREACHED(); |
| 481 return true; |
| 482 } |
| 483 |
| 484 int row_byte_size = rect.width() * (bitmap.bmBitsPixel / 8); |
| 485 for (int y = rect.y(); y < rect.bottom(); y++) { |
| 486 char* hdc_row_start = static_cast<char*>(bitmap.bmBits) + |
| 487 (y + static_cast<int>(xf.eDy)) * bitmap.bmWidthBytes + |
| 488 (rect.x() + static_cast<int>(xf.eDx)) * (bitmap.bmBitsPixel / 8); |
| 489 |
| 490 // getAddr32 doesn't use the translation units, so we have to subtract |
| 491 // the plugin origin from the coordinates. |
| 492 uint32_t* canvas_row_start = |
| 493 background_store_canvas_->getDevice()->accessBitmap(true).getAddr32( |
| 494 rect.x() - plugin_rect_.x(), y - plugin_rect_.y()); |
| 495 if (memcmp(hdc_row_start, canvas_row_start, row_byte_size) != 0) |
| 496 return true; |
| 497 } |
| 498 |
| 499 return false; |
427 } | 500 } |
428 | 501 |
429 void WebPluginDelegateProxy::Print(HDC hdc) { | 502 void WebPluginDelegateProxy::Print(HDC hdc) { |
430 PluginMsg_PrintResponse_Params params = { 0 }; | 503 PluginMsg_PrintResponse_Params params = { 0 }; |
431 Send(new PluginMsg_Print(instance_id_, ¶ms)); | 504 Send(new PluginMsg_Print(instance_id_, ¶ms)); |
432 | 505 |
433 SharedMemory memory(params.shared_memory, true); | 506 SharedMemory memory(params.shared_memory, true); |
434 if (!memory.Map(params.size)) { | 507 if (!memory.Map(params.size)) { |
435 NOTREACHED(); | 508 NOTREACHED(); |
436 return; | 509 return; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 cursor); | 554 cursor); |
482 message->set_pump_messages_event(modal_loop_pump_messages_event_); | 555 message->set_pump_messages_event(modal_loop_pump_messages_event_); |
483 Send(message); | 556 Send(message); |
484 return handled; | 557 return handled; |
485 } | 558 } |
486 | 559 |
487 int WebPluginDelegateProxy::GetProcessId() { | 560 int WebPluginDelegateProxy::GetProcessId() { |
488 return channel_host_->peer_pid(); | 561 return channel_host_->peer_pid(); |
489 } | 562 } |
490 | 563 |
491 HWND WebPluginDelegateProxy::GetWindowHandle() { | |
492 NOTREACHED() << "GetWindowHandle can't be called on the proxy."; | |
493 return NULL; | |
494 } | |
495 | |
496 void WebPluginDelegateProxy::OnSetWindow( | 564 void WebPluginDelegateProxy::OnSetWindow( |
497 HWND window, HANDLE modal_loop_pump_messages_event) { | 565 HWND window, HANDLE modal_loop_pump_messages_event) { |
498 windowless_ = window == NULL; | 566 windowless_ = window == NULL; |
499 if (plugin_) | 567 if (plugin_) |
500 plugin_->SetWindow(window, modal_loop_pump_messages_event); | 568 plugin_->SetWindow(window, modal_loop_pump_messages_event); |
501 | 569 |
502 DCHECK(modal_loop_pump_messages_event_ == NULL); | 570 DCHECK(modal_loop_pump_messages_event_ == NULL); |
503 modal_loop_pump_messages_event_.Set(modal_loop_pump_messages_event); | 571 modal_loop_pump_messages_event_.Set(modal_loop_pump_messages_event); |
504 } | 572 } |
505 | 573 |
506 void WebPluginDelegateProxy::OnCancelResource(int id) { | 574 void WebPluginDelegateProxy::OnCancelResource(int id) { |
507 if (plugin_) | 575 if (plugin_) |
508 plugin_->CancelResource(id); | 576 plugin_->CancelResource(id); |
509 } | 577 } |
510 | 578 |
511 void WebPluginDelegateProxy::OnInvalidate() { | 579 void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect) { |
512 if (plugin_) | 580 if (!plugin_) |
513 plugin_->Invalidate(); | 581 return; |
514 } | |
515 | 582 |
516 void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect) { | 583 invalidate_pending_ = true; |
517 if (plugin_) | 584 CopyFromTransportToBacking(rect); |
518 plugin_->InvalidateRect(rect); | 585 plugin_->InvalidateRect(rect); |
519 } | 586 } |
520 | 587 |
521 void WebPluginDelegateProxy::OnGetWindowScriptNPObject( | 588 void WebPluginDelegateProxy::OnGetWindowScriptNPObject( |
522 int route_id, bool* success, void** npobject_ptr) { | 589 int route_id, bool* success, void** npobject_ptr) { |
523 *success = false; | 590 *success = false; |
524 NPObject* npobject = NULL; | 591 NPObject* npobject = NULL; |
525 if (plugin_) | 592 if (plugin_) |
526 npobject = plugin_->GetWindowScriptNPObject(); | 593 npobject = plugin_->GetWindowScriptNPObject(); |
527 | 594 |
528 if (!npobject) | 595 if (!npobject) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 canvas.DrawBitmapInt(*sad_plugin_, | 676 canvas.DrawBitmapInt(*sad_plugin_, |
610 std::max(0, (width - sad_plugin_->width())/2), | 677 std::max(0, (width - sad_plugin_->width())/2), |
611 std::max(0, (height - sad_plugin_->height())/2)); | 678 std::max(0, (height - sad_plugin_->height())/2)); |
612 } | 679 } |
613 | 680 |
614 canvas.getTopPlatformDevice().drawToHDC( | 681 canvas.getTopPlatformDevice().drawToHDC( |
615 hdc, plugin_rect_.x(), plugin_rect_.y(), NULL); | 682 hdc, plugin_rect_.x(), plugin_rect_.y(), NULL); |
616 return; | 683 return; |
617 } | 684 } |
618 | 685 |
| 686 void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) { |
| 687 if (!backing_store_canvas_.get()) |
| 688 return; |
| 689 |
| 690 // Copy the damaged rect from the transport bitmap to the backing store. |
| 691 HDC backing = backing_store_canvas_->getTopPlatformDevice().getBitmapDC(); |
| 692 HDC transport = transport_store_canvas_->getTopPlatformDevice().getBitmapDC(); |
| 693 |
| 694 BitBlt(backing, rect.x(), rect.y(), rect.width(), rect.height(), |
| 695 transport, rect.x(), rect.y(), SRCCOPY); |
| 696 } |
| 697 |
619 void WebPluginDelegateProxy::OnHandleURLRequest( | 698 void WebPluginDelegateProxy::OnHandleURLRequest( |
620 const PluginHostMsg_URLRequest_Params& params) { | 699 const PluginHostMsg_URLRequest_Params& params) { |
621 const char* data = NULL; | 700 const char* data = NULL; |
622 if (params.buffer.size()) | 701 if (params.buffer.size()) |
623 data = ¶ms.buffer[0]; | 702 data = ¶ms.buffer[0]; |
624 | 703 |
625 const char* target = NULL; | 704 const char* target = NULL; |
626 if (params.target.length()) | 705 if (params.target.length()) |
627 target = params.target.c_str(); | 706 target = params.target.c_str(); |
628 | 707 |
(...skipping 25 matching lines...) Expand all Loading... |
654 plugin_->CancelDocumentLoad(); | 733 plugin_->CancelDocumentLoad(); |
655 } | 734 } |
656 | 735 |
657 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( | 736 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( |
658 const std::string& url, const std::string& range_info, | 737 const std::string& url, const std::string& range_info, |
659 HANDLE existing_stream, bool notify_needed, HANDLE notify_data) { | 738 HANDLE existing_stream, bool notify_needed, HANDLE notify_data) { |
660 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), | 739 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), |
661 existing_stream, notify_needed, | 740 existing_stream, notify_needed, |
662 notify_data); | 741 notify_data); |
663 } | 742 } |
OLD | NEW |