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/compositing_iosurface_mac.h" | 5 #include "content/browser/renderer_host/compositing_iosurface_mac.h" |
6 | 6 |
7 #include <OpenGL/OpenGL.h> | 7 #include <OpenGL/OpenGL.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return kCVReturnSuccess; | 160 return kCVReturnSuccess; |
161 } | 161 } |
162 | 162 |
163 CompositingIOSurfaceMac::CopyContext::CopyContext() { | 163 CompositingIOSurfaceMac::CopyContext::CopyContext() { |
164 Reset(); | 164 Reset(); |
165 } | 165 } |
166 | 166 |
167 CompositingIOSurfaceMac::CopyContext::~CopyContext() { | 167 CompositingIOSurfaceMac::CopyContext::~CopyContext() { |
168 } | 168 } |
169 | 169 |
170 CompositingIOSurfaceMac* CompositingIOSurfaceMac::Create() { | 170 // static |
| 171 CompositingIOSurfaceMac* CompositingIOSurfaceMac::Create(SurfaceOrder order) { |
171 TRACE_EVENT0("browser", "CompositingIOSurfaceMac::Create"); | 172 TRACE_EVENT0("browser", "CompositingIOSurfaceMac::Create"); |
172 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 173 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
173 if (!io_surface_support) { | 174 if (!io_surface_support) { |
174 LOG(WARNING) << "No IOSurface support"; | 175 LOG(WARNING) << "No IOSurface support"; |
175 return NULL; | 176 return NULL; |
176 } | 177 } |
177 | 178 |
178 std::vector<NSOpenGLPixelFormatAttribute> attributes; | 179 std::vector<NSOpenGLPixelFormatAttribute> attributes; |
179 attributes.push_back(NSOpenGLPFADoubleBuffer); | 180 attributes.push_back(NSOpenGLPFADoubleBuffer); |
180 // We don't need a depth buffer - try setting its size to 0... | 181 // We don't need a depth buffer - try setting its size to 0... |
(...skipping 10 matching lines...) Expand all Loading... |
191 } | 192 } |
192 | 193 |
193 scoped_nsobject<NSOpenGLContext> glContext( | 194 scoped_nsobject<NSOpenGLContext> glContext( |
194 [[NSOpenGLContext alloc] initWithFormat:glPixelFormat | 195 [[NSOpenGLContext alloc] initWithFormat:glPixelFormat |
195 shareContext:nil]); | 196 shareContext:nil]); |
196 if (!glContext) { | 197 if (!glContext) { |
197 LOG(ERROR) << "NSOpenGLContext initWithFormat failed"; | 198 LOG(ERROR) << "NSOpenGLContext initWithFormat failed"; |
198 return NULL; | 199 return NULL; |
199 } | 200 } |
200 | 201 |
201 // We "punch a hole" in the window, and have the WindowServer render the | 202 // If requested, ask the WindowServer to render the OpenGL surface underneath |
202 // OpenGL surface underneath so we can draw over it. | 203 // the window. This, combined with a hole punched in the window, will allow |
203 GLint belowWindow = -1; | 204 // for views to "overlap" the GL surface from the user's point of view. |
204 [glContext setValues:&belowWindow forParameter:NSOpenGLCPSurfaceOrder]; | 205 if (order == SURFACE_ORDER_BELOW_WINDOW) { |
| 206 GLint belowWindow = -1; |
| 207 [glContext setValues:&belowWindow forParameter:NSOpenGLCPSurfaceOrder]; |
| 208 } |
205 | 209 |
206 CGLContextObj cglContext = (CGLContextObj)[glContext CGLContextObj]; | 210 CGLContextObj cglContext = (CGLContextObj)[glContext CGLContextObj]; |
207 if (!cglContext) { | 211 if (!cglContext) { |
208 LOG(ERROR) << "CGLContextObj failed"; | 212 LOG(ERROR) << "CGLContextObj failed"; |
209 return NULL; | 213 return NULL; |
210 } | 214 } |
211 | 215 |
212 // Draw at beam vsync. | 216 // Draw at beam vsync. |
213 bool is_vsync_disabled = | 217 bool is_vsync_disabled = |
214 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync); | 218 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 glDeleteFramebuffersEXT(1, ©_context_.frame_buffer); CHECK_GL_ERROR(); | 874 glDeleteFramebuffersEXT(1, ©_context_.frame_buffer); CHECK_GL_ERROR(); |
871 glDeleteTextures(1, ©_context_.frame_buffer_texture); CHECK_GL_ERROR(); | 875 glDeleteTextures(1, ©_context_.frame_buffer_texture); CHECK_GL_ERROR(); |
872 glDeleteBuffers(1, ©_context_.pixel_buffer); CHECK_GL_ERROR(); | 876 glDeleteBuffers(1, ©_context_.pixel_buffer); CHECK_GL_ERROR(); |
873 if (copy_context_.use_fence) { | 877 if (copy_context_.use_fence) { |
874 glDeleteFencesAPPLE(1, ©_context_.fence); CHECK_GL_ERROR(); | 878 glDeleteFencesAPPLE(1, ©_context_.fence); CHECK_GL_ERROR(); |
875 } | 879 } |
876 copy_context_.Reset(); | 880 copy_context_.Reset(); |
877 } | 881 } |
878 | 882 |
879 } // namespace content | 883 } // namespace content |
OLD | NEW |