| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "content/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 BrowserPlugin::BrowserPlugin( | 69 BrowserPlugin::BrowserPlugin( |
| 70 RenderViewImpl* render_view, | 70 RenderViewImpl* render_view, |
| 71 WebKit::WebFrame* frame, | 71 WebKit::WebFrame* frame, |
| 72 const WebPluginParams& params) | 72 const WebPluginParams& params) |
| 73 : guest_instance_id_(browser_plugin::kInstanceIDNone), | 73 : guest_instance_id_(browser_plugin::kInstanceIDNone), |
| 74 attached_(false), | 74 attached_(false), |
| 75 render_view_(render_view->AsWeakPtr()), | 75 render_view_(render_view->AsWeakPtr()), |
| 76 render_view_routing_id_(render_view->GetRoutingID()), | 76 render_view_routing_id_(render_view->GetRoutingID()), |
| 77 container_(NULL), | 77 container_(NULL), |
| 78 damage_buffer_sequence_id_(0), | 78 damage_buffer_sequence_id_(0), |
| 79 paint_ack_received_(true), | 79 resize_ack_received_(true), |
| 80 last_device_scale_factor_(1.0f), | 80 last_device_scale_factor_(1.0f), |
| 81 sad_guest_(NULL), | 81 sad_guest_(NULL), |
| 82 guest_crashed_(false), | 82 guest_crashed_(false), |
| 83 is_auto_size_state_dirty_(false), | 83 auto_size_ack_pending_(false), |
| 84 persist_storage_(false), | 84 persist_storage_(false), |
| 85 valid_partition_id_(true), | 85 valid_partition_id_(true), |
| 86 content_window_routing_id_(MSG_ROUTING_NONE), | 86 content_window_routing_id_(MSG_ROUTING_NONE), |
| 87 plugin_focused_(false), | 87 plugin_focused_(false), |
| 88 visible_(true), | 88 visible_(true), |
| 89 before_first_navigation_(true), | 89 before_first_navigation_(true), |
| 90 mouse_locked_(false), | 90 mouse_locked_(false), |
| 91 browser_plugin_manager_(render_view->GetBrowserPluginManager()), | 91 browser_plugin_manager_(render_view->GetBrowserPluginManager()), |
| 92 compositing_enabled_(false), | 92 compositing_enabled_(false), |
| 93 weak_ptr_factory_(this) { | 93 weak_ptr_factory_(this) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 browser_plugin_manager()->Send( | 290 browser_plugin_manager()->Send( |
| 291 new BrowserPluginHostMsg_NavigateGuest(render_view_routing_id_, | 291 new BrowserPluginHostMsg_NavigateGuest(render_view_routing_id_, |
| 292 guest_instance_id_, | 292 guest_instance_id_, |
| 293 src)); | 293 src)); |
| 294 return true; | 294 return true; |
| 295 } | 295 } |
| 296 | 296 |
| 297 void BrowserPlugin::ParseAutoSizeAttribute() { | 297 void BrowserPlugin::ParseAutoSizeAttribute() { |
| 298 auto_size_ack_pending_ = true; |
| 298 last_view_size_ = plugin_rect_.size(); | 299 last_view_size_ = plugin_rect_.size(); |
| 299 is_auto_size_state_dirty_ = true; | |
| 300 UpdateGuestAutoSizeState(GetAutoSizeAttribute()); | 300 UpdateGuestAutoSizeState(GetAutoSizeAttribute()); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void BrowserPlugin::PopulateAutoSizeParameters( | 303 void BrowserPlugin::PopulateAutoSizeParameters( |
| 304 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled) { | 304 BrowserPluginHostMsg_AutoSize_Params* params, bool current_auto_size) { |
| 305 params->enable = auto_size_enabled; | 305 params->enable = current_auto_size; |
| 306 // No need to populate the params if autosize is off. | 306 // No need to populate the params if autosize is off. |
| 307 if (auto_size_enabled) { | 307 if (current_auto_size) { |
| 308 params->max_size = gfx::Size(GetAdjustedMaxWidth(), GetAdjustedMaxHeight()); | 308 params->max_size = gfx::Size(GetAdjustedMaxWidth(), GetAdjustedMaxHeight()); |
| 309 params->min_size = gfx::Size(GetAdjustedMinWidth(), GetAdjustedMinHeight()); | 309 params->min_size = gfx::Size(GetAdjustedMinWidth(), GetAdjustedMinHeight()); |
| 310 | |
| 311 if (max_auto_size_ != params->max_size) | |
| 312 is_auto_size_state_dirty_ = true; | |
| 313 | |
| 314 max_auto_size_ = params->max_size; | |
| 315 } else { | |
| 316 max_auto_size_ = gfx::Size(); | |
| 317 } | 310 } |
| 318 } | 311 } |
| 319 | 312 |
| 320 void BrowserPlugin::UpdateGuestAutoSizeState(bool auto_size_enabled) { | 313 void BrowserPlugin::UpdateGuestAutoSizeState(bool current_auto_size) { |
| 321 // If we haven't yet heard back from the guest about the last resize request, | 314 // If we haven't yet heard back from the guest about the last resize request, |
| 322 // then we don't issue another request until we do in | 315 // then we don't issue another request until we do in |
| 323 // BrowserPlugin::UpdateRect. | 316 // BrowserPlugin::UpdateRect. |
| 324 if (!HasGuestInstanceID() || !paint_ack_received_) | 317 if (!HasGuestInstanceID() || !resize_ack_received_) |
| 325 return; | 318 return; |
| 326 | |
| 327 BrowserPluginHostMsg_AutoSize_Params auto_size_params; | 319 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
| 328 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; | 320 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; |
| 329 if (auto_size_enabled) { | 321 if (current_auto_size) { |
| 330 GetDamageBufferWithSizeParams(&auto_size_params, | 322 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params); |
| 331 &resize_guest_params, | |
| 332 true); | |
| 333 } else { | 323 } else { |
| 334 GetDamageBufferWithSizeParams(NULL, &resize_guest_params, true); | 324 GetDamageBufferWithSizeParams(NULL, &resize_guest_params); |
| 335 } | 325 } |
| 336 paint_ack_received_ = false; | 326 resize_ack_received_ = false; |
| 337 browser_plugin_manager()->Send( | 327 browser_plugin_manager()->Send( |
| 338 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, | 328 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, |
| 339 guest_instance_id_, | 329 guest_instance_id_, |
| 340 auto_size_params, | 330 auto_size_params, |
| 341 resize_guest_params)); | 331 resize_guest_params)); |
| 342 } | 332 } |
| 343 | 333 |
| 344 // static | 334 // static |
| 345 bool BrowserPlugin::UsesDamageBuffer( | 335 bool BrowserPlugin::UsesDamageBuffer( |
| 346 const BrowserPluginMsg_UpdateRect_Params& params) { | 336 const BrowserPluginMsg_UpdateRect_Params& params) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 368 | 358 |
| 369 void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) { | 359 void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) { |
| 370 BrowserPluginHostMsg_Attach_Params attach_params; | 360 BrowserPluginHostMsg_Attach_Params attach_params; |
| 371 attach_params.focused = ShouldGuestBeFocused(); | 361 attach_params.focused = ShouldGuestBeFocused(); |
| 372 attach_params.visible = visible_; | 362 attach_params.visible = visible_; |
| 373 attach_params.name = GetNameAttribute(); | 363 attach_params.name = GetNameAttribute(); |
| 374 attach_params.storage_partition_id = storage_partition_id_; | 364 attach_params.storage_partition_id = storage_partition_id_; |
| 375 attach_params.persist_storage = persist_storage_; | 365 attach_params.persist_storage = persist_storage_; |
| 376 attach_params.src = GetSrcAttribute(); | 366 attach_params.src = GetSrcAttribute(); |
| 377 GetDamageBufferWithSizeParams(&attach_params.auto_size_params, | 367 GetDamageBufferWithSizeParams(&attach_params.auto_size_params, |
| 378 &attach_params.resize_guest_params, | 368 &attach_params.resize_guest_params); |
| 379 false); | |
| 380 | 369 |
| 381 browser_plugin_manager()->Send( | 370 browser_plugin_manager()->Send( |
| 382 new BrowserPluginHostMsg_Attach(render_view_routing_id_, | 371 new BrowserPluginHostMsg_Attach(render_view_routing_id_, |
| 383 guest_instance_id_, attach_params, | 372 guest_instance_id_, attach_params, |
| 384 *extra_params)); | 373 *extra_params)); |
| 385 } | 374 } |
| 386 | 375 |
| 387 void BrowserPlugin::DidCommitCompositorFrame() { | 376 void BrowserPlugin::DidCommitCompositorFrame() { |
| 388 if (compositing_helper_.get()) | 377 if (compositing_helper_.get()) |
| 389 compositing_helper_->DidCommitCompositorFrame(); | 378 compositing_helper_->DidCommitCompositorFrame(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // damage buffer then we know the guest will no longer use the current | 491 // damage buffer then we know the guest will no longer use the current |
| 503 // damage buffer. At this point, we drop the current damage buffer, and | 492 // damage buffer. At this point, we drop the current damage buffer, and |
| 504 // mark the pending damage buffer as the current damage buffer. | 493 // mark the pending damage buffer as the current damage buffer. |
| 505 if (UsesPendingDamageBuffer(params)) { | 494 if (UsesPendingDamageBuffer(params)) { |
| 506 SwapDamageBuffers(); | 495 SwapDamageBuffers(); |
| 507 use_new_damage_buffer = true; | 496 use_new_damage_buffer = true; |
| 508 } | 497 } |
| 509 | 498 |
| 510 bool auto_size = GetAutoSizeAttribute(); | 499 bool auto_size = GetAutoSizeAttribute(); |
| 511 // We receive a resize ACK in regular mode, but not in autosize. | 500 // We receive a resize ACK in regular mode, but not in autosize. |
| 512 // In SW, |paint_ack_received_| is reset in SwapDamageBuffers(). | 501 // In SW, |resize_ack_received_| is reset in SwapDamageBuffers(). |
| 513 // In HW mode, we need to do it here so we can continue sending | 502 // In HW mode, we need to do it here so we can continue sending |
| 514 // resize messages when needed. | 503 // resize messages when needed. |
| 515 if (params.is_resize_ack || | 504 if (params.is_resize_ack || |
| 516 (!params.needs_ack && (auto_size || is_auto_size_state_dirty_))) { | 505 (!params.needs_ack && (auto_size || auto_size_ack_pending_))) { |
| 517 paint_ack_received_ = true; | 506 resize_ack_received_ = true; |
| 518 } | 507 } |
| 519 | 508 |
| 520 bool was_auto_size_state_dirty = auto_size && is_auto_size_state_dirty_; | 509 auto_size_ack_pending_ = false; |
| 521 is_auto_size_state_dirty_ = false; | |
| 522 | 510 |
| 523 if ((!auto_size && (width() != params.view_size.width() || | 511 if ((!auto_size && (width() != params.view_size.width() || |
| 524 height() != params.view_size.height())) || | 512 height() != params.view_size.height())) || |
| 525 (auto_size && was_auto_size_state_dirty) || | 513 (auto_size && (!InAutoSizeBounds(params.view_size))) || |
| 526 GetDeviceScaleFactor() != params.scale_factor) { | 514 GetDeviceScaleFactor() != params.scale_factor) { |
| 527 // We are HW accelerated, render widget does not expect an ack, | 515 // We are HW accelerated, render widget does not expect an ack, |
| 528 // but we still need to update the size. | 516 // but we still need to update the size. |
| 529 if (!params.needs_ack) { | 517 if (!params.needs_ack) { |
| 530 UpdateGuestAutoSizeState(auto_size); | 518 UpdateGuestAutoSizeState(auto_size); |
| 531 return; | 519 return; |
| 532 } | 520 } |
| 533 | 521 |
| 534 if (!paint_ack_received_) { | 522 if (!resize_ack_received_) { |
| 535 // The guest has not yet responded to the last resize request, and | 523 // The guest has not yet responded to the last resize request, and |
| 536 // so we don't want to do anything at this point other than ACK the guest. | 524 // so we don't want to do anything at this point other than ACK the guest. |
| 537 if (auto_size) | 525 if (auto_size) |
| 538 PopulateAutoSizeParameters(&auto_size_params, auto_size); | 526 PopulateAutoSizeParameters(&auto_size_params, auto_size); |
| 539 } else { | 527 } else { |
| 540 // If we have no pending damage buffer, then the guest has not caught up | 528 // If we have no pending damage buffer, then the guest has not caught up |
| 541 // with the BrowserPlugin container. We now tell the guest about the new | 529 // with the BrowserPlugin container. We now tell the guest about the new |
| 542 // container size. | 530 // container size. |
| 543 if (auto_size) { | 531 if (auto_size) { |
| 544 GetDamageBufferWithSizeParams(&auto_size_params, | 532 GetDamageBufferWithSizeParams(&auto_size_params, |
| 545 &resize_guest_params, | 533 &resize_guest_params); |
| 546 was_auto_size_state_dirty); | |
| 547 } else { | 534 } else { |
| 548 GetDamageBufferWithSizeParams(NULL, | 535 GetDamageBufferWithSizeParams(NULL, &resize_guest_params); |
| 549 &resize_guest_params, | |
| 550 was_auto_size_state_dirty); | |
| 551 } | 536 } |
| 552 } | 537 } |
| 553 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 538 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
| 554 render_view_routing_id_, | 539 render_view_routing_id_, |
| 555 guest_instance_id_, | 540 guest_instance_id_, |
| 556 true, | 541 true, |
| 557 auto_size_params, | 542 auto_size_params, |
| 558 resize_guest_params)); | 543 resize_guest_params)); |
| 559 return; | 544 return; |
| 560 } | 545 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 594 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
| 610 render_view_routing_id_, | 595 render_view_routing_id_, |
| 611 guest_instance_id_, | 596 guest_instance_id_, |
| 612 UsesDamageBuffer(params), | 597 UsesDamageBuffer(params), |
| 613 auto_size_params, | 598 auto_size_params, |
| 614 resize_guest_params)); | 599 resize_guest_params)); |
| 615 } | 600 } |
| 616 | 601 |
| 617 void BrowserPlugin::ParseSizeContraintsChanged() { | 602 void BrowserPlugin::ParseSizeContraintsChanged() { |
| 618 bool auto_size = GetAutoSizeAttribute(); | 603 bool auto_size = GetAutoSizeAttribute(); |
| 619 if (auto_size) { | 604 if (auto_size) |
| 620 is_auto_size_state_dirty_ = true; | |
| 621 UpdateGuestAutoSizeState(true); | 605 UpdateGuestAutoSizeState(true); |
| 622 } | |
| 623 } | 606 } |
| 624 | 607 |
| 625 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { | 608 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { |
| 626 return size.width() <= GetAdjustedMaxWidth() && | 609 return size.width() <= GetAdjustedMaxWidth() && |
| 627 size.height() <= GetAdjustedMaxHeight(); | 610 size.height() <= GetAdjustedMaxHeight(); |
| 628 } | 611 } |
| 629 | 612 |
| 630 NPObject* BrowserPlugin::GetContentWindow() const { | 613 NPObject* BrowserPlugin::GetContentWindow() const { |
| 631 if (content_window_routing_id_ == MSG_ROUTING_NONE) | 614 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
| 632 return NULL; | 615 return NULL; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 ParseSrcAttribute(&error); | 740 ParseSrcAttribute(&error); |
| 758 } | 741 } |
| 759 | 742 |
| 760 float BrowserPlugin::GetDeviceScaleFactor() const { | 743 float BrowserPlugin::GetDeviceScaleFactor() const { |
| 761 if (!render_view_.get()) | 744 if (!render_view_.get()) |
| 762 return 1.0f; | 745 return 1.0f; |
| 763 return render_view_->GetWebView()->deviceScaleFactor(); | 746 return render_view_->GetWebView()->deviceScaleFactor(); |
| 764 } | 747 } |
| 765 | 748 |
| 766 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { | 749 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { |
| 767 if (last_device_scale_factor_ == device_scale_factor || !paint_ack_received_) | 750 if (last_device_scale_factor_ == device_scale_factor || !resize_ack_received_) |
| 768 return; | 751 return; |
| 769 | 752 |
| 770 BrowserPluginHostMsg_ResizeGuest_Params params; | 753 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 771 PopulateResizeGuestParameters(¶ms, plugin_rect(), false); | 754 PopulateResizeGuestParameters(¶ms, plugin_rect()); |
| 772 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 755 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 773 render_view_routing_id_, | 756 render_view_routing_id_, |
| 774 guest_instance_id_, | 757 guest_instance_id_, |
| 775 params)); | 758 params)); |
| 776 } | 759 } |
| 777 | 760 |
| 778 void BrowserPlugin::TriggerEvent(const std::string& event_name, | 761 void BrowserPlugin::TriggerEvent(const std::string& event_name, |
| 779 std::map<std::string, base::Value*>* props) { | 762 std::map<std::string, base::Value*>* props) { |
| 780 if (!container()) | 763 if (!container()) |
| 781 return; | 764 return; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 compositing_helper_ = | 853 compositing_helper_ = |
| 871 new BrowserPluginCompositingHelper(container_, | 854 new BrowserPluginCompositingHelper(container_, |
| 872 browser_plugin_manager(), | 855 browser_plugin_manager(), |
| 873 guest_instance_id_, | 856 guest_instance_id_, |
| 874 render_view_routing_id_); | 857 render_view_routing_id_); |
| 875 } | 858 } |
| 876 } else { | 859 } else { |
| 877 // We're switching back to the software path. We create a new damage | 860 // We're switching back to the software path. We create a new damage |
| 878 // buffer that can accommodate the current size of the container. | 861 // buffer that can accommodate the current size of the container. |
| 879 BrowserPluginHostMsg_ResizeGuest_Params params; | 862 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 863 PopulateResizeGuestParameters(¶ms, plugin_rect()); |
| 880 // Request a full repaint from the guest even if its size is not actually | 864 // Request a full repaint from the guest even if its size is not actually |
| 881 // changing. | 865 // changing. |
| 882 PopulateResizeGuestParameters(¶ms, | 866 params.repaint = true; |
| 883 plugin_rect(), | 867 resize_ack_received_ = false; |
| 884 true /* needs_repaint */); | |
| 885 paint_ack_received_ = false; | |
| 886 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 868 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 887 render_view_routing_id_, | 869 render_view_routing_id_, |
| 888 guest_instance_id_, | 870 guest_instance_id_, |
| 889 params)); | 871 params)); |
| 890 } | 872 } |
| 891 compositing_helper_->EnableCompositing(enable); | 873 compositing_helper_->EnableCompositing(enable); |
| 892 } | 874 } |
| 893 | 875 |
| 894 void BrowserPlugin::destroy() { | 876 void BrowserPlugin::destroy() { |
| 895 // If the plugin was initialized then it has a valid |npp_| identifier, and | 877 // If the plugin was initialized then it has a valid |npp_| identifier, and |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 const WebRect& clip_rect, | 1001 const WebRect& clip_rect, |
| 1020 const WebVector<WebRect>& cut_outs_rects, | 1002 const WebVector<WebRect>& cut_outs_rects, |
| 1021 bool is_visible) { | 1003 bool is_visible) { |
| 1022 int old_width = width(); | 1004 int old_width = width(); |
| 1023 int old_height = height(); | 1005 int old_height = height(); |
| 1024 plugin_rect_ = window_rect; | 1006 plugin_rect_ = window_rect; |
| 1025 if (!attached()) | 1007 if (!attached()) |
| 1026 return; | 1008 return; |
| 1027 | 1009 |
| 1028 // In AutoSize mode, guests don't care when the BrowserPlugin container is | 1010 // In AutoSize mode, guests don't care when the BrowserPlugin container is |
| 1029 // resized. If |!paint_ack_received_|, then we are still waiting on a | 1011 // resized. If |!resize_ack_received_|, then we are still waiting on a |
| 1030 // previous resize to be ACK'ed and so we don't issue additional resizes | 1012 // previous resize to be ACK'ed and so we don't issue additional resizes |
| 1031 // until the previous one is ACK'ed. | 1013 // until the previous one is ACK'ed. |
| 1032 // TODO(mthiesse): Assess the performance of calling GetAutoSizeAttribute() on | 1014 // TODO(mthiesse): Assess the performance of calling GetAutoSizeAttribute() on |
| 1033 // resize. | 1015 // resize. |
| 1034 if (!paint_ack_received_ || | 1016 if (!resize_ack_received_ || |
| 1035 (old_width == window_rect.width && old_height == window_rect.height) || | 1017 (old_width == window_rect.width && old_height == window_rect.height) || |
| 1036 GetAutoSizeAttribute()) { | 1018 GetAutoSizeAttribute()) { |
| 1037 // Let the browser know about the updated view rect. | 1019 // Let the browser know about the updated view rect. |
| 1038 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateGeometry( | 1020 browser_plugin_manager()->Send(new BrowserPluginHostMsg_UpdateGeometry( |
| 1039 render_view_routing_id_, guest_instance_id_, plugin_rect_)); | 1021 render_view_routing_id_, guest_instance_id_, plugin_rect_)); |
| 1040 return; | 1022 return; |
| 1041 } | 1023 } |
| 1042 | 1024 |
| 1043 BrowserPluginHostMsg_ResizeGuest_Params params; | 1025 BrowserPluginHostMsg_ResizeGuest_Params params; |
| 1044 PopulateResizeGuestParameters(¶ms, plugin_rect(), false); | 1026 PopulateResizeGuestParameters(¶ms, plugin_rect()); |
| 1045 paint_ack_received_ = false; | 1027 resize_ack_received_ = false; |
| 1046 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 1028 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 1047 render_view_routing_id_, | 1029 render_view_routing_id_, |
| 1048 guest_instance_id_, | 1030 guest_instance_id_, |
| 1049 params)); | 1031 params)); |
| 1050 } | 1032 } |
| 1051 | 1033 |
| 1052 void BrowserPlugin::SwapDamageBuffers() { | 1034 void BrowserPlugin::SwapDamageBuffers() { |
| 1053 current_damage_buffer_.reset(pending_damage_buffer_.release()); | 1035 current_damage_buffer_.reset(pending_damage_buffer_.release()); |
| 1054 paint_ack_received_ = true; | 1036 resize_ack_received_ = true; |
| 1055 } | 1037 } |
| 1056 | 1038 |
| 1057 void BrowserPlugin::PopulateResizeGuestParameters( | 1039 void BrowserPlugin::PopulateResizeGuestParameters( |
| 1058 BrowserPluginHostMsg_ResizeGuest_Params* params, | 1040 BrowserPluginHostMsg_ResizeGuest_Params* params, |
| 1059 const gfx::Rect& view_rect, | 1041 const gfx::Rect& view_rect) { |
| 1060 bool needs_repaint) { | |
| 1061 params->size_changed = true; | 1042 params->size_changed = true; |
| 1062 params->view_rect = view_rect; | 1043 params->view_rect = view_rect; |
| 1063 params->repaint = needs_repaint; | |
| 1064 params->scale_factor = GetDeviceScaleFactor(); | 1044 params->scale_factor = GetDeviceScaleFactor(); |
| 1065 if (last_device_scale_factor_ != params->scale_factor){ | 1045 if (last_device_scale_factor_ != params->scale_factor){ |
| 1066 params->repaint = true; | 1046 params->repaint = true; |
| 1067 last_device_scale_factor_ = params->scale_factor; | 1047 last_device_scale_factor_ = params->scale_factor; |
| 1068 } | 1048 } |
| 1069 | 1049 |
| 1070 // In HW compositing mode, we do not need a damage buffer. | 1050 // In HW compositing mode, we do not need a damage buffer. |
| 1071 if (compositing_enabled_) | 1051 if (compositing_enabled_) |
| 1072 return; | 1052 return; |
| 1073 | 1053 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1084 params->damage_buffer_size = size; | 1064 params->damage_buffer_size = size; |
| 1085 pending_damage_buffer_.reset( | 1065 pending_damage_buffer_.reset( |
| 1086 CreateDamageBuffer(size, ¶ms->damage_buffer_handle)); | 1066 CreateDamageBuffer(size, ¶ms->damage_buffer_handle)); |
| 1087 if (!pending_damage_buffer_) | 1067 if (!pending_damage_buffer_) |
| 1088 NOTREACHED(); | 1068 NOTREACHED(); |
| 1089 params->damage_buffer_sequence_id = ++damage_buffer_sequence_id_; | 1069 params->damage_buffer_sequence_id = ++damage_buffer_sequence_id_; |
| 1090 } | 1070 } |
| 1091 | 1071 |
| 1092 void BrowserPlugin::GetDamageBufferWithSizeParams( | 1072 void BrowserPlugin::GetDamageBufferWithSizeParams( |
| 1093 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 1073 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
| 1094 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, | 1074 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params) { |
| 1095 bool needs_repaint) { | 1075 if (auto_size_params) |
| 1096 if (auto_size_params) { | |
| 1097 PopulateAutoSizeParameters(auto_size_params, GetAutoSizeAttribute()); | 1076 PopulateAutoSizeParameters(auto_size_params, GetAutoSizeAttribute()); |
| 1098 } else { | |
| 1099 max_auto_size_ = gfx::Size(); | |
| 1100 } | |
| 1101 gfx::Size view_size = (auto_size_params && auto_size_params->enable) ? | 1077 gfx::Size view_size = (auto_size_params && auto_size_params->enable) ? |
| 1102 auto_size_params->max_size : gfx::Size(width(), height()); | 1078 auto_size_params->max_size : gfx::Size(width(), height()); |
| 1103 if (view_size.IsEmpty()) | 1079 if (view_size.IsEmpty()) |
| 1104 return; | 1080 return; |
| 1105 paint_ack_received_ = false; | 1081 resize_ack_received_ = false; |
| 1106 gfx::Rect view_rect = gfx::Rect(plugin_rect_.origin(), view_size); | 1082 gfx::Rect view_rect = gfx::Rect(plugin_rect_.origin(), view_size); |
| 1107 PopulateResizeGuestParameters(resize_guest_params, view_rect, needs_repaint); | 1083 PopulateResizeGuestParameters(resize_guest_params, view_rect); |
| 1108 } | 1084 } |
| 1109 | 1085 |
| 1110 #if defined(OS_POSIX) | 1086 #if defined(OS_POSIX) |
| 1111 base::SharedMemory* BrowserPlugin::CreateDamageBuffer( | 1087 base::SharedMemory* BrowserPlugin::CreateDamageBuffer( |
| 1112 const size_t size, | 1088 const size_t size, |
| 1113 base::SharedMemoryHandle* damage_buffer_handle) { | 1089 base::SharedMemoryHandle* damage_buffer_handle) { |
| 1114 scoped_ptr<base::SharedMemory> shared_buf( | 1090 scoped_ptr<base::SharedMemory> shared_buf( |
| 1115 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer( | 1091 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer( |
| 1116 size).release()); | 1092 size).release()); |
| 1117 | 1093 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 const WebKit::WebMouseEvent& event) { | 1279 const WebKit::WebMouseEvent& event) { |
| 1304 browser_plugin_manager()->Send( | 1280 browser_plugin_manager()->Send( |
| 1305 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1281 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 1306 guest_instance_id_, | 1282 guest_instance_id_, |
| 1307 plugin_rect_, | 1283 plugin_rect_, |
| 1308 &event)); | 1284 &event)); |
| 1309 return true; | 1285 return true; |
| 1310 } | 1286 } |
| 1311 | 1287 |
| 1312 } // namespace content | 1288 } // namespace content |
| OLD | NEW |