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_CC_CONTEXT_PROVIDER_MOJO_H_ | 5 #ifndef SERVICES_SURFACES_CONTEXT_PROVIDER_MOJO_H_ |
6 #define MOJO_CC_CONTEXT_PROVIDER_MOJO_H_ | 6 #define SERVICES_SURFACES_CONTEXT_PROVIDER_MOJO_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
11 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
12 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h" | 11 #include "mojo/public/c/gles2/gles2.h" |
13 #include "third_party/mojo/src/mojo/public/cpp/system/core.h" | 12 #include "mojo/public/cpp/system/core.h" |
14 | 13 |
15 namespace mojo { | 14 namespace mojo { |
16 | 15 |
17 class ContextProviderMojo : public cc::ContextProvider { | 16 class ContextProviderMojo : public cc::ContextProvider { |
18 public: | 17 public: |
19 explicit ContextProviderMojo(ScopedMessagePipeHandle command_buffer_handle); | 18 explicit ContextProviderMojo(ScopedMessagePipeHandle command_buffer_handle); |
20 | 19 |
21 // cc::ContextProvider implementation. | 20 // cc::ContextProvider implementation. |
22 bool BindToCurrentThread() override; | 21 bool BindToCurrentThread() override; |
23 gpu::gles2::GLES2Interface* ContextGL() override; | 22 gpu::gles2::GLES2Interface* ContextGL() override; |
24 gpu::ContextSupport* ContextSupport() override; | 23 gpu::ContextSupport* ContextSupport() override; |
25 class GrContext* GrContext() override; | 24 class GrContext* GrContext() override; |
26 void SetupLock() override; | |
27 base::Lock* GetLock() override; | |
28 Capabilities ContextCapabilities() override; | 25 Capabilities ContextCapabilities() override; |
29 bool IsContextLost() override; | 26 bool IsContextLost() override; |
30 void VerifyContexts() override {} | 27 void VerifyContexts() override {} |
31 void DeleteCachedResources() override {} | 28 void DeleteCachedResources() override {} |
32 bool DestroyedOnMainThread() override; | 29 bool DestroyedOnMainThread() override; |
33 void SetLostContextCallback( | 30 void SetLostContextCallback( |
34 const LostContextCallback& lost_context_callback) override {} | 31 const LostContextCallback& lost_context_callback) override; |
35 void SetMemoryPolicyChangedCallback( | 32 void SetMemoryPolicyChangedCallback( |
36 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 33 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
37 override {} | 34 override {} |
| 35 void SetupLock() override; |
| 36 base::Lock* GetLock() override; |
38 | 37 |
39 protected: | 38 protected: |
40 friend class base::RefCountedThreadSafe<ContextProviderMojo>; | 39 friend class base::RefCountedThreadSafe<ContextProviderMojo>; |
41 ~ContextProviderMojo() override; | 40 ~ContextProviderMojo() override; |
42 | 41 |
43 private: | 42 private: |
44 static void ContextLostThunk(void* closure) { | 43 static void ContextLostThunk(void* closure) { |
45 static_cast<ContextProviderMojo*>(closure)->ContextLost(); | 44 static_cast<ContextProviderMojo*>(closure)->ContextLost(); |
46 } | 45 } |
47 void ContextLost(); | 46 void ContextLost(); |
48 | 47 |
49 cc::ContextProvider::Capabilities capabilities_; | 48 cc::ContextProvider::Capabilities capabilities_; |
50 ScopedMessagePipeHandle command_buffer_handle_; | 49 ScopedMessagePipeHandle command_buffer_handle_; |
51 MojoGLES2Context context_; | 50 MojoGLES2Context context_; |
52 scoped_ptr<gpu::gles2::GLES2Interface> context_gl_; | |
53 bool context_lost_; | 51 bool context_lost_; |
| 52 LostContextCallback lost_context_callback_; |
54 | 53 |
55 base::Lock context_lock_; | 54 base::Lock context_lock_; |
56 | 55 |
57 DISALLOW_COPY_AND_ASSIGN(ContextProviderMojo); | 56 DISALLOW_COPY_AND_ASSIGN(ContextProviderMojo); |
58 }; | 57 }; |
59 | 58 |
60 } // namespace mojo | 59 } // namespace mojo |
61 | 60 |
62 #endif // MOJO_CC_CONTEXT_PROVIDER_MOJO_H_ | 61 #endif // SERVICES_SURFACES_CONTEXT_PROVIDER_MOJO_H_ |
OLD | NEW |