OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/weak_ptr.h" | |
12 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
13 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
14 #include "content/browser/renderer_host/backing_store_skia.h" | 13 #include "content/browser/renderer_host/backing_store_skia.h" |
15 #include "content/browser/renderer_host/dip_util.h" | 14 #include "content/browser/renderer_host/dip_util.h" |
16 #include "content/browser/renderer_host/image_transport_client.h" | 15 #include "content/browser/renderer_host/image_transport_client.h" |
17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 16 #include "content/browser/renderer_host/render_widget_host_impl.h" |
18 #include "content/browser/renderer_host/web_input_event_aura.h" | 17 #include "content/browser/renderer_host/web_input_event_aura.h" |
19 #include "content/common/gpu/client/gl_helper.h" | 18 #include "content/common/gpu/client/gl_helper.h" |
20 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
21 #include "content/port/browser/render_widget_host_view_port.h" | 20 #include "content/port/browser/render_widget_host_view_port.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 205 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
207 in_shutdown_(false), | 206 in_shutdown_(false), |
208 is_fullscreen_(false), | 207 is_fullscreen_(false), |
209 popup_parent_host_view_(NULL), | 208 popup_parent_host_view_(NULL), |
210 popup_child_host_view_(NULL), | 209 popup_child_host_view_(NULL), |
211 is_loading_(false), | 210 is_loading_(false), |
212 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 211 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
213 can_compose_inline_(true), | 212 can_compose_inline_(true), |
214 has_composition_text_(false), | 213 has_composition_text_(false), |
215 current_surface_(0), | 214 current_surface_(0), |
| 215 route_id_(0), |
| 216 gpu_host_id_(0), |
| 217 weak_factory_(this), |
| 218 current_valid_release_front_request_id_(0), |
| 219 is_thumbnailing_(false), |
216 paint_canvas_(NULL), | 220 paint_canvas_(NULL), |
217 synthetic_move_sent_(false), | 221 synthetic_move_sent_(false), |
218 needs_update_texture_(false) { | 222 needs_update_texture_(false) { |
219 host_->SetView(this); | 223 host_->SetView(this); |
220 window_observer_.reset(new WindowObserver(this)); | 224 window_observer_.reset(new WindowObserver(this)); |
221 window_->AddObserver(window_observer_.get()); | 225 window_->AddObserver(window_observer_.get()); |
222 aura::client::SetTooltipText(window_, &tooltip_); | 226 aura::client::SetTooltipText(window_, &tooltip_); |
223 aura::client::SetActivationDelegate(window_, this); | 227 aura::client::SetActivationDelegate(window_, this); |
224 } | 228 } |
225 | 229 |
226 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { | 230 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
227 if (!shared_surface_handle_.is_null()) { | 231 if (!shared_surface_handle_.is_null()) { |
228 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 232 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
229 factory->DestroySharedSurfaceHandle(shared_surface_handle_); | 233 factory->DestroySharedSurfaceHandle(shared_surface_handle_); |
230 factory->RemoveObserver(this); | 234 factory->RemoveObserver(this); |
231 } | 235 } |
232 window_->RemoveObserver(window_observer_.get()); | 236 window_->RemoveObserver(window_observer_.get()); |
233 UnlockMouse(); | 237 UnlockMouse(); |
234 if (popup_type_ != WebKit::WebPopupTypeNone) { | 238 if (popup_type_ != WebKit::WebPopupTypeNone) { |
235 DCHECK(popup_parent_host_view_); | 239 DCHECK(popup_parent_host_view_); |
236 popup_parent_host_view_->popup_child_host_view_ = NULL; | 240 popup_parent_host_view_->popup_child_host_view_ = NULL; |
237 } | 241 } |
238 aura::client::SetTooltipText(window_, NULL); | 242 aura::client::SetTooltipText(window_, NULL); |
| 243 weak_factory_.InvalidateWeakPtrs(); |
239 } | 244 } |
240 | 245 |
241 //////////////////////////////////////////////////////////////////////////////// | 246 //////////////////////////////////////////////////////////////////////////////// |
242 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 247 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
243 | 248 |
244 void RenderWidgetHostViewAura::InitAsChild( | 249 void RenderWidgetHostViewAura::InitAsChild( |
245 gfx::NativeView parent_view) { | 250 gfx::NativeView parent_view) { |
246 window_->Init(ui::LAYER_TEXTURED); | 251 window_->Init(ui::LAYER_TEXTURED); |
247 window_->SetName("RenderWidgetHostViewAura"); | 252 window_->SetName("RenderWidgetHostViewAura"); |
248 } | 253 } |
(...skipping 27 matching lines...) Expand all Loading... |
276 Show(); | 281 Show(); |
277 Focus(); | 282 Focus(); |
278 } | 283 } |
279 | 284 |
280 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 285 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
281 return host_; | 286 return host_; |
282 } | 287 } |
283 | 288 |
284 void RenderWidgetHostViewAura::DidBecomeSelected() { | 289 void RenderWidgetHostViewAura::DidBecomeSelected() { |
285 host_->WasRestored(); | 290 host_->WasRestored(); |
| 291 InvalidatePendingRequestReleaseFrontRequest(); |
| 292 if (!route_id_ || !gpu_host_id_) |
| 293 return; |
| 294 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(true, |
| 295 route_id_, |
| 296 gpu_host_id_); |
286 } | 297 } |
287 | 298 |
288 void RenderWidgetHostViewAura::WasHidden() { | 299 void RenderWidgetHostViewAura::WasHidden() { |
289 host_->WasHidden(); | 300 host_->WasHidden(); |
| 301 InvalidatePendingRequestReleaseFrontRequest(); |
| 302 if (!route_id_ || !gpu_host_id_) |
| 303 return; |
| 304 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(false, |
| 305 route_id_, |
| 306 gpu_host_id_); |
290 } | 307 } |
291 | 308 |
292 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { | 309 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { |
293 SetBounds(gfx::Rect(window_->bounds().origin(), size)); | 310 SetBounds(gfx::Rect(window_->bounds().origin(), size)); |
294 } | 311 } |
295 | 312 |
296 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { | 313 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { |
297 if (window_->bounds().size() != rect.size() && | 314 if (window_->bounds().size() != rect.size() && |
298 host_->is_accelerated_compositing_active()) { | 315 host_->is_accelerated_compositing_active()) { |
299 resize_locks_.push_back(make_linked_ptr( | 316 resize_locks_.push_back(make_linked_ptr( |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( | 459 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( |
443 const gfx::Size& size) { | 460 const gfx::Size& size) { |
444 return new BackingStoreSkia(host_, size); | 461 return new BackingStoreSkia(host_, size); |
445 } | 462 } |
446 | 463 |
447 void RenderWidgetHostViewAura::CopyFromCompositingSurface( | 464 void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
448 const gfx::Size& size, | 465 const gfx::Size& size, |
449 skia::PlatformCanvas* output, | 466 skia::PlatformCanvas* output, |
450 base::Callback<void(bool)> callback) { | 467 base::Callback<void(bool)> callback) { |
451 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); | 468 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); |
| 469 if (is_thumbnailing_) |
| 470 return; |
| 471 |
452 ui::Compositor* compositor = GetCompositor(); | 472 ui::Compositor* compositor = GetCompositor(); |
453 if (!compositor) | 473 if (!compositor) |
454 return; | 474 return; |
455 | 475 |
456 std::map<uint64, scoped_refptr<ImageTransportClient> >::iterator it = | 476 std::map<uint64, scoped_refptr<ImageTransportClient> >::iterator it = |
457 image_transport_clients_.find(current_surface_); | 477 image_transport_clients_.find(current_surface_); |
458 if (it == image_transport_clients_.end()) | 478 if (it == image_transport_clients_.end()) |
459 return; | 479 return; |
460 | 480 |
461 ImageTransportClient* container = it->second; | 481 ImageTransportClient* container = it->second; |
462 DCHECK(container); | 482 DCHECK(container); |
463 | 483 |
464 gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size); | 484 gfx::Size size_in_pixel = content::ConvertSizeToPixel(this, size); |
465 if (!output->initialize( | 485 if (!output->initialize( |
466 size_in_pixel.width(), size_in_pixel.height(), true)) | 486 size_in_pixel.width(), size_in_pixel.height(), true)) |
467 return; | 487 return; |
468 | 488 |
469 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 489 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
470 content::GLHelper* gl_helper = factory->GetGLHelper(compositor); | 490 content::GLHelper* gl_helper = factory->GetGLHelper(compositor); |
471 if (!gl_helper) | 491 if (!gl_helper) |
472 return; | 492 return; |
473 | 493 |
474 unsigned char* addr = static_cast<unsigned char*>( | 494 unsigned char* addr = static_cast<unsigned char*>( |
475 output->getTopDevice()->accessBitmap(true).getPixels()); | 495 output->getTopDevice()->accessBitmap(true).getPixels()); |
476 scoped_callback_runner.Release(); | 496 scoped_callback_runner.Release(); |
| 497 is_thumbnailing_ = true; |
| 498 base::Callback<void(bool)> internal_callback = base::Bind( |
| 499 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished, |
| 500 weak_factory_.GetWeakPtr(), |
| 501 callback); |
477 gl_helper->CopyTextureTo(container->texture_id(), | 502 gl_helper->CopyTextureTo(container->texture_id(), |
478 container->size(), | 503 container->size(), |
479 size_in_pixel, | 504 size_in_pixel, |
480 addr, | 505 addr, |
481 callback); | 506 internal_callback); |
| 507 } |
| 508 |
| 509 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished( |
| 510 base::Callback<void(bool)> callback, bool result) { |
| 511 is_thumbnailing_ = false; |
| 512 for (size_t i = 0; i != delayed_release_front_acks_.size(); ++i) |
| 513 delayed_release_front_acks_[i].Run(); |
| 514 delayed_release_front_acks_.clear(); |
| 515 callback.Run(result); |
482 } | 516 } |
483 | 517 |
484 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { | 518 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { |
485 // Delay UpdateExternalTexture until we actually got a software frame. | 519 // Delay UpdateExternalTexture until we actually got a software frame. |
486 // Sometimes (e.g. on a page load) the renderer will spuriously disable then | 520 // Sometimes (e.g. on a page load) the renderer will spuriously disable then |
487 // re-enable accelerated compositing, causing us to flash. | 521 // re-enable accelerated compositing, causing us to flash. |
488 // TODO(piman): factor the enable/disable accelerated compositing message into | 522 // TODO(piman): factor the enable/disable accelerated compositing message into |
489 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have | 523 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have |
490 // fewer inconsistent temporary states. | 524 // fewer inconsistent temporary states. |
491 needs_update_texture_ = true; | 525 needs_update_texture_ = true; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 578 } |
545 } else { | 579 } else { |
546 window_->SetExternalTexture(NULL); | 580 window_->SetExternalTexture(NULL); |
547 resize_locks_.clear(); | 581 resize_locks_.clear(); |
548 } | 582 } |
549 } | 583 } |
550 | 584 |
551 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 585 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
552 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 586 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
553 int gpu_host_id) { | 587 int gpu_host_id) { |
| 588 InvalidatePendingRequestReleaseFrontRequest(); |
554 current_surface_ = params_in_pixel.surface_handle; | 589 current_surface_ = params_in_pixel.surface_handle; |
555 UpdateExternalTexture(); | 590 UpdateExternalTexture(); |
556 | 591 |
557 ui::Compositor* compositor = GetCompositor(); | 592 ui::Compositor* compositor = GetCompositor(); |
558 if (!compositor) { | 593 if (!compositor) { |
559 // We have no compositor, so we have no way to display the surface. | 594 // We have no compositor, so we have no way to display the surface. |
560 // Must still send the ACK. | 595 // Must still send the ACK. |
561 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id, | 596 RenderWidgetHostImpl::AcknowledgeSwapBuffers(params_in_pixel.route_id, |
562 gpu_host_id); | 597 gpu_host_id); |
563 } else { | 598 } else { |
(...skipping 17 matching lines...) Expand all Loading... |
581 params_in_pixel.route_id, gpu_host_id)); | 616 params_in_pixel.route_id, gpu_host_id)); |
582 if (!compositor->HasObserver(this)) | 617 if (!compositor->HasObserver(this)) |
583 compositor->AddObserver(this); | 618 compositor->AddObserver(this); |
584 } | 619 } |
585 } | 620 } |
586 } | 621 } |
587 | 622 |
588 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 623 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
589 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 624 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
590 int gpu_host_id) { | 625 int gpu_host_id) { |
| 626 InvalidatePendingRequestReleaseFrontRequest(); |
591 current_surface_ = params_in_pixel.surface_handle; | 627 current_surface_ = params_in_pixel.surface_handle; |
592 UpdateExternalTexture(); | 628 UpdateExternalTexture(); |
593 | 629 |
594 ui::Compositor* compositor = GetCompositor(); | 630 ui::Compositor* compositor = GetCompositor(); |
595 if (!compositor) { | 631 if (!compositor) { |
596 // We have no compositor, so we have no way to display the surface | 632 // We have no compositor, so we have no way to display the surface |
597 // Must still send the ACK | 633 // Must still send the ACK |
598 RenderWidgetHostImpl::AcknowledgePostSubBuffer( | 634 RenderWidgetHostImpl::AcknowledgePostSubBuffer( |
599 params_in_pixel.route_id, gpu_host_id); | 635 params_in_pixel.route_id, gpu_host_id); |
600 } else { | 636 } else { |
| 637 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) != |
| 638 image_transport_clients_.end()); |
601 gfx::Size surface_size_in_pixel = | 639 gfx::Size surface_size_in_pixel = |
602 image_transport_clients_[params_in_pixel.surface_handle]->size(); | 640 image_transport_clients_[params_in_pixel.surface_handle]->size(); |
603 | 641 |
604 // Co-ordinates come in OpenGL co-ordinate space. | 642 // Co-ordinates come in OpenGL co-ordinate space. |
605 // We need to convert to layer space. | 643 // We need to convert to layer space. |
606 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect( | 644 gfx::Rect rect_to_paint = content::ConvertRectToDIP(this, gfx::Rect( |
607 params_in_pixel.x, | 645 params_in_pixel.x, |
608 surface_size_in_pixel.height() - params_in_pixel.y - | 646 surface_size_in_pixel.height() - params_in_pixel.y - |
609 params_in_pixel.height, | 647 params_in_pixel.height, |
610 params_in_pixel.width, | 648 params_in_pixel.width, |
(...skipping 26 matching lines...) Expand all Loading... |
637 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't | 675 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't |
638 // matter what is returned here as GetBackingStore is the only caller of this | 676 // matter what is returned here as GetBackingStore is the only caller of this |
639 // method. TODO(jbates) implement this if other Aura code needs it. | 677 // method. TODO(jbates) implement this if other Aura code needs it. |
640 return false; | 678 return false; |
641 } | 679 } |
642 | 680 |
643 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( | 681 void RenderWidgetHostViewAura::AcceleratedSurfaceNew( |
644 int32 width_in_pixel, | 682 int32 width_in_pixel, |
645 int32 height_in_pixel, | 683 int32 height_in_pixel, |
646 uint64* surface_handle, | 684 uint64* surface_handle, |
647 TransportDIB::Handle* shm_handle) { | 685 TransportDIB::Handle* shm_handle, |
| 686 int32 route_id, |
| 687 int gpu_host_id) { |
648 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 688 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
649 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient( | 689 scoped_refptr<ImageTransportClient> surface(factory->CreateTransportClient( |
650 gfx::Size(width_in_pixel, height_in_pixel), surface_handle)); | 690 gfx::Size(width_in_pixel, height_in_pixel), surface_handle)); |
651 if (!surface) { | 691 if (!surface) { |
652 LOG(ERROR) << "Failed to create ImageTransportClient"; | 692 LOG(ERROR) << "Failed to create ImageTransportClient"; |
653 return; | 693 return; |
654 } | 694 } |
655 *shm_handle = surface->Handle(); | 695 *shm_handle = surface->Handle(); |
656 | 696 |
657 image_transport_clients_[*surface_handle] = surface; | 697 image_transport_clients_[*surface_handle] = surface; |
| 698 |
| 699 route_id_ = route_id; |
| 700 gpu_host_id_ = gpu_host_id; |
| 701 RenderWidgetHostImpl::SendFrontSurfaceIsProtected(host_->IsVisible(), |
| 702 route_id_, |
| 703 gpu_host_id_); |
658 } | 704 } |
659 | 705 |
660 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( | 706 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( |
661 uint64 surface_handle) { | 707 uint64 surface_handle) { |
662 if (current_surface_ == surface_handle) { | 708 if (current_surface_ == surface_handle) { |
663 current_surface_ = 0; | 709 current_surface_ = 0; |
664 UpdateExternalTexture(); | 710 UpdateExternalTexture(); |
665 } | 711 } |
666 image_transport_clients_.erase(surface_handle); | 712 image_transport_clients_.erase(surface_handle); |
667 } | 713 } |
668 | 714 |
| 715 void RenderWidgetHostViewAura::AcceleratedSurfaceRequestReleaseFront( |
| 716 uint64 surface_handle, |
| 717 int request_id, |
| 718 int retry_count, |
| 719 int32 route_id, |
| 720 int gpu_host_id) { |
| 721 // TODO(mmocny): Once we have implemented smooth tab switching on aura |
| 722 // (crbug.com/126526) then this flag should switch to enabled by default, or |
| 723 // be removed altogether. |
| 724 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 725 switches::kEnableUIReleaseFrontSurface)) |
| 726 return; |
| 727 |
| 728 // This request id becomes the only valid id. We use this id to for request |
| 729 // invalidation and to protect against visibility state ABA issues. |
| 730 current_valid_release_front_request_id_ = request_id; |
| 731 |
| 732 // This surface may have already been released if multiple suggestions were |
| 733 // sent. Always send a reply since previous response may have been discarded. |
| 734 if (image_transport_clients_.find(surface_handle) == |
| 735 image_transport_clients_.end()) { |
| 736 SendRequestReleaseFrontAckAfterThumbnailIfNecessary(request_id, |
| 737 retry_count, |
| 738 true, |
| 739 route_id, |
| 740 gpu_host_id); |
| 741 return; |
| 742 } |
| 743 DCHECK(current_surface_ == surface_handle); |
| 744 |
| 745 // Confirm that the surface is not in use, by making sure the tab is not |
| 746 // visible (visibility can change since the time the request was sent out). |
| 747 if (host_->IsVisible()) { |
| 748 // Send an ACK informing the gpu that we are ignoring this request. |
| 749 RenderWidgetHostImpl::AcknowledgeRequestReleaseFront( |
| 750 request_id, retry_count, false, route_id, gpu_host_id); |
| 751 return; |
| 752 } |
| 753 |
| 754 base::Callback<void(void)> send_ack_if_valid_callback = |
| 755 base::Bind(&RenderWidgetHostViewAura::ReleaseFrontSurfaceIfStillValid, |
| 756 weak_factory_.GetWeakPtr(), |
| 757 surface_handle, |
| 758 request_id, |
| 759 retry_count, |
| 760 route_id, |
| 761 gpu_host_id); |
| 762 |
| 763 ui::Compositor* compositor = GetCompositor(); |
| 764 // We may still be using the surface for the duration of a composite, so check |
| 765 // that we aren't currently in the middle of one. |
| 766 if (!compositor->CurrentlyCompositing()) { |
| 767 send_ack_if_valid_callback.Run(); |
| 768 return; |
| 769 } |
| 770 |
| 771 // We are in the middle of a composite, so we must delay reply. |
| 772 on_compositing_ended_callbacks_.push_back(send_ack_if_valid_callback); |
| 773 if (!compositor->HasObserver(this)) |
| 774 compositor->AddObserver(this); |
| 775 } |
| 776 |
| 777 void RenderWidgetHostViewAura::InvalidatePendingRequestReleaseFrontRequest() { |
| 778 current_valid_release_front_request_id_ = 0; |
| 779 } |
| 780 |
| 781 void RenderWidgetHostViewAura::ReleaseFrontSurfaceIfStillValid( |
| 782 uint64 surface_handle, |
| 783 int request_id, |
| 784 int retry_count, |
| 785 int32 route_id, |
| 786 int gpu_host_id) { |
| 787 // Check if this request_id is valid. No need to send an ACK if not, since |
| 788 // the newer, currently valid request will send one. |
| 789 if (current_valid_release_front_request_id_ != request_id) |
| 790 return; |
| 791 |
| 792 DCHECK(!host_->IsVisible()); |
| 793 DCHECK(current_surface_ == surface_handle); |
| 794 |
| 795 // Release our handle to the surface. |
| 796 AcceleratedSurfaceRelease(surface_handle); |
| 797 DCHECK(!current_surface_); |
| 798 |
| 799 // Now reply to the gpu process, potentially delayed during thumbnailing. |
| 800 SendRequestReleaseFrontAckAfterThumbnailIfNecessary(request_id, |
| 801 retry_count, |
| 802 true, |
| 803 route_id, |
| 804 gpu_host_id); |
| 805 } |
| 806 |
| 807 void RenderWidgetHostViewAura:: |
| 808 SendRequestReleaseFrontAckAfterThumbnailIfNecessary( |
| 809 int request_id, |
| 810 int retry_count, |
| 811 bool was_released, |
| 812 int32 route_id, |
| 813 int gpu_host_id) { |
| 814 base::Callback<void(void)> request_release_front_ack = |
| 815 base::Bind(&RenderWidgetHostImpl::AcknowledgeRequestReleaseFront, |
| 816 request_id, |
| 817 retry_count, |
| 818 was_released, |
| 819 route_id, |
| 820 gpu_host_id); |
| 821 if (is_thumbnailing_) |
| 822 delayed_release_front_acks_.push_back(request_release_front_ack); |
| 823 else |
| 824 request_release_front_ack.Run(); |
| 825 } |
| 826 |
669 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 827 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
670 content::RenderWidgetHostViewBase::SetBackground(background); | 828 content::RenderWidgetHostViewBase::SetBackground(background); |
671 host_->SetBackground(background); | 829 host_->SetBackground(background); |
672 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 830 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
673 } | 831 } |
674 | 832 |
675 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { | 833 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { |
676 GetScreenInfoForWindow(results, window_); | 834 GetScreenInfoForWindow(results, window_); |
677 } | 835 } |
678 | 836 |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 RunCompositingCallbacks(); | 1347 RunCompositingCallbacks(); |
1190 compositor->RemoveObserver(this); | 1348 compositor->RemoveObserver(this); |
1191 } | 1349 } |
1192 | 1350 |
1193 //////////////////////////////////////////////////////////////////////////////// | 1351 //////////////////////////////////////////////////////////////////////////////// |
1194 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 1352 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
1195 | 1353 |
1196 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { | 1354 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { |
1197 image_transport_clients_.clear(); | 1355 image_transport_clients_.clear(); |
1198 current_surface_ = 0; | 1356 current_surface_ = 0; |
| 1357 route_id_ = 0; |
| 1358 gpu_host_id_ = 0; |
| 1359 current_valid_release_front_request_id_ = 0; |
| 1360 is_thumbnailing_ = 0; |
| 1361 delayed_release_front_acks_.clear(); |
1199 UpdateExternalTexture(); | 1362 UpdateExternalTexture(); |
1200 locks_pending_draw_.clear(); | 1363 locks_pending_draw_.clear(); |
1201 | 1364 |
1202 DCHECK(!shared_surface_handle_.is_null()); | 1365 DCHECK(!shared_surface_handle_.is_null()); |
1203 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1366 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1204 factory->DestroySharedSurfaceHandle(shared_surface_handle_); | 1367 factory->DestroySharedSurfaceHandle(shared_surface_handle_); |
1205 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); | 1368 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); |
1206 host_->CompositingSurfaceUpdated(); | 1369 host_->CompositingSurfaceUpdated(); |
1207 host_->ScheduleComposite(); | 1370 host_->ScheduleComposite(); |
1208 } | 1371 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 1498 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
1336 RenderWidgetHost* widget) { | 1499 RenderWidgetHost* widget) { |
1337 return new RenderWidgetHostViewAura(widget); | 1500 return new RenderWidgetHostViewAura(widget); |
1338 } | 1501 } |
1339 | 1502 |
1340 // static | 1503 // static |
1341 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1504 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
1342 WebKit::WebScreenInfo* results) { | 1505 WebKit::WebScreenInfo* results) { |
1343 GetScreenInfoForWindow(results, NULL); | 1506 GetScreenInfoForWindow(results, NULL); |
1344 } | 1507 } |
OLD | NEW |