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 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 width, | 942 width, |
943 height, | 943 height, |
944 transport_dib); | 944 transport_dib); |
945 } | 945 } |
946 | 946 |
947 void RenderWidgetHostViewMac::CompositorSwapBuffers(uint64 surface_handle, | 947 void RenderWidgetHostViewMac::CompositorSwapBuffers(uint64 surface_handle, |
948 int32 route_id, | 948 int32 route_id, |
949 int32 gpu_host_id) { | 949 int32 gpu_host_id) { |
950 pending_swap_buffers_acks_.push_back(std::make_pair(route_id, gpu_host_id)); | 950 pending_swap_buffers_acks_.push_back(std::make_pair(route_id, gpu_host_id)); |
951 if (!compositing_iosurface_.get() && !is_hidden_) { | 951 if (!compositing_iosurface_.get() && !is_hidden_) { |
952 [cocoa_view_ addedGLContext]; | |
953 compositing_iosurface_.reset(CompositingIOSurfaceMac::Create()); | 952 compositing_iosurface_.reset(CompositingIOSurfaceMac::Create()); |
954 } | 953 } |
955 | 954 |
956 if (compositing_iosurface_.get() && !is_hidden_) { | 955 if (compositing_iosurface_.get() && !is_hidden_) { |
957 last_frame_was_accelerated_ = true; | 956 last_frame_was_accelerated_ = true; |
958 compositing_iosurface_->SetIOSurface(surface_handle); | 957 compositing_iosurface_->SetIOSurface(surface_handle); |
959 [cocoa_view_ setNeedsDisplay:YES]; | 958 [cocoa_view_ setNeedsDisplay:YES]; |
960 } else { | 959 } else { |
961 AckPendingCompositorSwapBuffers(); | 960 AckPendingCompositorSwapBuffers(); |
962 } | 961 } |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 if (self) { | 1213 if (self) { |
1215 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper); | 1214 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper); |
1216 editCommand_helper_->AddEditingSelectorsToClass([self class]); | 1215 editCommand_helper_->AddEditingSelectorsToClass([self class]); |
1217 | 1216 |
1218 renderWidgetHostView_.reset(r); | 1217 renderWidgetHostView_.reset(r); |
1219 canBeKeyView_ = YES; | 1218 canBeKeyView_ = YES; |
1220 focusedPluginIdentifier_ = -1; | 1219 focusedPluginIdentifier_ = -1; |
1221 | 1220 |
1222 // OpenGL support: | 1221 // OpenGL support: |
1223 handlingGlobalFrameDidChange_ = NO; | 1222 handlingGlobalFrameDidChange_ = NO; |
1224 hasGLContext_ = NO; | |
1225 [[NSNotificationCenter defaultCenter] | 1223 [[NSNotificationCenter defaultCenter] |
1226 addObserver:self | 1224 addObserver:self |
1227 selector:@selector(globalFrameDidChange:) | 1225 selector:@selector(globalFrameDidChange:) |
1228 name:NSViewGlobalFrameDidChangeNotification | 1226 name:NSViewGlobalFrameDidChangeNotification |
1229 object:self]; | 1227 object:self]; |
1230 } | 1228 } |
1231 return self; | 1229 return self; |
1232 } | 1230 } |
1233 | 1231 |
1234 - (void)dealloc { | 1232 - (void)dealloc { |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 for (NSView* subview in [self subviews]) { | 1749 for (NSView* subview in [self subviews]) { |
1752 if (![subview isKindOfClass:[RenderWidgetHostViewCocoa class]]) | 1750 if (![subview isKindOfClass:[RenderWidgetHostViewCocoa class]]) |
1753 continue; // Skip plugin views. | 1751 continue; // Skip plugin views. |
1754 | 1752 |
1755 [static_cast<RenderWidgetHostViewCocoa*>(subview) | 1753 [static_cast<RenderWidgetHostViewCocoa*>(subview) |
1756 renderWidgetHostViewMac]->KillSelf(); | 1754 renderWidgetHostViewMac]->KillSelf(); |
1757 } | 1755 } |
1758 } | 1756 } |
1759 } | 1757 } |
1760 | 1758 |
1761 // OpenGL support | |
1762 - (void)addedGLContext { | |
1763 hasGLContext_ = YES; | |
1764 if (![self isHiddenOrHasHiddenAncestor]) { | |
1765 // Intentionally leak underlaySurface count so that the window never changes | |
1766 // back to opaque. This is to prevent black/transparent flashing that | |
1767 // appears during tab switching otherwise. | |
1768 // TODO(jbates) Remove the underlaySurfaceAdded feature completely from | |
1769 // ChromeBrowserWindow when the subtle gray line corner bug is fixed. Then | |
1770 // the window can be permanently set to non-opaque. crbug.com/56154 | |
1771 if ([[self window] respondsToSelector:@selector(underlaySurfaceAdded)]) | |
1772 [static_cast<id>([self window]) underlaySurfaceAdded]; | |
1773 } | |
1774 } | |
1775 | |
1776 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { | 1759 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { |
1777 if (![self isHiddenOrHasHiddenAncestor]) { | |
1778 // Intentionally leak underlaySurface count (see comment in addedGLContext). | |
1779 if (hasGLContext_ && | |
1780 [newWindow respondsToSelector:@selector(underlaySurfaceAdded)]) | |
1781 [static_cast<id>(newWindow) underlaySurfaceAdded]; | |
1782 } | |
1783 | |
1784 // We're messing with the window, so do this to ensure no flashes. This one | 1760 // We're messing with the window, so do this to ensure no flashes. This one |
1785 // prevents a flash when the current tab is closed. | 1761 // prevents a flash when the current tab is closed. |
1786 [[self window] disableScreenUpdatesUntilFlush]; | 1762 [[self window] disableScreenUpdatesUntilFlush]; |
1787 } | 1763 } |
1788 | 1764 |
1789 - (void) globalFrameDidChange:(NSNotification*)notification { | 1765 - (void)globalFrameDidChange:(NSNotification*)notification { |
1790 if (handlingGlobalFrameDidChange_) | 1766 if (handlingGlobalFrameDidChange_) |
1791 return; | 1767 return; |
1792 | 1768 |
1793 handlingGlobalFrameDidChange_ = YES; | 1769 handlingGlobalFrameDidChange_ = YES; |
1794 if (renderWidgetHostView_->compositing_iosurface_.get()) | 1770 if (renderWidgetHostView_->compositing_iosurface_.get()) |
1795 renderWidgetHostView_->compositing_iosurface_->GlobalFrameDidChange(); | 1771 renderWidgetHostView_->compositing_iosurface_->GlobalFrameDidChange(); |
1796 handlingGlobalFrameDidChange_ = NO; | 1772 handlingGlobalFrameDidChange_ = NO; |
1797 } | 1773 } |
1798 | 1774 |
1799 - (void)setFrameSize:(NSSize)newSize { | 1775 - (void)setFrameSize:(NSSize)newSize { |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2872 if (!string) return NO; | 2848 if (!string) return NO; |
2873 | 2849 |
2874 // If the user is currently using an IME, confirm the IME input, | 2850 // If the user is currently using an IME, confirm the IME input, |
2875 // and then insert the text from the service, the same as TextEdit and Safari. | 2851 // and then insert the text from the service, the same as TextEdit and Safari. |
2876 [self confirmComposition]; | 2852 [self confirmComposition]; |
2877 [self insertText:string]; | 2853 [self insertText:string]; |
2878 return YES; | 2854 return YES; |
2879 } | 2855 } |
2880 | 2856 |
2881 @end | 2857 @end |
OLD | NEW |