OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_GL_SCOPED_CGL_H_ | 5 #ifndef UI_GL_SCOPED_CGL_H_ |
6 #define UI_GL_SCOPED_CGL_H_ | 6 #define UI_GL_SCOPED_CGL_H_ |
7 | 7 |
8 #include <OpenGL/OpenGL.h> | 8 #include <OpenGL/OpenGL.h> |
9 | 9 |
10 #include "base/mac/scoped_typeref.h" | 10 #include "base/mac/scoped_typeref.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 static CGLPixelFormatObj Retain(CGLPixelFormatObj object) { | 30 static CGLPixelFormatObj Retain(CGLPixelFormatObj object) { |
31 return CGLRetainPixelFormat(object); | 31 return CGLRetainPixelFormat(object); |
32 } | 32 } |
33 static void Release(CGLPixelFormatObj object) { | 33 static void Release(CGLPixelFormatObj object) { |
34 CGLReleasePixelFormat(object); | 34 CGLReleasePixelFormat(object); |
35 } | 35 } |
36 }; | 36 }; |
37 | 37 |
38 } // namespace base | 38 } // namespace base |
39 | 39 |
40 namespace gfx { | 40 namespace gl { |
41 | 41 |
42 class GL_EXPORT ScopedCGLSetCurrentContext { | 42 class GL_EXPORT ScopedCGLSetCurrentContext { |
43 public: | 43 public: |
44 explicit ScopedCGLSetCurrentContext(CGLContextObj context); | 44 explicit ScopedCGLSetCurrentContext(CGLContextObj context); |
45 ~ScopedCGLSetCurrentContext(); | 45 ~ScopedCGLSetCurrentContext(); |
46 private: | 46 private: |
47 // Note that if a context is destroyed when it is current, then the current | 47 // Note that if a context is destroyed when it is current, then the current |
48 // context is changed to NULL. Take out a reference on |previous_context_| to | 48 // context is changed to NULL. Take out a reference on |previous_context_| to |
49 // preserve this behavior (when this falls out of scope, |previous_context_| | 49 // preserve this behavior (when this falls out of scope, |previous_context_| |
50 // will be made current, then released, so NULL will be current if that | 50 // will be made current, then released, so NULL will be current if that |
51 // release destroys the context). | 51 // release destroys the context). |
52 base::ScopedTypeRef<CGLContextObj> previous_context_; | 52 base::ScopedTypeRef<CGLContextObj> previous_context_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(ScopedCGLSetCurrentContext); | 54 DISALLOW_COPY_AND_ASSIGN(ScopedCGLSetCurrentContext); |
55 }; | 55 }; |
56 | 56 |
57 } // namespace gfx | 57 } // namespace gl |
58 | 58 |
59 #endif // UI_GL_SCOPED_CGL_H_ | 59 #endif // UI_GL_SCOPED_CGL_H_ |
OLD | NEW |