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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
14 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
15 #include "content/browser/renderer_host/backing_store_aura.h" | 14 #include "content/browser/renderer_host/backing_store_aura.h" |
16 #include "content/browser/renderer_host/dip_util.h" | 15 #include "content/browser/renderer_host/dip_util.h" |
17 #include "content/browser/renderer_host/render_view_host_delegate.h" | 16 #include "content/browser/renderer_host/render_view_host_delegate.h" |
18 #include "content/browser/renderer_host/render_widget_host_impl.h" | 17 #include "content/browser/renderer_host/render_widget_host_impl.h" |
19 #include "content/browser/renderer_host/web_input_event_aura.h" | 18 #include "content/browser/renderer_host/web_input_event_aura.h" |
20 #include "content/common/gpu/client/gl_helper.h" | 19 #include "content/common/gpu/client/gl_helper.h" |
21 #include "content/common/gpu/gpu_messages.h" | 20 #include "content/common/gpu/gpu_messages.h" |
22 #include "content/port/browser/render_widget_host_view_port.h" | 21 #include "content/port/browser/render_widget_host_view_port.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 results->horizontalDPI = default_dpi; | 125 results->horizontalDPI = default_dpi; |
127 } | 126 } |
128 | 127 |
129 bool ShouldSendPinchGesture() { | 128 bool ShouldSendPinchGesture() { |
130 static bool pinch_allowed = | 129 static bool pinch_allowed = |
131 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) || | 130 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) || |
132 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); | 131 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); |
133 return pinch_allowed; | 132 return pinch_allowed; |
134 } | 133 } |
135 | 134 |
135 bool ShouldReleaseFrontSurface() { | |
136 static bool release_front_surface_allowed = | |
137 CommandLine::ForCurrentProcess()->HasSwitch( | |
138 switches::kEnableUIReleaseFrontSurface); | |
139 return release_front_surface_allowed; | |
140 } | |
141 | |
136 } // namespace | 142 } // namespace |
137 | 143 |
138 // We have to implement the WindowObserver interface on a separate object | 144 // We have to implement the WindowObserver interface on a separate object |
139 // because clang doesn't like implementing multiple interfaces that have | 145 // because clang doesn't like implementing multiple interfaces that have |
140 // methods with the same name. This object is owned by the | 146 // methods with the same name. This object is owned by the |
141 // RenderWidgetHostViewAura. | 147 // RenderWidgetHostViewAura. |
142 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { | 148 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { |
143 public: | 149 public: |
144 explicit WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} | 150 explicit WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} |
145 virtual ~WindowObserver() {} | 151 virtual ~WindowObserver() {} |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 213 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
208 in_shutdown_(false), | 214 in_shutdown_(false), |
209 is_fullscreen_(false), | 215 is_fullscreen_(false), |
210 popup_parent_host_view_(NULL), | 216 popup_parent_host_view_(NULL), |
211 popup_child_host_view_(NULL), | 217 popup_child_host_view_(NULL), |
212 is_loading_(false), | 218 is_loading_(false), |
213 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 219 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
214 can_compose_inline_(true), | 220 can_compose_inline_(true), |
215 has_composition_text_(false), | 221 has_composition_text_(false), |
216 current_surface_(0), | 222 current_surface_(0), |
223 current_surface_is_protected_(true), | |
224 current_surface_in_use_by_compositor_(true), | |
225 pending_thumbnail_tasks_(0), | |
226 protection_state_id_(0), | |
227 surface_route_id_(0), | |
217 paint_canvas_(NULL), | 228 paint_canvas_(NULL), |
218 synthetic_move_sent_(false), | 229 synthetic_move_sent_(false), |
219 accelerated_compositing_state_changed_(false) { | 230 accelerated_compositing_state_changed_(false) { |
220 host_->SetView(this); | 231 host_->SetView(this); |
221 window_observer_.reset(new WindowObserver(this)); | 232 window_observer_.reset(new WindowObserver(this)); |
222 window_->AddObserver(window_observer_.get()); | 233 window_->AddObserver(window_observer_.get()); |
223 aura::client::SetTooltipText(window_, &tooltip_); | 234 aura::client::SetTooltipText(window_, &tooltip_); |
224 aura::client::SetActivationDelegate(window_, this); | 235 aura::client::SetActivationDelegate(window_, this); |
225 } | 236 } |
226 | 237 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 window_->SetParent(NULL); | 269 window_->SetParent(NULL); |
259 Show(); | 270 Show(); |
260 Focus(); | 271 Focus(); |
261 } | 272 } |
262 | 273 |
263 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 274 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
264 return host_; | 275 return host_; |
265 } | 276 } |
266 | 277 |
267 void RenderWidgetHostViewAura::WasRestored() { | 278 void RenderWidgetHostViewAura::WasRestored() { |
279 if (!host_->IsHidden()) | |
280 return; | |
268 host_->WasRestored(); | 281 host_->WasRestored(); |
282 | |
269 if (!current_surface_ && host_->is_accelerated_compositing_active() && | 283 if (!current_surface_ && host_->is_accelerated_compositing_active() && |
270 !released_front_lock_.get()) | 284 !released_front_lock_.get()) { |
271 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock(); | 285 released_front_lock_ = window_->GetRootWindow()->GetCompositorLock(); |
286 } | |
287 | |
288 AdjustSurfaceProtection(); | |
272 } | 289 } |
273 | 290 |
274 void RenderWidgetHostViewAura::WasHidden() { | 291 void RenderWidgetHostViewAura::WasHidden() { |
292 if (host_->IsHidden()) | |
293 return; | |
294 | |
275 host_->WasHidden(); | 295 host_->WasHidden(); |
296 | |
276 released_front_lock_ = NULL; | 297 released_front_lock_ = NULL; |
298 | |
299 if (ShouldReleaseFrontSurface() && | |
300 host_->is_accelerated_compositing_active()) { | |
301 current_surface_ = 0; | |
302 UpdateExternalTexture(); | |
303 } | |
304 | |
305 AdjustSurfaceProtection(); | |
277 } | 306 } |
278 | 307 |
279 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { | 308 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { |
280 SetBounds(gfx::Rect(window_->bounds().origin(), size)); | 309 SetBounds(gfx::Rect(window_->bounds().origin(), size)); |
281 } | 310 } |
282 | 311 |
283 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { | 312 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { |
284 if (window_->bounds().size() != rect.size() && | 313 if (window_->bounds().size() != rect.size() && |
285 host_->is_accelerated_compositing_active()) { | 314 host_->is_accelerated_compositing_active()) { |
286 resize_locks_.push_back(make_linked_ptr( | 315 resize_locks_.push_back(make_linked_ptr( |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 return; | 497 return; |
469 | 498 |
470 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 499 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
471 GLHelper* gl_helper = factory->GetGLHelper(compositor); | 500 GLHelper* gl_helper = factory->GetGLHelper(compositor); |
472 if (!gl_helper) | 501 if (!gl_helper) |
473 return; | 502 return; |
474 | 503 |
475 unsigned char* addr = static_cast<unsigned char*>( | 504 unsigned char* addr = static_cast<unsigned char*>( |
476 output->getTopDevice()->accessBitmap(true).getPixels()); | 505 output->getTopDevice()->accessBitmap(true).getPixels()); |
477 scoped_callback_runner.Release(); | 506 scoped_callback_runner.Release(); |
507 // Wrap the callback with an internal handler so that we can inject our | |
508 // own completion handlers (where we can call AdjustSurfaceProtection). | |
509 base::Callback<void(bool)> wrapper_callback = base::Bind( | |
510 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished, | |
511 AsWeakPtr(), | |
512 callback); | |
piman
2012/07/25 19:56:51
I believe the thumbnailer expects you to run the c
| |
513 ++pending_thumbnail_tasks_; | |
478 gl_helper->CopyTextureTo(container->texture_id(), | 514 gl_helper->CopyTextureTo(container->texture_id(), |
479 container->size(), | 515 container->size(), |
480 size_in_pixel, | 516 size_in_pixel, |
481 addr, | 517 addr, |
482 callback); | 518 wrapper_callback); |
483 } | 519 } |
484 | 520 |
485 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { | 521 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { |
486 // Delay processing the state change until we either get a software frame if | 522 // Delay processing the state change until we either get a software frame if |
487 // switching to software mode or receive a buffers swapped notification | 523 // switching to software mode or receive a buffers swapped notification |
488 // if switching to accelerated mode. | 524 // if switching to accelerated mode. |
489 // Sometimes (e.g. on a page load) the renderer will spuriously disable then | 525 // Sometimes (e.g. on a page load) the renderer will spuriously disable then |
490 // re-enable accelerated compositing, causing us to flash. | 526 // re-enable accelerated compositing, causing us to flash. |
491 // TODO(piman): factor the enable/disable accelerated compositing message into | 527 // TODO(piman): factor the enable/disable accelerated compositing message into |
492 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have | 528 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have |
(...skipping 10 matching lines...) Expand all Loading... | |
503 // care of it. | 539 // care of it. |
504 window_->layer()->set_scale_content( | 540 window_->layer()->set_scale_content( |
505 !host_->is_accelerated_compositing_active()); | 541 !host_->is_accelerated_compositing_active()); |
506 | 542 |
507 accelerated_compositing_state_changed_ = false; | 543 accelerated_compositing_state_changed_ = false; |
508 } | 544 } |
509 | 545 |
510 if (current_surface_ != 0 && host_->is_accelerated_compositing_active()) { | 546 if (current_surface_ != 0 && host_->is_accelerated_compositing_active()) { |
511 ui::Texture* container = image_transport_clients_[current_surface_]; | 547 ui::Texture* container = image_transport_clients_[current_surface_]; |
512 window_->SetExternalTexture(container); | 548 window_->SetExternalTexture(container); |
513 | 549 current_surface_in_use_by_compositor_ = true; |
514 released_front_lock_ = NULL; | |
515 | 550 |
516 if (!container) { | 551 if (!container) { |
517 resize_locks_.clear(); | 552 resize_locks_.clear(); |
518 } else { | 553 } else { |
519 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; | 554 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; |
520 ResizeLockList::iterator it = resize_locks_.begin(); | 555 ResizeLockList::iterator it = resize_locks_.begin(); |
521 while (it != resize_locks_.end()) { | 556 while (it != resize_locks_.end()) { |
522 gfx::Size container_size = ConvertSizeToDIP(this, | 557 gfx::Size container_size = ConvertSizeToDIP(this, |
523 container->size()); | 558 container->size()); |
524 if ((*it)->expected_size() == container_size) | 559 if ((*it)->expected_size() == container_size) |
(...skipping 16 matching lines...) Expand all Loading... | |
541 it2->get()->UnlockCompositor(); | 576 it2->get()->UnlockCompositor(); |
542 } | 577 } |
543 if (!compositor->HasObserver(this)) | 578 if (!compositor->HasObserver(this)) |
544 compositor->AddObserver(this); | 579 compositor->AddObserver(this); |
545 } | 580 } |
546 resize_locks_.erase(resize_locks_.begin(), it); | 581 resize_locks_.erase(resize_locks_.begin(), it); |
547 } | 582 } |
548 } | 583 } |
549 } else { | 584 } else { |
550 window_->SetExternalTexture(NULL); | 585 window_->SetExternalTexture(NULL); |
586 if (ShouldReleaseFrontSurface() && | |
587 host_->is_accelerated_compositing_active()) { | |
588 // The current surface may have pipelined gl commands, so always wait for | |
589 // the next composite to start. If the current surface is still null, | |
590 // then we really know its no longer in use. | |
591 ui::Compositor* compositor = GetCompositor(); | |
592 if (compositor) { | |
593 on_compositing_will_start_callbacks_.push_back( | |
594 base::Bind(&RenderWidgetHostViewAura:: | |
595 SetSurfaceNotInUseByCompositor, | |
596 AsWeakPtr())); | |
597 if (!compositor->HasObserver(this)) | |
598 compositor->AddObserver(this); | |
599 } | |
600 } | |
551 resize_locks_.clear(); | 601 resize_locks_.clear(); |
552 } | 602 } |
553 } | 603 } |
554 | 604 |
555 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 605 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
556 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 606 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
557 int gpu_host_id) { | 607 int gpu_host_id) { |
608 surface_route_id_ = params_in_pixel.route_id; | |
609 // If protection state changed, then this swap is stale. We must still ACK but | |
610 // do not update current_surface_ since it may have been discarded. | |
611 if (params_in_pixel.protection_state_id && | |
612 params_in_pixel.protection_state_id != protection_state_id_) { | |
613 DCHECK(!current_surface_); | |
614 if (!params_in_pixel.skip_ack) | |
615 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); | |
616 return; | |
617 } | |
558 current_surface_ = params_in_pixel.surface_handle; | 618 current_surface_ = params_in_pixel.surface_handle; |
619 // If we don't require an ACK that means the content is not a fresh updated | |
620 // new frame, rather we are just resetting our handle to some old content that | |
621 // we still hadn't discarded. Although we could display immediately, by not | |
622 // resetting the compositor lock here, we give us some time to get a fresh | |
623 // frame which means fewer content flashes. | |
624 if (!params_in_pixel.skip_ack) | |
625 released_front_lock_ = NULL; | |
626 | |
559 UpdateExternalTexture(); | 627 UpdateExternalTexture(); |
560 | 628 |
561 ui::Compositor* compositor = GetCompositor(); | 629 ui::Compositor* compositor = GetCompositor(); |
562 if (!compositor) { | 630 if (!compositor) { |
563 // We have no compositor, so we have no way to display the surface. | 631 // We have no compositor, so we have no way to display the surface. |
564 // Must still send the ACK. | 632 // Must still send the ACK. |
565 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); | 633 if (!params_in_pixel.skip_ack) |
634 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); | |
566 } else { | 635 } else { |
636 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) != | |
637 image_transport_clients_.end()); | |
567 gfx::Size surface_size_in_pixel = | 638 gfx::Size surface_size_in_pixel = |
568 image_transport_clients_[params_in_pixel.surface_handle]->size(); | 639 image_transport_clients_[params_in_pixel.surface_handle]->size(); |
569 gfx::Size surface_size = ConvertSizeToDIP(this, | 640 gfx::Size surface_size = ConvertSizeToDIP(this, |
570 surface_size_in_pixel); | 641 surface_size_in_pixel); |
571 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 642 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
572 | 643 |
573 if (!resize_locks_.empty()) { | 644 if (!params_in_pixel.skip_ack) { |
574 // If we are waiting for the resize, fast-track the ACK. | 645 if (!resize_locks_.empty()) { |
575 if (compositor->IsThreaded()) { | 646 // If we are waiting for the resize, fast-track the ACK. |
576 // We need the compositor thread to pick up the active buffer before | 647 if (compositor->IsThreaded()) { |
577 // ACKing. | 648 // We need the compositor thread to pick up the active buffer before |
578 on_compositing_did_commit_callbacks_.push_back( | 649 // ACKing. |
650 on_compositing_did_commit_callbacks_.push_back( | |
651 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, | |
652 params_in_pixel.route_id, | |
653 gpu_host_id)); | |
654 if (!compositor->HasObserver(this)) | |
655 compositor->AddObserver(this); | |
656 } else { | |
657 // The compositor will pickup the active buffer during a draw, so we | |
658 // can ACK immediately. | |
659 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, | |
660 compositor); | |
661 } | |
662 } else { | |
663 // Add sending an ACK to the list of things to do OnCompositingWillStart | |
664 on_compositing_will_start_callbacks_.push_back( | |
579 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, | 665 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, |
580 params_in_pixel.route_id, | 666 params_in_pixel.route_id, |
581 gpu_host_id)); | 667 gpu_host_id)); |
582 if (!compositor->HasObserver(this)) | 668 if (!compositor->HasObserver(this)) |
583 compositor->AddObserver(this); | 669 compositor->AddObserver(this); |
584 } else { | |
585 // The compositor will pickup the active buffer during a draw, so we | |
586 // can ACK immediately. | |
587 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, | |
588 compositor); | |
589 } | 670 } |
590 } else { | |
591 // Add sending an ACK to the list of things to do OnCompositingWillStart | |
592 on_compositing_will_start_callbacks_.push_back( | |
593 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, | |
594 params_in_pixel.route_id, | |
595 gpu_host_id)); | |
596 if (!compositor->HasObserver(this)) | |
597 compositor->AddObserver(this); | |
598 } | 671 } |
599 } | 672 } |
600 } | 673 } |
601 | 674 |
602 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 675 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
603 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 676 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
604 int gpu_host_id) { | 677 int gpu_host_id) { |
678 surface_route_id_ = params_in_pixel.route_id; | |
679 // If visible state changed, then this PSB is stale. We must still ACK but | |
680 // do not update current_surface_. | |
681 if (params_in_pixel.protection_state_id && | |
682 params_in_pixel.protection_state_id != protection_state_id_) { | |
683 DCHECK(!current_surface_); | |
684 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); | |
685 return; | |
686 } | |
605 current_surface_ = params_in_pixel.surface_handle; | 687 current_surface_ = params_in_pixel.surface_handle; |
688 released_front_lock_ = NULL; | |
689 DCHECK(current_surface_); | |
606 UpdateExternalTexture(); | 690 UpdateExternalTexture(); |
607 | 691 |
608 ui::Compositor* compositor = GetCompositor(); | 692 ui::Compositor* compositor = GetCompositor(); |
609 if (!compositor) { | 693 if (!compositor) { |
610 // We have no compositor, so we have no way to display the surface | 694 // We have no compositor, so we have no way to display the surface |
611 // Must still send the ACK | 695 // Must still send the ACK |
612 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); | 696 InsertSyncPointAndACK(params_in_pixel.route_id, gpu_host_id, NULL); |
613 } else { | 697 } else { |
698 DCHECK(image_transport_clients_.find(params_in_pixel.surface_handle) != | |
699 image_transport_clients_.end()); | |
614 gfx::Size surface_size_in_pixel = | 700 gfx::Size surface_size_in_pixel = |
615 image_transport_clients_[params_in_pixel.surface_handle]->size(); | 701 image_transport_clients_[params_in_pixel.surface_handle]->size(); |
616 | 702 |
617 // Co-ordinates come in OpenGL co-ordinate space. | 703 // Co-ordinates come in OpenGL co-ordinate space. |
618 // We need to convert to layer space. | 704 // We need to convert to layer space. |
619 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( | 705 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( |
620 params_in_pixel.x, | 706 params_in_pixel.x, |
621 surface_size_in_pixel.height() - params_in_pixel.y - | 707 surface_size_in_pixel.height() - params_in_pixel.y - |
622 params_in_pixel.height, | 708 params_in_pixel.height, |
623 params_in_pixel.width, | 709 params_in_pixel.width, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 if (!surface) { | 763 if (!surface) { |
678 LOG(ERROR) << "Failed to create ImageTransport texture"; | 764 LOG(ERROR) << "Failed to create ImageTransport texture"; |
679 return; | 765 return; |
680 } | 766 } |
681 | 767 |
682 image_transport_clients_[surface_handle] = surface; | 768 image_transport_clients_[surface_handle] = surface; |
683 } | 769 } |
684 | 770 |
685 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( | 771 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( |
686 uint64 surface_handle) { | 772 uint64 surface_handle) { |
773 DCHECK(image_transport_clients_.find(surface_handle) != | |
774 image_transport_clients_.end()); | |
687 if (current_surface_ == surface_handle) { | 775 if (current_surface_ == surface_handle) { |
688 current_surface_ = 0; | 776 current_surface_ = 0; |
689 UpdateExternalTexture(); | 777 UpdateExternalTexture(); |
690 } | 778 } |
691 image_transport_clients_.erase(surface_handle); | 779 image_transport_clients_.erase(surface_handle); |
692 } | 780 } |
693 | 781 |
782 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(ui::Compositor*) { | |
783 if (current_surface_ || !host_->IsHidden()) | |
784 return; | |
785 current_surface_in_use_by_compositor_ = false; | |
786 AdjustSurfaceProtection(); | |
787 } | |
788 | |
789 void RenderWidgetHostViewAura::AdjustSurfaceProtection() { | |
790 // If the current surface is non null, it is protected. | |
791 // If we are visible, it is protected. | |
792 // Otherwise, change to not proctected once done thumbnailing and compositing. | |
793 bool surface_is_protected = | |
794 current_surface_ || | |
795 !host_->IsHidden() || | |
796 (current_surface_is_protected_ && | |
797 (pending_thumbnail_tasks_ || current_surface_in_use_by_compositor_)); | |
798 if (current_surface_is_protected_ == surface_is_protected) | |
799 return; | |
800 current_surface_is_protected_ = surface_is_protected; | |
801 ++protection_state_id_; | |
802 | |
803 if (!surface_route_id_ || !shared_surface_handle_.parent_gpu_process_id) | |
804 return; | |
805 | |
806 RenderWidgetHostImpl::SendFrontSurfaceIsProtected( | |
807 surface_is_protected, | |
808 protection_state_id_, | |
809 surface_route_id_, | |
810 shared_surface_handle_.parent_gpu_process_id); | |
811 } | |
812 | |
813 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished( | |
814 base::Callback<void(bool)> callback, bool result) { | |
815 --pending_thumbnail_tasks_; | |
816 AdjustSurfaceProtection(); | |
817 callback.Run(result); | |
818 } | |
819 | |
694 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { | 820 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { |
695 RenderWidgetHostViewBase::SetBackground(background); | 821 RenderWidgetHostViewBase::SetBackground(background); |
696 host_->SetBackground(background); | 822 host_->SetBackground(background); |
697 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 823 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
698 } | 824 } |
699 | 825 |
700 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { | 826 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { |
701 GetScreenInfoForWindow(results, window_); | 827 GetScreenInfoForWindow(results, window_); |
702 } | 828 } |
703 | 829 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 void RenderWidgetHostViewAura::OnCompositingAborted( | 1415 void RenderWidgetHostViewAura::OnCompositingAborted( |
1290 ui::Compositor* compositor) { | 1416 ui::Compositor* compositor) { |
1291 } | 1417 } |
1292 | 1418 |
1293 //////////////////////////////////////////////////////////////////////////////// | 1419 //////////////////////////////////////////////////////////////////////////////// |
1294 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 1420 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
1295 | 1421 |
1296 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { | 1422 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { |
1297 image_transport_clients_.clear(); | 1423 image_transport_clients_.clear(); |
1298 current_surface_ = 0; | 1424 current_surface_ = 0; |
1425 protection_state_id_ = 0; | |
1426 current_surface_is_protected_ = true; | |
1427 current_surface_in_use_by_compositor_ = true; | |
1428 surface_route_id_ = 0; | |
1299 UpdateExternalTexture(); | 1429 UpdateExternalTexture(); |
1300 locks_pending_draw_.clear(); | 1430 locks_pending_draw_.clear(); |
1301 | 1431 |
1302 DCHECK(!shared_surface_handle_.is_null()); | 1432 DCHECK(!shared_surface_handle_.is_null()); |
1303 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1433 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1304 factory->DestroySharedSurfaceHandle(shared_surface_handle_); | 1434 factory->DestroySharedSurfaceHandle(shared_surface_handle_); |
1305 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); | 1435 shared_surface_handle_ = factory->CreateSharedSurfaceHandle(compositor); |
1306 host_->CompositingSurfaceUpdated(); | 1436 host_->CompositingSurfaceUpdated(); |
1307 host_->ScheduleComposite(); | 1437 host_->ScheduleComposite(); |
1308 } | 1438 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 RenderWidgetHost* widget) { | 1622 RenderWidgetHost* widget) { |
1493 return new RenderWidgetHostViewAura(widget); | 1623 return new RenderWidgetHostViewAura(widget); |
1494 } | 1624 } |
1495 | 1625 |
1496 // static | 1626 // static |
1497 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1627 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
1498 GetScreenInfoForWindow(results, NULL); | 1628 GetScreenInfoForWindow(results, NULL); |
1499 } | 1629 } |
1500 | 1630 |
1501 } // namespace content | 1631 } // namespace content |
OLD | NEW |