| 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 #ifndef UI_GL_SCOPED_MAKE_CURRENT_H_ | 5 #ifndef UI_GL_SCOPED_MAKE_CURRENT_H_ | 
| 6 #define UI_GL_SCOPED_MAKE_CURRENT_H_ | 6 #define UI_GL_SCOPED_MAKE_CURRENT_H_ | 
| 7 | 7 | 
| 8 #include "base/macros.h" | 8 #include "base/macros.h" | 
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" | 
|  | 10 #include "base/optional.h" | 
| 10 #include "ui/gl/gl_export.h" | 11 #include "ui/gl/gl_export.h" | 
| 11 | 12 | 
| 12 namespace gl { | 13 namespace gl { | 
| 13 class GLContext; | 14 class GLContext; | 
| 14 class GLSurface; | 15 class GLSurface; | 
| 15 } | 16 } | 
| 16 | 17 | 
| 17 namespace ui { | 18 namespace ui { | 
| 18 | 19 | 
| 19 class GL_EXPORT ScopedMakeCurrent { | 20 class GL_EXPORT ScopedMakeCurrent { | 
| 20  public: | 21  public: | 
| 21   ScopedMakeCurrent(gl::GLContext* context, gl::GLSurface* surface); | 22   ScopedMakeCurrent(gl::GLContext* context, gl::GLSurface* surface); | 
| 22   ~ScopedMakeCurrent(); | 23   ~ScopedMakeCurrent(); | 
| 23 | 24 | 
| 24   bool Succeeded() const; | 25   bool Succeeded() const; | 
| 25 | 26 | 
| 26  private: | 27  private: | 
| 27   scoped_refptr<gl::GLContext> previous_context_; | 28   scoped_refptr<gl::GLContext> previous_context_; | 
| 28   scoped_refptr<gl::GLSurface> previous_surface_; | 29   scoped_refptr<gl::GLSurface> previous_surface_; | 
| 29   scoped_refptr<gl::GLContext> context_; | 30   scoped_refptr<gl::GLContext> context_; | 
| 30   scoped_refptr<gl::GLSurface> surface_; | 31   scoped_refptr<gl::GLSurface> surface_; | 
| 31   bool succeeded_; | 32   bool succeeded_; | 
| 32 | 33 | 
| 33   DISALLOW_COPY_AND_ASSIGN(ScopedMakeCurrent); | 34   DISALLOW_COPY_AND_ASSIGN(ScopedMakeCurrent); | 
| 34 }; | 35 }; | 
| 35 | 36 | 
|  | 37 // This class is used to make sure a specified surface isn't current, and upon | 
|  | 38 // destruction it will make the surface current again if it had been before. | 
|  | 39 class GL_EXPORT ScopedReleaseCurrent { | 
|  | 40  public: | 
|  | 41   explicit ScopedReleaseCurrent(gl::GLSurface* this_surface); | 
|  | 42 | 
|  | 43   ~ScopedReleaseCurrent(); | 
|  | 44 | 
|  | 45  private: | 
|  | 46   base::Optional<ScopedMakeCurrent> make_current_; | 
|  | 47 | 
|  | 48   DISALLOW_COPY_AND_ASSIGN(ScopedReleaseCurrent); | 
|  | 49 }; | 
|  | 50 | 
| 36 }  // namespace ui | 51 }  // namespace ui | 
| 37 | 52 | 
| 38 #endif  // UI_GL_SCOPED_MAKE_CURRENT_H_ | 53 #endif  // UI_GL_SCOPED_MAKE_CURRENT_H_ | 
| OLD | NEW | 
|---|