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

Side by Side Diff: ui/base/cocoa/underlay_opengl_hosting_window.mm

Issue 10825302: mac: Remove more 10.5-only code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweak comments Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/video_frame_capturer_unittest.cc ('k') | webkit/plugins/npapi/plugin_host.cc » ('j') | 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 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" 5 #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // not do this. Use kWindowSizeDeterminedLater in 97 // not do this. Use kWindowSizeDeterminedLater in
98 // ui/base/cocoa/window_size_constants.h instead. 98 // ui/base/cocoa/window_size_constants.h instead.
99 // 99 //
100 // (This is checked here because UnderlayOpenGLHostingWindow is the base of 100 // (This is checked here because UnderlayOpenGLHostingWindow is the base of
101 // most Chromium windows, not because this is related to its functionality.) 101 // most Chromium windows, not because this is related to its functionality.)
102 DCHECK(!NSIsEmptyRect(contentRect)); 102 DCHECK(!NSIsEmptyRect(contentRect));
103 if ((self = [super initWithContentRect:contentRect 103 if ((self = [super initWithContentRect:contentRect
104 styleMask:windowStyle 104 styleMask:windowStyle
105 backing:bufferingType 105 backing:bufferingType
106 defer:deferCreation])) { 106 defer:deferCreation])) {
107 if (base::mac::IsOSSnowLeopardOrLater()) { 107 // OpenGL-accelerated content works by punching holes in windows. Therefore
108 // Hole punching is used when IOSurfaces are used to transport, which is 108 // all windows hosting OpenGL content must not be opaque.
109 // only on > 10.5. Therefore, on > 10.5, the window must always be 109 [self setOpaque:NO];
110 // non-opaque whether or not it's titled if we want hole punching to work.
111 [self setOpaque:NO];
112 110
113 if (windowStyle & NSTitledWindowMask) { 111 if (windowStyle & NSTitledWindowMask) {
114 // Only fiddle with shadows if the window is a proper window with a 112 // Only fiddle with shadows if the window is a proper window with a
115 // title bar and all. (The invisible opaque area technique only works on 113 // title bar and all.
116 // > 10.5, but that is guaranteed by this point.) 114 [self _setContentHasShadow:NO];
117 [self _setContentHasShadow:NO];
118 115
119 NSView* rootView = [[self contentView] superview]; 116 NSView* rootView = [[self contentView] superview];
120 const NSRect rootBounds = [rootView bounds]; 117 const NSRect rootBounds = [rootView bounds];
121 118
122 // On 10.7/8, the bottom corners of the window are rounded by magic at a 119 // On 10.7/8, the bottom corners of the window are rounded by magic at a
123 // deeper level than the NSThemeFrame, so it is OK to have the opaques 120 // deeper level than the NSThemeFrame, so it is OK to have the opaques
124 // go all the way to the bottom. 121 // go all the way to the bottom.
125 const CGFloat kTopEdgeInset = 16; 122 const CGFloat kTopEdgeInset = 16;
126 const CGFloat kAlphaValueJustOpaqueEnough = 0.002; 123 const CGFloat kAlphaValueJustOpaqueEnough = 0.002;
127 124
128 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame: 125 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame:
129 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds), 126 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds),
130 1, NSHeight(rootBounds) - kTopEdgeInset)]); 127 1, NSHeight(rootBounds) - kTopEdgeInset)]);
131 [leftOpaque setAutoresizingMask:NSViewMaxXMargin | 128 [leftOpaque setAutoresizingMask:NSViewMaxXMargin |
132 NSViewHeightSizable]; 129 NSViewHeightSizable];
133 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; 130 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough];
134 [rootView addSubview:leftOpaque]; 131 [rootView addSubview:leftOpaque];
135 132
136 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame: 133 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame:
137 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds), 134 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds),
138 1, NSHeight(rootBounds) - kTopEdgeInset)]); 135 1, NSHeight(rootBounds) - kTopEdgeInset)]);
139 [rightOpaque setAutoresizingMask:NSViewMinXMargin | 136 [rightOpaque setAutoresizingMask:NSViewMinXMargin |
140 NSViewHeightSizable]; 137 NSViewHeightSizable];
141 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; 138 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough];
142 [rootView addSubview:rightOpaque]; 139 [rootView addSubview:rightOpaque];
143 }
144 } 140 }
145 } 141 }
146 142
147 return self; 143 return self;
148 } 144 }
149 145
150 @end 146 @end
OLDNEW
« no previous file with comments | « remoting/host/video_frame_capturer_unittest.cc ('k') | webkit/plugins/npapi/plugin_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698