| 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 707 |
| 708 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { | 708 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { |
| 709 TRACE_EVENT0("browser", | 709 TRACE_EVENT0("browser", |
| 710 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); | 710 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); |
| 711 | 711 |
| 712 // Transition from Active -> Suspended if need be. | 712 // Transition from Active -> Suspended if need be. |
| 713 SuspendBrowserCompositorView(); | 713 SuspendBrowserCompositorView(); |
| 714 | 714 |
| 715 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed. | 715 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed. |
| 716 if (browser_compositor_state_ == BrowserCompositorSuspended) { | 716 if (browser_compositor_state_ == BrowserCompositorSuspended) { |
| 717 if (browser_compositor_) { | 717 browser_compositor_->accelerated_widget_mac()->ResetNSView(); |
| 718 browser_compositor_->accelerated_widget_mac()->ResetNSView(); | 718 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); |
| 719 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); | 719 browser_compositor_->compositor()->SetRootLayer(nullptr); |
| 720 browser_compositor_->compositor()->SetRootLayer(nullptr); | 720 BrowserCompositorMac::Recycle(browser_compositor_.Pass()); |
| 721 BrowserCompositorMac::Recycle(browser_compositor_.Pass()); | |
| 722 } | |
| 723 browser_compositor_state_ = BrowserCompositorDestroyed; | 721 browser_compositor_state_ = BrowserCompositorDestroyed; |
| 724 } | 722 } |
| 725 } | 723 } |
| 726 | 724 |
| 727 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() { | 725 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() { |
| 728 if (browser_compositor_state_ != BrowserCompositorSuspended) | 726 if (browser_compositor_state_ != BrowserCompositorSuspended) |
| 729 return; | 727 return; |
| 730 | 728 |
| 731 // If this view is in a window that is visible, keep around the suspended | 729 // If this view is in a window that is visible, keep around the suspended |
| 732 // BrowserCompositorView in case |cocoa_view_| is suddenly revealed (so that | 730 // BrowserCompositorView in case |cocoa_view_| is suddenly revealed (so that |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 void RenderWidgetHostViewMac::WasOccluded() { | 945 void RenderWidgetHostViewMac::WasOccluded() { |
| 948 if (render_widget_host_->is_hidden()) | 946 if (render_widget_host_->is_hidden()) |
| 949 return; | 947 return; |
| 950 | 948 |
| 951 // Note that the following call to WasHidden() can trigger thumbnail | 949 // Note that the following call to WasHidden() can trigger thumbnail |
| 952 // generation on behalf of the NTP, and that cannot succeed if the browser | 950 // generation on behalf of the NTP, and that cannot succeed if the browser |
| 953 // compositor view has been suspended. Therefore these two statements must | 951 // compositor view has been suspended. Therefore these two statements must |
| 954 // occur in this specific order. However, because thumbnail generation is | 952 // occur in this specific order. However, because thumbnail generation is |
| 955 // asychronous, that operation won't run before SuspendBrowserCompositorView() | 953 // asychronous, that operation won't run before SuspendBrowserCompositorView() |
| 956 // completes. As a result you won't get a thumbnail for the page unless you | 954 // completes. As a result you won't get a thumbnail for the page unless you |
| 957 // execute these two statements in this specific order. | 955 // happen to switch back to it. See http://crbug.com/530707 . |
| 958 render_widget_host_->WasHidden(); | 956 render_widget_host_->WasHidden(); |
| 959 SuspendBrowserCompositorView(); | 957 SuspendBrowserCompositorView(); |
| 960 } | 958 } |
| 961 | 959 |
| 962 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { | 960 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { |
| 963 gfx::Rect rect = GetViewBounds(); | 961 gfx::Rect rect = GetViewBounds(); |
| 964 rect.set_size(size); | 962 rect.set_size(size); |
| 965 SetBounds(rect); | 963 SetBounds(rect); |
| 966 } | 964 } |
| 967 | 965 |
| (...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3491 | 3489 |
| 3492 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3490 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3493 // regions that are not draggable. (See ControlRegionView in | 3491 // regions that are not draggable. (See ControlRegionView in |
| 3494 // native_app_window_cocoa.mm). This requires the render host view to be | 3492 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3495 // draggable by default. | 3493 // draggable by default. |
| 3496 - (BOOL)mouseDownCanMoveWindow { | 3494 - (BOOL)mouseDownCanMoveWindow { |
| 3497 return YES; | 3495 return YES; |
| 3498 } | 3496 } |
| 3499 | 3497 |
| 3500 @end | 3498 @end |
| OLD | NEW |