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