| 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 MOJO_GPU_GL_CONTEXT_H_ | 5 #ifndef MOJO_GPU_GL_CONTEXT_H_ |
| 6 #define MOJO_GPU_GL_CONTEXT_H_ | 6 #define MOJO_GPU_GL_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "mojo/public/c/gles2/gles2.h" | 11 #include "mojo/public/c/gles2/gles2.h" |
| 12 | 12 |
| 13 namespace gpu { | 13 namespace gpu { |
| 14 namespace gles2 { | 14 namespace gles2 { |
| 15 class GLES2Interface; | 15 class GLES2Interface; |
| 16 } | 16 } |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 class MojoGLES2Impl; |
| 20 class Shell; | 21 class Shell; |
| 21 | 22 |
| 22 class GLContext { | 23 class GLContext { |
| 23 public: | 24 public: |
| 24 class Observer { | 25 class Observer { |
| 25 public: | 26 public: |
| 26 virtual void OnContextLost() = 0; | 27 virtual void OnContextLost() = 0; |
| 27 | 28 |
| 28 protected: | 29 protected: |
| 29 virtual ~Observer(); | 30 virtual ~Observer(); |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 static base::WeakPtr<GLContext> Create(Shell* shell); | 33 static base::WeakPtr<GLContext> Create(Shell* shell); |
| 33 | 34 |
| 34 void MakeCurrent(); | 35 void MakeCurrent(); |
| 35 void Destroy(); | 36 void Destroy(); |
| 36 | 37 |
| 37 gpu::gles2::GLES2Interface* gl() const { return gl_; } | 38 gpu::gles2::GLES2Interface* gl() const; |
| 38 | 39 |
| 39 void AddObserver(Observer* observer); | 40 void AddObserver(Observer* observer); |
| 40 void RemoveObserver(Observer* observer); | 41 void RemoveObserver(Observer* observer); |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 explicit GLContext(Shell* shell); | 44 explicit GLContext(Shell* shell); |
| 44 ~GLContext(); | 45 ~GLContext(); |
| 45 | 46 |
| 46 static void ContextLostThunk(void* self); | 47 static void ContextLostThunk(void* self); |
| 47 void OnContextLost(); | 48 void OnContextLost(); |
| 48 | 49 |
| 49 MojoGLES2Context context_; | 50 MojoGLES2Context context_; |
| 50 gpu::gles2::GLES2Interface* gl_; | 51 scoped_ptr<MojoGLES2Impl> gl_impl_; |
| 51 | 52 |
| 52 base::ObserverList<Observer> observers_; | 53 base::ObserverList<Observer> observers_; |
| 53 base::WeakPtrFactory<GLContext> weak_factory_; | 54 base::WeakPtrFactory<GLContext> weak_factory_; |
| 54 | 55 |
| 55 DISALLOW_COPY_AND_ASSIGN(GLContext); | 56 DISALLOW_COPY_AND_ASSIGN(GLContext); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 } // namespace mojo | 59 } // namespace mojo |
| 59 | 60 |
| 60 #endif // MOJO_GPU_GL_CONTEXT_H_ | 61 #endif // MOJO_GPU_GL_CONTEXT_H_ |
| OLD | NEW |