Chromium Code Reviews| Index: ui/base/cocoa/constrained_window/constrained_window_animation.mm |
| diff --git a/ui/base/cocoa/constrained_window/constrained_window_animation.mm b/ui/base/cocoa/constrained_window/constrained_window_animation.mm |
| index 3618a1b97825fc36365861ab3d3928d170cb3f2b..b691536d0d0e2fe9118fd03c233ee2ffb792617b 100644 |
| --- a/ui/base/cocoa/constrained_window/constrained_window_animation.mm |
| +++ b/ui/base/cocoa/constrained_window/constrained_window_animation.mm |
| @@ -20,18 +20,12 @@ |
| // - Perspective and shear transformations get clipped if they are bigger |
| // than the window size. This does not seem to apply to scale transformations. |
| +// Use of private APIs is dangerous, and is known to cause WindowServer crashes. |
| +// https://bugs.chromium.org/p/chromium/issues/detail?id=515627 |
| + |
| // Length of the animation in seconds. |
| const NSTimeInterval kAnimationDuration = 0.18; |
| -// The number of pixels above the final destination to animate from. |
| -const CGFloat kShowHideVerticalOffset = 20; |
| - |
| -// Scale the window by this factor when animating. |
| -const CGFloat kShowHideScaleFactor = 0.99; |
| - |
| -// Size of the perspective effect as a factor of the window width. |
| -const CGFloat kShowHidePerspectiveFactor = 0.04; |
| - |
| // Forward declare private CoreGraphics APIs used to transform windows. |
| extern "C" { |
| @@ -54,11 +48,6 @@ CGSConnection _CGSDefaultConnection(); |
| CGError CGSSetWindowTransform(const CGSConnection cid, |
|
tapted
2016/03/14 00:03:22
You said CGSSetWindowWarp caused the crashes, but
|
| const CGSWindow wid, |
| CGAffineTransform transform); |
| -CGError CGSSetWindowWarp(const CGSConnection cid, |
| - const CGSWindow wid, |
| - int32_t w, |
| - int32_t h, |
| - CGPointWarp* mesh); |
| CGError CGSSetWindowAlpha(const CGSConnection cid, |
| const CGSWindow wid, |
| float32 alpha); |
| @@ -119,74 +108,11 @@ void SetWindowScale(NSWindow* window, float scale) { |
| CGSSetWindowTransform(cid, [window windowNumber], transform); |
| } |
| -// Unsets any window warp that may have been previously applied. |
| -// Window warp prevents other effects such as CGSSetWindowTransform from |
| -// being applied. |
| -void ClearWindowWarp(NSWindow* window) { |
| - CGSConnection cid = _CGSDefaultConnection(); |
| - CGSSetWindowWarp(cid, [window windowNumber], 0, 0, NULL); |
| -} |
| - |
| -// Applies various transformations using a warp effect. The window is |
| -// translated vertically by |y_offset|. The window is scaled by |scale| and |
| -// translated so that the it remains centered relative to its original position. |
| -// Finally, perspective is effect is applied by shrinking the top of the window. |
| -void SetWindowWarp(NSWindow* window, |
| - float y_offset, |
| - float scale, |
| - float perspective_offset) { |
| - NSRect win_rect = [window frame]; |
| - win_rect.origin = NSZeroPoint; |
| - NSRect screen_rect = win_rect; |
| - screen_rect.origin = GetCGSWindowScreenOrigin(window); |
| - |
| - // Apply a vertical translate. |
| - screen_rect.origin.y -= y_offset; |
| - |
| - // Apply a scale and translate to keep the window centered. |
| - screen_rect.origin.x += (NSWidth(win_rect) - NSWidth(screen_rect)) / 2.0; |
| - screen_rect.origin.y += (NSHeight(win_rect) - NSHeight(screen_rect)) / 2.0; |
| - |
| - // A 2 x 2 mesh that maps each corner of the window to a location in screen |
| - // coordinates. Note that the origin of the coordinate system is top, left. |
| - CGPointWarp mesh[2][2] = { |
| - {{ |
| - // Top left. |
| - {NSMinX(win_rect), NSMinY(win_rect)}, |
| - {NSMinX(screen_rect) + perspective_offset, NSMinY(screen_rect)}, |
| - }, |
| - { |
| - // Top right. |
| - {NSMaxX(win_rect), NSMinY(win_rect)}, |
| - {NSMaxX(screen_rect) - perspective_offset, NSMinY(screen_rect)}, }}, |
| - {{ |
| - // Bottom left. |
| - {NSMinX(win_rect), NSMaxY(win_rect)}, |
| - {NSMinX(screen_rect), NSMaxY(screen_rect)}, |
| - }, |
| - { |
| - // Bottom right. |
| - {NSMaxX(win_rect), NSMaxY(win_rect)}, |
| - {NSMaxX(screen_rect), NSMaxY(screen_rect)}, }}, |
| - }; |
| - |
| - CGSConnection cid = _CGSDefaultConnection(); |
| - CGSSetWindowWarp(cid, [window windowNumber], 2, 2, &(mesh[0][0])); |
| -} |
| - |
| // Sets the various effects that are a part of the Show/Hide animation. |
| // Value is a number between 0 and 1 where 0 means the window is completely |
| // hidden and 1 means the window is fully visible. |
| void UpdateWindowShowHideAnimationState(NSWindow* window, CGFloat value) { |
| - CGFloat inverse_value = 1.0 - value; |
| - |
| SetWindowAlpha(window, value); |
| - CGFloat y_offset = kShowHideVerticalOffset * inverse_value; |
| - CGFloat scale = 1.0 - (1.0 - kShowHideScaleFactor) * inverse_value; |
| - CGFloat perspective_offset = |
| - ([window frame].size.width * kShowHidePerspectiveFactor) * inverse_value; |
| - |
| - SetWindowWarp(window, y_offset, scale, perspective_offset); |
| } |
| } // namespace |
| @@ -255,7 +181,6 @@ void UpdateWindowShowHideAnimationState(NSWindow* window, CGFloat value) { |
| - (void)setWindowStateForEnd { |
| SetWindowAlpha(window_, 1.0); |
| - ClearWindowWarp(window_); |
| } |
| @end |
| @@ -268,7 +193,6 @@ void UpdateWindowShowHideAnimationState(NSWindow* window, CGFloat value) { |
| - (void)setWindowStateForEnd { |
| SetWindowAlpha(window_, 0.0); |
| - ClearWindowWarp(window_); |
| } |
| @end |