summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 19:11:11 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 19:11:11 +0000
commitb359a9bc5f629319610e35010cacef5cc87c8df3 (patch)
tree686d8821443b59a717d709f0eeeefb2e5bf4d9fc
parentbbe9e97ee2779001fd5161cf181c1b77918c9cf1 (diff)
downloadchromium_src-b359a9bc5f629319610e35010cacef5cc87c8df3.zip
chromium_src-b359a9bc5f629319610e35010cacef5cc87c8df3.tar.gz
chromium_src-b359a9bc5f629319610e35010cacef5cc87c8df3.tar.bz2
Merge 246517 "Make sure that each NSWindow has its own GL context"
> Make sure that each NSWindow has its own GL context > > Update the GL context for an NSView before drawing it, in > CreateCompositedIOSurface. > > In the case of the devtools window being added and removed, > the WindowFrameChanged is not called on the devtools window, > and as a result, it and the main window compete for the same > context (which sometimes results in nothing being drawn for > the devtools window). > > BUG=335011 > > Review URL: https://codereview.chromium.org/140693013 TBR=ccameron@chromium.org Review URL: https://codereview.chromium.org/145083014 git-svn-id: svn://svn.chromium.org/chrome/branches/1750/src@246943 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm44
1 files changed, 27 insertions, 17 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 9fd9b03..23a6e3c 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -514,22 +514,37 @@ void RenderWidgetHostViewMac::EnableCoreAnimation() {
}
bool RenderWidgetHostViewMac::CreateCompositedIOSurface() {
- if (compositing_iosurface_context_ && compositing_iosurface_)
+ int current_window_number = window_number();
+ bool new_surface_needed = !compositing_iosurface_;
+ bool new_context_needed =
+ !compositing_iosurface_context_ ||
+ (compositing_iosurface_context_ &&
+ compositing_iosurface_context_->window_number() !=
+ current_window_number);
+
+ if (!new_surface_needed && !new_context_needed)
return true;
ScopedCAActionDisabler disabler;
// Create the GL context and shaders.
- if (!compositing_iosurface_context_) {
- compositing_iosurface_context_ =
- CompositingIOSurfaceContext::Get(window_number());
- if (!compositing_iosurface_context_) {
+ if (new_context_needed) {
+ scoped_refptr<CompositingIOSurfaceContext> new_context =
+ CompositingIOSurfaceContext::Get(current_window_number);
+ // Un-bind the GL context from this view before binding the new GL
+ // context. Having two GL contexts bound to a view will result in
+ // crashes and corruption.
+ // http://crbug.com/230883
+ ClearBoundContextDrawable();
+ if (!new_context) {
LOG(ERROR) << "Failed to create CompositingIOSurfaceContext";
return false;
}
+ compositing_iosurface_context_ = new_context;
}
+
// Create the IOSurface texture.
- if (!compositing_iosurface_) {
+ if (new_surface_needed) {
compositing_iosurface_.reset(CompositingIOSurfaceMac::Create());
if (!compositing_iosurface_) {
LOG(ERROR) << "Failed to create CompositingIOSurface";
@@ -595,6 +610,9 @@ void RenderWidgetHostViewMac::ClearBoundContextDrawable() {
cocoa_view_ &&
[[compositing_iosurface_context_->nsgl_context() view]
isEqual:cocoa_view_]) {
+ // Disable screen updates because removing the GL context from below can
+ // cause flashes.
+ [[cocoa_view_ window] disableScreenUpdatesUntilFlush];
[compositing_iosurface_context_->nsgl_context() clearDrawable];
}
}
@@ -1990,17 +2008,9 @@ void RenderWidgetHostViewMac::WindowFrameChanged() {
GetViewBounds()));
}
- if (compositing_iosurface_ && use_core_animation_) {
- scoped_refptr<CompositingIOSurfaceContext> new_context =
- CompositingIOSurfaceContext::Get(window_number());
- if (new_context) {
- // Un-bind the GL context from this view before binding the new GL
- // context. Having two GL contexts bound to a view will result in
- // crashes and corruption.
- // http://crbug.com/230883
- ClearBoundContextDrawable();
- compositing_iosurface_context_ = new_context;
- }
+ if (compositing_iosurface_) {
+ // This will migrate the context to the appropriate window.
+ CreateCompositedIOSurface();
}
}