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

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

Issue 279523003: CoreAnimation: Ensure frames are acked when tab capture is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <QuartzCore/QuartzCore.h> 8 #include <QuartzCore/QuartzCore.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 101 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
102 @interface NSView (NSOpenGLSurfaceResolutionLionAPI) 102 @interface NSView (NSOpenGLSurfaceResolutionLionAPI)
103 - (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; 103 - (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag;
104 @end 104 @end
105 105
106 static NSString* const NSWindowDidChangeBackingPropertiesNotification = 106 static NSString* const NSWindowDidChangeBackingPropertiesNotification =
107 @"NSWindowDidChangeBackingPropertiesNotification"; 107 @"NSWindowDidChangeBackingPropertiesNotification";
108 108
109 #endif // 10.7 109 #endif // 10.7
110 110
111 // Declare things that are part of the 10.9 SDK.
112 #if !defined(MAC_OS_X_VERSION_10_9) || \
113 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
114 enum {
115 NSWindowOcclusionStateVisible = 1UL << 1,
116 };
117 typedef NSUInteger NSWindowOcclusionState;
118
119 @interface NSWindow (MavericksAPI)
120 - (NSWindowOcclusionState)occlusionState;
121 @end
122
123 #endif // 10.9
124
111 // This method will return YES for OS X versions 10.7.3 and later, and NO 125 // This method will return YES for OS X versions 10.7.3 and later, and NO
112 // otherwise. 126 // otherwise.
113 // Used to prevent a crash when building with the 10.7 SDK and accessing the 127 // Used to prevent a crash when building with the 10.7 SDK and accessing the
114 // notification below. See: http://crbug.com/260595. 128 // notification below. See: http://crbug.com/260595.
115 static BOOL SupportsBackingPropertiesChangedNotification() { 129 static BOOL SupportsBackingPropertiesChangedNotification() {
116 // windowDidChangeBackingProperties: method has been added to the 130 // windowDidChangeBackingProperties: method has been added to the
117 // NSWindowDelegate protocol in 10.7.3, at the same time as the 131 // NSWindowDelegate protocol in 10.7.3, at the same time as the
118 // NSWindowDidChangeBackingPropertiesNotification notification was added. 132 // NSWindowDidChangeBackingPropertiesNotification notification was added.
119 // If the protocol contains this method description, the notification should 133 // If the protocol contains this method description, the notification should
120 // be supported as well. 134 // be supported as well.
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 std::string value = 1440 std::string value =
1427 base::StringPrintf("window %s delegate %s controller %s", 1441 base::StringPrintf("window %s delegate %s controller %s",
1428 object_getClassName(window), 1442 object_getClassName(window),
1429 object_getClassName([window delegate]), 1443 object_getClassName([window delegate]),
1430 object_getClassName([window windowController])); 1444 object_getClassName([window windowController]));
1431 base::debug::SetCrashKeyValue(kCrashKey, value); 1445 base::debug::SetCrashKeyValue(kCrashKey, value);
1432 } 1446 }
1433 return; 1447 return;
1434 } 1448 }
1435 1449
1450 // If the window is occluded, then this frame's display call may be severely
1451 // throttled. This is a good thing, unless tab capture may be active,
1452 // because the broadcast will be inappropriately throttled.
1453 // http://crbug.com/350410
1454 NSWindow* window = [cocoa_view_ window];
1455 if (window && [window respondsToSelector:@selector(occlusionState)]) {
1456 bool window_is_occluded =
1457 !([window occlusionState] & NSWindowOcclusionStateVisible);
1458 // Note that we aggressively ack even if this particular frame is not being
1459 // captured.
1460 if (window_is_occluded && frame_subscriber_)
1461 scoped_ack.Reset();
1462 }
1463
1436 // If we reach here, then the frame will be displayed by a future draw 1464 // If we reach here, then the frame will be displayed by a future draw
1437 // call, so don't make the callback. 1465 // call, so don't make the callback.
1438 ignore_result(scoped_ack.Release()); 1466 ignore_result(scoped_ack.Release());
1439 if (use_core_animation_) { 1467 if (use_core_animation_) {
1440 DCHECK(compositing_iosurface_layer_); 1468 DCHECK(compositing_iosurface_layer_);
1441 compositing_iosurface_layer_async_timer_.Reset(); 1469 compositing_iosurface_layer_async_timer_.Reset();
1442 [compositing_iosurface_layer_ gotNewFrame]; 1470 [compositing_iosurface_layer_ gotNewFrame];
1443 } else { 1471 } else {
1444 gfx::ScopedCGLSetCurrentContext scoped_set_current_context( 1472 gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
1445 compositing_iosurface_context_->cgl_context()); 1473 compositing_iosurface_context_->cgl_context());
(...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after
4279 } 4307 }
4280 4308
4281 - (void)disableRendering { 4309 - (void)disableRendering {
4282 // Disable the fade-out animation as the layer is removed. 4310 // Disable the fade-out animation as the layer is removed.
4283 ScopedCAActionDisabler disabler; 4311 ScopedCAActionDisabler disabler;
4284 [self removeFromSuperlayer]; 4312 [self removeFromSuperlayer];
4285 renderWidgetHostView_ = nil; 4313 renderWidgetHostView_ = nil;
4286 } 4314 }
4287 4315
4288 @end // implementation SoftwareLayer 4316 @end // implementation SoftwareLayer
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698