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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class GLContext { | 22 class GLContext { |
23 public: | 23 public: |
24 class Observer { | 24 class Observer { |
25 public: | 25 public: |
26 virtual void OnContextLost() = 0; | 26 virtual void OnContextLost() = 0; |
27 | 27 |
28 protected: | 28 protected: |
29 virtual ~Observer(); | 29 virtual ~Observer(); |
30 }; | 30 }; |
31 | 31 |
32 static base::WeakPtr<GLContext> Create(mojo::Shell* shell); | 32 static base::WeakPtr<GLContext> Create(Shell* shell); |
33 | 33 |
34 void MakeCurrent(); | 34 void MakeCurrent(); |
35 void Destroy(); | 35 void Destroy(); |
36 | 36 |
37 gpu::gles2::GLES2Interface* gl() const { return gl_; } | 37 gpu::gles2::GLES2Interface* gl() const { return gl_; } |
38 | 38 |
39 void AddObserver(Observer* observer); | 39 void AddObserver(Observer* observer); |
40 void RemoveObserver(Observer* observer); | 40 void RemoveObserver(Observer* observer); |
41 | 41 |
42 private: | 42 private: |
43 explicit GLContext(mojo::Shell* shell); | 43 explicit GLContext(Shell* shell); |
44 ~GLContext(); | 44 ~GLContext(); |
45 | 45 |
46 static void ContextLostThunk(void* self); | 46 static void ContextLostThunk(void* self); |
47 void OnContextLost(); | 47 void OnContextLost(); |
48 | 48 |
49 MojoGLES2Context context_; | 49 MojoGLES2Context context_; |
50 gpu::gles2::GLES2Interface* gl_; | 50 gpu::gles2::GLES2Interface* gl_; |
51 | 51 |
52 ObserverList<Observer> observers_; | 52 ObserverList<Observer> observers_; |
53 base::WeakPtrFactory<GLContext> weak_factory_; | 53 base::WeakPtrFactory<GLContext> weak_factory_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(GLContext); | 55 DISALLOW_COPY_AND_ASSIGN(GLContext); |
56 }; | 56 }; |
57 | 57 |
58 } // namespace mojo | 58 } // namespace mojo |
59 | 59 |
60 #endif // MOJO_GPU_GL_CONTEXT_H_ | 60 #endif // MOJO_GPU_GL_CONTEXT_H_ |
OLD | NEW |