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 "ui/gl/gl_context_cgl.h" | 5 #include "ui/gl/gl_context_cgl.h" |
6 | 6 |
7 #include <OpenGL/CGLRenderers.h> | 7 #include <OpenGL/CGLRenderers.h> |
8 #include <OpenGL/CGLTypes.h> | 8 #include <OpenGL/CGLTypes.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 format, | 109 format, |
110 share_context ? | 110 share_context ? |
111 static_cast<CGLContextObj>(share_context->GetHandle()) : NULL, | 111 static_cast<CGLContextObj>(share_context->GetHandle()) : NULL, |
112 reinterpret_cast<CGLContextObj*>(&context_)); | 112 reinterpret_cast<CGLContextObj*>(&context_)); |
113 if (res != kCGLNoError) { | 113 if (res != kCGLNoError) { |
114 LOG(ERROR) << "Error creating context."; | 114 LOG(ERROR) << "Error creating context."; |
115 Destroy(); | 115 Destroy(); |
116 return false; | 116 return false; |
117 } | 117 } |
118 | 118 |
| 119 // For transparent windows. |
| 120 GLint opaque = 0; |
| 121 CGLSetParameter( |
| 122 static_cast<CGLContextObj>(context_), kCGLCPSurfaceOpacity, &opaque); |
| 123 |
119 gpu_preference_ = gpu_preference; | 124 gpu_preference_ = gpu_preference; |
120 return true; | 125 return true; |
121 } | 126 } |
122 | 127 |
123 void GLContextCGL::Destroy() { | 128 void GLContextCGL::Destroy() { |
124 if (discrete_pixelformat_) { | 129 if (discrete_pixelformat_) { |
125 // Delay releasing the pixel format for 10 seconds to reduce the number of | 130 // Delay releasing the pixel format for 10 seconds to reduce the number of |
126 // unnecessary GPU switches. | 131 // unnecessary GPU switches. |
127 base::MessageLoop::current()->PostDelayedTask( | 132 base::MessageLoop::current()->PostDelayedTask( |
128 FROM_HERE, | 133 FROM_HERE, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 301 |
297 GLContextCGL::~GLContextCGL() { | 302 GLContextCGL::~GLContextCGL() { |
298 Destroy(); | 303 Destroy(); |
299 } | 304 } |
300 | 305 |
301 GpuPreference GLContextCGL::GetGpuPreference() { | 306 GpuPreference GLContextCGL::GetGpuPreference() { |
302 return gpu_preference_; | 307 return gpu_preference_; |
303 } | 308 } |
304 | 309 |
305 } // namespace gfx | 310 } // namespace gfx |
OLD | NEW |