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