OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/gl/gl_surface_cgl.h" | 5 #include "ui/gfx/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/gfx/gl/gl_bindings.h" | 12 #include "ui/gfx/gl/gl_bindings.h" |
13 #include "ui/gfx/gl/gl_context.h" | 13 #include "ui/gfx/gl/gl_context.h" |
14 #include "ui/gfx/gl/gl_implementation.h" | 14 #include "ui/gfx/gl/gl_implementation.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 namespace { | 18 namespace { |
19 CGLPixelFormatObj g_pixel_format; | 19 CGLPixelFormatObj g_pixel_format; |
20 } | 20 } |
21 | 21 |
22 GLSurfaceCGL::GLSurfaceCGL() { | 22 GLSurfaceCGL::GLSurfaceCGL() {} |
23 } | |
24 | |
25 GLSurfaceCGL::~GLSurfaceCGL() { | |
26 } | |
27 | 23 |
28 bool GLSurfaceCGL::InitializeOneOff() { | 24 bool GLSurfaceCGL::InitializeOneOff() { |
29 static bool initialized = false; | 25 static bool initialized = false; |
30 if (initialized) | 26 if (initialized) |
31 return true; | 27 return true; |
32 | 28 |
33 // 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. |
34 // GPU-related stuff is very slow without this, probably because | 30 // GPU-related stuff is very slow without this, probably because |
35 // the sandbox prevents loading graphics drivers or some such. | 31 // the sandbox prevents loading graphics drivers or some such. |
36 std::vector<CGLPixelFormatAttribute> attribs; | 32 std::vector<CGLPixelFormatAttribute> attribs; |
(...skipping 24 matching lines...) Expand all Loading... |
61 CGLReleasePixelFormat(format); | 57 CGLReleasePixelFormat(format); |
62 DCHECK_NE(num_pixel_formats, 0); | 58 DCHECK_NE(num_pixel_formats, 0); |
63 initialized = true; | 59 initialized = true; |
64 return true; | 60 return true; |
65 } | 61 } |
66 | 62 |
67 void* GLSurfaceCGL::GetPixelFormat() { | 63 void* GLSurfaceCGL::GetPixelFormat() { |
68 return g_pixel_format; | 64 return g_pixel_format; |
69 } | 65 } |
70 | 66 |
| 67 GLSurfaceCGL::~GLSurfaceCGL() {} |
| 68 |
71 NoOpGLSurfaceCGL::NoOpGLSurfaceCGL(const gfx::Size& size) | 69 NoOpGLSurfaceCGL::NoOpGLSurfaceCGL(const gfx::Size& size) |
72 : size_(size) { | 70 : size_(size) { |
73 } | 71 } |
74 | 72 |
75 NoOpGLSurfaceCGL::~NoOpGLSurfaceCGL() { | |
76 Destroy(); | |
77 } | |
78 | |
79 bool NoOpGLSurfaceCGL::Initialize() { | 73 bool NoOpGLSurfaceCGL::Initialize() { |
80 return true; | 74 return true; |
81 } | 75 } |
82 | 76 |
83 void NoOpGLSurfaceCGL::Destroy() { | 77 void NoOpGLSurfaceCGL::Destroy() { |
84 } | 78 } |
85 | 79 |
86 bool NoOpGLSurfaceCGL::IsOffscreen() { | 80 bool NoOpGLSurfaceCGL::IsOffscreen() { |
87 return true; | 81 return true; |
88 } | 82 } |
89 | 83 |
90 bool NoOpGLSurfaceCGL::SwapBuffers() { | 84 bool NoOpGLSurfaceCGL::SwapBuffers() { |
91 NOTREACHED() << "Cannot call SwapBuffers on a NoOpGLSurfaceCGL."; | 85 NOTREACHED() << "Cannot call SwapBuffers on a NoOpGLSurfaceCGL."; |
92 return false; | 86 return false; |
93 } | 87 } |
94 | 88 |
95 gfx::Size NoOpGLSurfaceCGL::GetSize() { | 89 gfx::Size NoOpGLSurfaceCGL::GetSize() { |
96 return size_; | 90 return size_; |
97 } | 91 } |
98 | 92 |
99 void* NoOpGLSurfaceCGL::GetHandle() { | 93 void* NoOpGLSurfaceCGL::GetHandle() { |
100 return NULL; | 94 return NULL; |
101 } | 95 } |
102 | 96 |
| 97 NoOpGLSurfaceCGL::~NoOpGLSurfaceCGL() { |
| 98 Destroy(); |
| 99 } |
| 100 |
103 } // namespace gfx | 101 } // namespace gfx |
OLD | NEW |