| 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_surface_cgl.h" | 5 #include "ui/gl/gl_surface_cgl.h" |
| 6 | 6 |
| 7 #include <OpenGL/CGLRenderers.h> | 7 #include <OpenGL/CGLRenderers.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #include "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
| 13 #include "ui/gl/gl_context.h" | 13 #include "ui/gl/gl_context.h" |
| 14 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
| 15 #include "ui/gl/gpu_switching_manager.h" | 15 #include "ui/gl/gpu_switching_manager.h" |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 CGLPixelFormatObj g_pixel_format; | 20 CGLPixelFormatObj g_pixel_format; |
| 21 } | 21 } |
| 22 | 22 |
| 23 GLSurfaceCGL::GLSurfaceCGL() {} | 23 // static |
| 24 | |
| 25 bool GLSurfaceCGL::InitializeOneOff() { | 24 bool GLSurfaceCGL::InitializeOneOff() { |
| 26 static bool initialized = false; | 25 static bool initialized = false; |
| 27 if (initialized) | 26 if (initialized) |
| 28 return true; | 27 return true; |
| 29 | 28 |
| 30 // This is called from the sandbox warmup code on Mac OS X. | 29 // This is called from the sandbox warmup code on Mac OS X. |
| 31 // GPU-related stuff is very slow without this, probably because | 30 // GPU-related stuff is very slow without this, probably because |
| 32 // the sandbox prevents loading graphics drivers or some such. | 31 // the sandbox prevents loading graphics drivers or some such. |
| 33 std::vector<CGLPixelFormatAttribute> attribs; | 32 std::vector<CGLPixelFormatAttribute> attribs; |
| 34 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { | 33 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 if (!format) { | 53 if (!format) { |
| 55 LOG(ERROR) << "format == 0."; | 54 LOG(ERROR) << "format == 0."; |
| 56 return false; | 55 return false; |
| 57 } | 56 } |
| 58 CGLReleasePixelFormat(format); | 57 CGLReleasePixelFormat(format); |
| 59 DCHECK_NE(num_pixel_formats, 0); | 58 DCHECK_NE(num_pixel_formats, 0); |
| 60 initialized = true; | 59 initialized = true; |
| 61 return true; | 60 return true; |
| 62 } | 61 } |
| 63 | 62 |
| 63 // static |
| 64 void* GLSurfaceCGL::GetPixelFormat() { | 64 void* GLSurfaceCGL::GetPixelFormat() { |
| 65 return g_pixel_format; | 65 return g_pixel_format; |
| 66 } | 66 } |
| 67 | 67 |
| 68 GLSurfaceCGL::~GLSurfaceCGL() {} | |
| 69 | |
| 70 NoOpGLSurfaceCGL::NoOpGLSurfaceCGL(const gfx::Size& size) | 68 NoOpGLSurfaceCGL::NoOpGLSurfaceCGL(const gfx::Size& size) |
| 71 : size_(size) { | 69 : size_(size) { |
| 72 } | 70 } |
| 73 | 71 |
| 74 bool NoOpGLSurfaceCGL::Initialize() { | 72 bool NoOpGLSurfaceCGL::Initialize() { |
| 75 return true; | 73 return true; |
| 76 } | 74 } |
| 77 | 75 |
| 78 void NoOpGLSurfaceCGL::Destroy() { | 76 void NoOpGLSurfaceCGL::Destroy() { |
| 79 } | 77 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 97 | 95 |
| 98 void* NoOpGLSurfaceCGL::GetDisplay() { | 96 void* NoOpGLSurfaceCGL::GetDisplay() { |
| 99 return NULL; | 97 return NULL; |
| 100 } | 98 } |
| 101 | 99 |
| 102 NoOpGLSurfaceCGL::~NoOpGLSurfaceCGL() { | 100 NoOpGLSurfaceCGL::~NoOpGLSurfaceCGL() { |
| 103 Destroy(); | 101 Destroy(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 } // namespace gfx | 104 } // namespace gfx |
| OLD | NEW |