| 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_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
| 9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
| 10 | 10 |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 /////////////////////////////////////////////////////////////////////////////// | 597 /////////////////////////////////////////////////////////////////////////////// |
| 598 // RenderWidgetHostViewMac, RenderWidgetHostView implementation: | 598 // RenderWidgetHostViewMac, RenderWidgetHostView implementation: |
| 599 | 599 |
| 600 void RenderWidgetHostViewMac::EnsureBrowserCompositorView() { | 600 void RenderWidgetHostViewMac::EnsureBrowserCompositorView() { |
| 601 TRACE_EVENT0("browser", | 601 TRACE_EVENT0("browser", |
| 602 "RenderWidgetHostViewMac::EnsureBrowserCompositorView"); | 602 "RenderWidgetHostViewMac::EnsureBrowserCompositorView"); |
| 603 | 603 |
| 604 // Create the view, to transition from Destroyed -> Suspended. | 604 // Create the view, to transition from Destroyed -> Suspended. |
| 605 if (browser_compositor_state_ == BrowserCompositorDestroyed) { | 605 if (browser_compositor_state_ == BrowserCompositorDestroyed) { |
| 606 browser_compositor_ = BrowserCompositorMac::Create(); | 606 browser_compositor_ = BrowserCompositorMac::Create(); |
| 607 browser_compositor_->compositor()->SetRootLayer(root_layer_.get()); |
| 607 browser_compositor_->accelerated_widget_mac()->SetNSView(this); | 608 browser_compositor_->accelerated_widget_mac()->SetNSView(this); |
| 608 browser_compositor_state_ = BrowserCompositorSuspended; | 609 browser_compositor_state_ = BrowserCompositorSuspended; |
| 609 } | 610 } |
| 610 | 611 |
| 611 // Show the DelegatedFrameHost to transition from Suspended -> Active. | 612 // Show the DelegatedFrameHost to transition from Suspended -> Active. |
| 612 if (browser_compositor_state_ == BrowserCompositorSuspended) { | 613 if (browser_compositor_state_ == BrowserCompositorSuspended) { |
| 613 delegated_frame_host_->SetCompositor(browser_compositor_->compositor()); | 614 delegated_frame_host_->SetCompositor(browser_compositor_->compositor()); |
| 614 delegated_frame_host_->WasShown(ui::LatencyInfo()); | 615 delegated_frame_host_->WasShown(ui::LatencyInfo()); |
| 615 browser_compositor_->compositor()->SetRootLayer( | |
| 616 root_layer_.get()); | |
| 617 browser_compositor_state_ = BrowserCompositorActive; | 616 browser_compositor_state_ = BrowserCompositorActive; |
| 618 } | 617 } |
| 619 } | 618 } |
| 620 | 619 |
| 621 void RenderWidgetHostViewMac::SuspendBrowserCompositorView() { | 620 void RenderWidgetHostViewMac::SuspendBrowserCompositorView() { |
| 622 TRACE_EVENT0("browser", | 621 TRACE_EVENT0("browser", |
| 623 "RenderWidgetHostViewMac::SuspendBrowserCompositorView"); | 622 "RenderWidgetHostViewMac::SuspendBrowserCompositorView"); |
| 624 | 623 |
| 625 // Hide the DelegatedFrameHost to transition from Active -> Suspended. | 624 // Hide the DelegatedFrameHost to transition from Active -> Suspended. |
| 626 if (browser_compositor_state_ == BrowserCompositorActive) { | 625 if (browser_compositor_state_ == BrowserCompositorActive) { |
| 627 // Disconnect the root layer, which will prevent the compositor from | |
| 628 // producing more frames. | |
| 629 browser_compositor_->compositor()->SetRootLayer(nullptr); | |
| 630 // Marking the DelegatedFrameHost as removed from the window hierarchy is | 626 // Marking the DelegatedFrameHost as removed from the window hierarchy is |
| 631 // necessary to remove all connections to its old ui::Compositor. | 627 // necessary to remove all connections to its old ui::Compositor. |
| 632 delegated_frame_host_->WasHidden(); | 628 delegated_frame_host_->WasHidden(); |
| 633 delegated_frame_host_->ResetCompositor(); | 629 delegated_frame_host_->ResetCompositor(); |
| 634 browser_compositor_state_ = BrowserCompositorSuspended; | 630 browser_compositor_state_ = BrowserCompositorSuspended; |
| 635 } | 631 } |
| 636 } | 632 } |
| 637 | 633 |
| 638 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { | 634 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { |
| 639 TRACE_EVENT0("browser", | 635 TRACE_EVENT0("browser", |
| 640 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); | 636 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); |
| 641 | 637 |
| 642 // Transition from Active -> Suspended if need be. | 638 // Transition from Active -> Suspended if need be. |
| 643 SuspendBrowserCompositorView(); | 639 SuspendBrowserCompositorView(); |
| 644 | 640 |
| 645 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed. | 641 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed. |
| 646 if (browser_compositor_state_ == BrowserCompositorSuspended) { | 642 if (browser_compositor_state_ == BrowserCompositorSuspended) { |
| 647 browser_compositor_->accelerated_widget_mac()->ResetNSView(); | 643 browser_compositor_->accelerated_widget_mac()->ResetNSView(); |
| 648 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); | 644 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); |
| 645 browser_compositor_->compositor()->SetRootLayer(nullptr); |
| 649 BrowserCompositorMac::Recycle(browser_compositor_.Pass()); | 646 BrowserCompositorMac::Recycle(browser_compositor_.Pass()); |
| 650 browser_compositor_state_ = BrowserCompositorDestroyed; | 647 browser_compositor_state_ = BrowserCompositorDestroyed; |
| 651 } | 648 } |
| 652 } | 649 } |
| 653 | 650 |
| 654 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() { | 651 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() { |
| 655 if (browser_compositor_state_ != BrowserCompositorSuspended) | 652 if (browser_compositor_state_ != BrowserCompositorSuspended) |
| 656 return; | 653 return; |
| 657 | 654 |
| 658 // If this view is in a window that is visible, keep around the suspended | 655 // If this view is in a window that is visible, keep around the suspended |
| (...skipping 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3383 | 3380 |
| 3384 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3381 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3385 // regions that are not draggable. (See ControlRegionView in | 3382 // regions that are not draggable. (See ControlRegionView in |
| 3386 // native_app_window_cocoa.mm). This requires the render host view to be | 3383 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3387 // draggable by default. | 3384 // draggable by default. |
| 3388 - (BOOL)mouseDownCanMoveWindow { | 3385 - (BOOL)mouseDownCanMoveWindow { |
| 3389 return YES; | 3386 return YES; |
| 3390 } | 3387 } |
| 3391 | 3388 |
| 3392 @end | 3389 @end |
| OLD | NEW |