| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 return results; | 387 return results; |
| 388 } | 388 } |
| 389 | 389 |
| 390 } // namespace | 390 } // namespace |
| 391 | 391 |
| 392 namespace content { | 392 namespace content { |
| 393 | 393 |
| 394 //////////////////////////////////////////////////////////////////////////////// | 394 //////////////////////////////////////////////////////////////////////////////// |
| 395 // DelegatedFrameHost, public: | 395 // DelegatedFrameHost, public: |
| 396 | 396 |
| 397 ui::Compositor* RenderWidgetHostViewMac::GetCompositor() const { | |
| 398 // When |browser_compositor_| is suspended or destroyed, the connection | |
| 399 // between its ui::Compositor and |delegated_frame_host_| has been severed. | |
| 400 if (browser_compositor_state_ == BrowserCompositorActive) | |
| 401 return browser_compositor_->compositor(); | |
| 402 return NULL; | |
| 403 } | |
| 404 | |
| 405 ui::Layer* RenderWidgetHostViewMac::GetLayer() { | 397 ui::Layer* RenderWidgetHostViewMac::GetLayer() { |
| 406 return root_layer_.get(); | 398 return root_layer_.get(); |
| 407 } | 399 } |
| 408 | 400 |
| 409 RenderWidgetHostImpl* RenderWidgetHostViewMac::GetHost() { | 401 RenderWidgetHostImpl* RenderWidgetHostViewMac::GetHost() { |
| 410 return render_widget_host_; | 402 return render_widget_host_; |
| 411 } | 403 } |
| 412 | 404 |
| 413 bool RenderWidgetHostViewMac::IsVisible() { | 405 bool RenderWidgetHostViewMac::IsVisible() { |
| 414 return !render_widget_host_->is_hidden(); | 406 return !render_widget_host_->is_hidden(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 588 |
| 597 // Create the view, to transition from Destroyed -> Suspended. | 589 // Create the view, to transition from Destroyed -> Suspended. |
| 598 if (browser_compositor_state_ == BrowserCompositorDestroyed) { | 590 if (browser_compositor_state_ == BrowserCompositorDestroyed) { |
| 599 browser_compositor_ = BrowserCompositorMac::Create(); | 591 browser_compositor_ = BrowserCompositorMac::Create(); |
| 600 browser_compositor_->accelerated_widget_mac()->SetNSView(this); | 592 browser_compositor_->accelerated_widget_mac()->SetNSView(this); |
| 601 browser_compositor_state_ = BrowserCompositorSuspended; | 593 browser_compositor_state_ = BrowserCompositorSuspended; |
| 602 } | 594 } |
| 603 | 595 |
| 604 // Show the DelegatedFrameHost to transition from Suspended -> Active. | 596 // Show the DelegatedFrameHost to transition from Suspended -> Active. |
| 605 if (browser_compositor_state_ == BrowserCompositorSuspended) { | 597 if (browser_compositor_state_ == BrowserCompositorSuspended) { |
| 606 delegated_frame_host_->AddedToWindow(); | 598 delegated_frame_host_->SetCompositor(browser_compositor_->compositor()); |
| 607 delegated_frame_host_->WasShown(ui::LatencyInfo()); | 599 delegated_frame_host_->WasShown(ui::LatencyInfo()); |
| 608 browser_compositor_->compositor()->SetRootLayer( | 600 browser_compositor_->compositor()->SetRootLayer( |
| 609 root_layer_.get()); | 601 root_layer_.get()); |
| 610 browser_compositor_state_ = BrowserCompositorActive; | 602 browser_compositor_state_ = BrowserCompositorActive; |
| 611 } | 603 } |
| 612 } | 604 } |
| 613 | 605 |
| 614 void RenderWidgetHostViewMac::SuspendBrowserCompositorView() { | 606 void RenderWidgetHostViewMac::SuspendBrowserCompositorView() { |
| 615 TRACE_EVENT0("browser", | 607 TRACE_EVENT0("browser", |
| 616 "RenderWidgetHostViewMac::SuspendBrowserCompositorView"); | 608 "RenderWidgetHostViewMac::SuspendBrowserCompositorView"); |
| 617 | 609 |
| 618 // Hide the DelegatedFrameHost to transition from Active -> Suspended. | 610 // Hide the DelegatedFrameHost to transition from Active -> Suspended. |
| 619 if (browser_compositor_state_ == BrowserCompositorActive) { | 611 if (browser_compositor_state_ == BrowserCompositorActive) { |
| 620 // Disconnect the root layer, which will prevent the compositor from | 612 // Disconnect the root layer, which will prevent the compositor from |
| 621 // producing more frames. | 613 // producing more frames. |
| 622 browser_compositor_->compositor()->SetRootLayer(nullptr); | 614 browser_compositor_->compositor()->SetRootLayer(nullptr); |
| 623 // Marking the DelegatedFrameHost as removed from the window hierarchy is | 615 // Marking the DelegatedFrameHost as removed from the window hierarchy is |
| 624 // necessary to remove all connections to its old ui::Compositor. | 616 // necessary to remove all connections to its old ui::Compositor. |
| 625 delegated_frame_host_->WasHidden(); | 617 delegated_frame_host_->WasHidden(); |
| 626 delegated_frame_host_->RemovingFromWindow(); | 618 delegated_frame_host_->ResetCompositor(); |
| 627 browser_compositor_state_ = BrowserCompositorSuspended; | 619 browser_compositor_state_ = BrowserCompositorSuspended; |
| 628 } | 620 } |
| 629 } | 621 } |
| 630 | 622 |
| 631 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { | 623 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { |
| 632 TRACE_EVENT0("browser", | 624 TRACE_EVENT0("browser", |
| 633 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); | 625 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); |
| 634 | 626 |
| 635 // Transition from Active -> Suspended if need be. | 627 // Transition from Active -> Suspended if need be. |
| 636 SuspendBrowserCompositorView(); | 628 SuspendBrowserCompositorView(); |
| (...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3372 | 3364 |
| 3373 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3365 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3374 // regions that are not draggable. (See ControlRegionView in | 3366 // regions that are not draggable. (See ControlRegionView in |
| 3375 // native_app_window_cocoa.mm). This requires the render host view to be | 3367 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3376 // draggable by default. | 3368 // draggable by default. |
| 3377 - (BOOL)mouseDownCanMoveWindow { | 3369 - (BOOL)mouseDownCanMoveWindow { |
| 3378 return YES; | 3370 return YES; |
| 3379 } | 3371 } |
| 3380 | 3372 |
| 3381 @end | 3373 @end |
| OLD | NEW |