OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 5 #ifndef WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
6 #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 6 #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "webkit/common/gpu/context_provider_web_context.h" | 14 #include "cc/output/context_provider.h" |
15 #include "webkit/common/gpu/webkit_gpu_export.h" | 15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
16 #include "skia/ext/refptr.h" | |
17 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | |
18 #include "ui/gfx/native_widget_types.h" | |
16 | 19 |
17 namespace blink { class WebGraphicsContext3D; } | 20 namespace gpu { |
18 | 21 class GLInProcessContext; |
19 namespace gpu_blink { | |
20 class WebGraphicsContext3DInProcessCommandBufferImpl; | |
21 } | 22 } |
22 | 23 |
23 namespace webkit { | |
24 namespace gpu { | |
25 class GrContextForWebGraphicsContext3D; | |
26 | 24 |
27 class WEBKIT_GPU_EXPORT ContextProviderInProcess | 25 namespace ui { |
28 : NON_EXPORTED_BASE(public ContextProviderWebContext) { | 26 |
27 class InProcessContextProvider : public cc::ContextProvider { | |
29 public: | 28 public: |
30 static scoped_refptr<ContextProviderInProcess> Create( | 29 static scoped_refptr<InProcessContextProvider> Create( |
31 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> | 30 const blink::WebGraphicsContext3D::Attributes& attributes, |
piman
2015/01/21 22:37:39
As James mentioned, you can pass in a ContextCreat
tfarina
2015/01/22 00:05:32
Done.
| |
32 context3d, | 31 bool lose_context_when_out_of_memory, |
32 gfx::AcceleratedWidget window, | |
33 const std::string& debug_name); | 33 const std::string& debug_name); |
34 | 34 |
35 // Uses default attributes for creating an offscreen context. | 35 // Uses default attributes for creating an offscreen context. |
36 static scoped_refptr<ContextProviderInProcess> CreateOffscreen( | 36 static scoped_refptr<InProcessContextProvider> CreateOffscreen( |
37 bool lose_context_when_out_of_memory); | 37 bool lose_context_when_out_of_memory); |
38 | 38 |
39 private: | 39 private: |
40 ContextProviderInProcess( | 40 InProcessContextProvider( |
41 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> | 41 const blink::WebGraphicsContext3D::Attributes& attributes, |
42 context3d, | 42 bool lose_context_when_out_of_memory, |
43 gfx::AcceleratedWidget window, | |
43 const std::string& debug_name); | 44 const std::string& debug_name); |
44 ~ContextProviderInProcess() override; | 45 ~InProcessContextProvider() override; |
45 | |
46 // ContextProviderWebContext: | |
47 blink::WebGraphicsContext3D* WebContext3D() override; | |
48 | 46 |
49 // cc::ContextProvider: | 47 // cc::ContextProvider: |
50 bool BindToCurrentThread() override; | 48 bool BindToCurrentThread() override; |
51 Capabilities ContextCapabilities() override; | 49 Capabilities ContextCapabilities() override; |
52 ::gpu::gles2::GLES2Interface* ContextGL() override; | 50 gpu::gles2::GLES2Interface* ContextGL() override; |
53 ::gpu::ContextSupport* ContextSupport() override; | 51 gpu::ContextSupport* ContextSupport() override; |
54 class GrContext* GrContext() override; | 52 class GrContext* GrContext() override; |
55 bool IsContextLost() override; | 53 bool IsContextLost() override; |
56 void VerifyContexts() override; | 54 void VerifyContexts() override; |
57 void DeleteCachedResources() override; | 55 void DeleteCachedResources() override; |
58 bool DestroyedOnMainThread() override; | 56 bool DestroyedOnMainThread() override; |
59 void SetLostContextCallback( | 57 void SetLostContextCallback( |
60 const LostContextCallback& lost_context_callback) override; | 58 const LostContextCallback& lost_context_callback) override; |
61 void SetMemoryPolicyChangedCallback( | 59 void SetMemoryPolicyChangedCallback( |
62 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 60 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
63 override; | 61 override; |
64 | 62 |
65 void OnLostContext(); | 63 void OnLostContext(); |
66 void InitializeCapabilities(); | 64 void InitializeCapabilities(); |
67 | 65 |
68 base::ThreadChecker main_thread_checker_; | 66 base::ThreadChecker main_thread_checker_; |
69 base::ThreadChecker context_thread_checker_; | 67 base::ThreadChecker context_thread_checker_; |
70 | 68 |
71 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> | 69 scoped_ptr<gpu::GLInProcessContext> context_; |
72 context3d_; | 70 skia::RefPtr<class GrContext> gr_context_; |
73 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; | |
74 | 71 |
75 LostContextCallback lost_context_callback_; | 72 gpu::gles2::ContextCreationAttribHelper attributes_; |
73 bool lose_context_when_out_of_memory_; | |
74 bool share_resources_; | |
75 gfx::AcceleratedWidget window_; | |
76 | 76 |
77 base::Lock destroyed_lock_; | 77 base::Lock destroyed_lock_; |
78 bool destroyed_; | 78 bool destroyed_; |
79 | 79 |
80 std::string debug_name_; | 80 std::string debug_name_; |
81 class LostContextCallbackProxy; | |
82 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | |
83 | 81 |
84 cc::ContextProvider::Capabilities capabilities_; | 82 cc::ContextProvider::Capabilities capabilities_; |
85 | 83 |
86 DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); | 84 DISALLOW_COPY_AND_ASSIGN(InProcessContextProvider); |
87 }; | 85 }; |
88 | 86 |
89 } // namespace gpu | 87 } // namespace ui |
90 } // namespace webkit | |
91 | 88 |
92 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 89 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
OLD | NEW |