Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1461463002: Reland fix for thumbnail generation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tight ownership of context, still ref counted Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <stdint.h> 10 #include <stdint.h>
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 648
649 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() { 649 void RenderWidgetHostViewMac::DestroyBrowserCompositorView() {
650 TRACE_EVENT0("browser", 650 TRACE_EVENT0("browser",
651 "RenderWidgetHostViewMac::DestroyBrowserCompositorView"); 651 "RenderWidgetHostViewMac::DestroyBrowserCompositorView");
652 652
653 // Transition from Active -> Suspended if need be. 653 // Transition from Active -> Suspended if need be.
654 SuspendBrowserCompositorView(); 654 SuspendBrowserCompositorView();
655 655
656 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed. 656 // Destroy the BrowserCompositorView to transition Suspended -> Destroyed.
657 if (browser_compositor_state_ == BrowserCompositorSuspended) { 657 if (browser_compositor_state_ == BrowserCompositorSuspended) {
658 browser_compositor_->accelerated_widget_mac()->ResetNSView(); 658 if (browser_compositor_) {
659 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0)); 659 browser_compositor_->accelerated_widget_mac()->ResetNSView();
660 browser_compositor_->compositor()->SetRootLayer(nullptr); 660 browser_compositor_->compositor()->SetScaleAndSize(1.0, gfx::Size(0, 0));
661 BrowserCompositorMac::Recycle(browser_compositor_.Pass()); 661 browser_compositor_->compositor()->SetRootLayer(nullptr);
662 BrowserCompositorMac::Recycle(std::move(browser_compositor_));
663 }
662 browser_compositor_state_ = BrowserCompositorDestroyed; 664 browser_compositor_state_ = BrowserCompositorDestroyed;
663 } 665 }
664 } 666 }
665 667
666 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() { 668 void RenderWidgetHostViewMac::DestroySuspendedBrowserCompositorViewIfNeeded() {
667 if (browser_compositor_state_ != BrowserCompositorSuspended) 669 if (browser_compositor_state_ != BrowserCompositorSuspended)
668 return; 670 return;
669 671
670 // If this view is in a window that is visible, keep around the suspended 672 // If this view is in a window that is visible, keep around the suspended
671 // BrowserCompositorView in case |cocoa_view_| is suddenly revealed (so that 673 // BrowserCompositorView in case |cocoa_view_| is suddenly revealed (so that
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 void RenderWidgetHostViewMac::WasOccluded() { 888 void RenderWidgetHostViewMac::WasOccluded() {
887 if (render_widget_host_->is_hidden()) 889 if (render_widget_host_->is_hidden())
888 return; 890 return;
889 891
890 // Note that the following call to WasHidden() can trigger thumbnail 892 // Note that the following call to WasHidden() can trigger thumbnail
891 // generation on behalf of the NTP, and that cannot succeed if the browser 893 // generation on behalf of the NTP, and that cannot succeed if the browser
892 // compositor view has been suspended. Therefore these two statements must 894 // compositor view has been suspended. Therefore these two statements must
893 // occur in this specific order. However, because thumbnail generation is 895 // occur in this specific order. However, because thumbnail generation is
894 // asychronous, that operation won't run before SuspendBrowserCompositorView() 896 // asychronous, that operation won't run before SuspendBrowserCompositorView()
895 // completes. As a result you won't get a thumbnail for the page unless you 897 // completes. As a result you won't get a thumbnail for the page unless you
896 // happen to switch back to it. See http://crbug.com/530707 . 898 // execute these two statements in this specific order.
897 render_widget_host_->WasHidden(); 899 render_widget_host_->WasHidden();
898 SuspendBrowserCompositorView(); 900 SuspendBrowserCompositorView();
899 } 901 }
900 902
901 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { 903 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) {
902 gfx::Rect rect = GetViewBounds(); 904 gfx::Rect rect = GetViewBounds();
903 rect.set_size(size); 905 rect.set_size(size);
904 SetBounds(rect); 906 SetBounds(rect);
905 } 907 }
906 908
(...skipping 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3435 3437
3436 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3438 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3437 // regions that are not draggable. (See ControlRegionView in 3439 // regions that are not draggable. (See ControlRegionView in
3438 // native_app_window_cocoa.mm). This requires the render host view to be 3440 // native_app_window_cocoa.mm). This requires the render host view to be
3439 // draggable by default. 3441 // draggable by default.
3440 - (BOOL)mouseDownCanMoveWindow { 3442 - (BOOL)mouseDownCanMoveWindow {
3441 return YES; 3443 return YES;
3442 } 3444 }
3443 3445
3444 @end 3446 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698