OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 ANDROID_WEBVIEW_BROWSER_CONTEXT_PROVIDER_IN_PROCESS_H_ |
6 #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_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 "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 15 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
16 #include "skia/ext/refptr.h" | 16 #include "skia/ext/refptr.h" |
17 #include "ui/gfx/native_widget_types.h" | 17 |
18 namespace gfx { | |
19 class GLSurface; | |
20 } | |
18 | 21 |
19 namespace gpu { | 22 namespace gpu { |
20 class GLInProcessContext; | 23 class GLInProcessContext; |
21 } | 24 } |
22 | 25 |
23 namespace ui { | 26 namespace android_webview { |
24 | 27 |
25 class InProcessContextProvider : public cc::ContextProvider { | 28 class ContextProviderInProcess : public cc::ContextProvider { |
boliu
2015/04/20 10:06:05
Call this a different name to avoid confusion, may
tfarina
2015/04/22 02:09:04
Done.
| |
26 public: | 29 public: |
27 static scoped_refptr<InProcessContextProvider> Create( | 30 static scoped_refptr<ContextProviderInProcess> Create( |
28 const gpu::gles2::ContextCreationAttribHelper& attribs, | 31 scoped_refptr<gfx::GLSurface> surface, |
29 bool lose_context_when_out_of_memory, | 32 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
30 gfx::AcceleratedWidget window, | |
31 const std::string& debug_name); | 33 const std::string& debug_name); |
32 | 34 |
33 // Uses default attributes for creating an offscreen context. | |
34 static scoped_refptr<InProcessContextProvider> CreateOffscreen( | |
35 bool lose_context_when_out_of_memory); | |
36 | |
37 private: | 35 private: |
38 InProcessContextProvider( | 36 ContextProviderInProcess( |
39 const gpu::gles2::ContextCreationAttribHelper& attribs, | 37 scoped_refptr<gfx::GLSurface> surface, |
40 bool lose_context_when_out_of_memory, | 38 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
41 gfx::AcceleratedWidget window, | |
42 const std::string& debug_name); | 39 const std::string& debug_name); |
43 ~InProcessContextProvider() override; | 40 ~ContextProviderInProcess() override; |
44 | 41 |
45 // cc::ContextProvider: | 42 // cc::ContextProvider: |
46 bool BindToCurrentThread() override; | 43 bool BindToCurrentThread() override; |
47 Capabilities ContextCapabilities() override; | 44 Capabilities ContextCapabilities() override; |
48 gpu::gles2::GLES2Interface* ContextGL() override; | 45 gpu::gles2::GLES2Interface* ContextGL() override; |
49 gpu::ContextSupport* ContextSupport() override; | 46 gpu::ContextSupport* ContextSupport() override; |
50 class GrContext* GrContext() override; | 47 class GrContext* GrContext() override; |
51 void SetupLock() override; | 48 void SetupLock() override; |
52 base::Lock* GetLock() override; | 49 base::Lock* GetLock() override; |
53 bool IsContextLost() override; | 50 bool IsContextLost() override; |
54 void VerifyContexts() override; | 51 void VerifyContexts() override; |
55 void DeleteCachedResources() override; | 52 void DeleteCachedResources() override; |
56 bool DestroyedOnMainThread() override; | 53 bool DestroyedOnMainThread() override; |
57 void SetLostContextCallback( | 54 void SetLostContextCallback( |
58 const LostContextCallback& lost_context_callback) override; | 55 const LostContextCallback& lost_context_callback) override; |
59 void SetMemoryPolicyChangedCallback( | 56 void SetMemoryPolicyChangedCallback( |
60 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 57 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
61 override; | 58 override; |
62 | 59 |
63 void OnLostContext(); | 60 void OnLostContext(); |
64 | 61 |
65 base::ThreadChecker main_thread_checker_; | 62 base::ThreadChecker main_thread_checker_; |
66 base::ThreadChecker context_thread_checker_; | 63 base::ThreadChecker context_thread_checker_; |
boliu
2015/04/20 10:06:05
We can assume main_thread and context_thread is al
tfarina
2015/04/22 02:09:04
Done.
| |
67 | 64 |
65 scoped_refptr<gfx::GLSurface> surface_; | |
66 scoped_refptr<gpu::InProcessCommandBuffer::Service> service_; | |
boliu
2015/04/20 10:06:05
You can create GLInProcessContext in the construct
tfarina
2015/04/22 02:09:04
Done.
| |
68 scoped_ptr<gpu::GLInProcessContext> context_; | 67 scoped_ptr<gpu::GLInProcessContext> context_; |
69 skia::RefPtr<class GrContext> gr_context_; | 68 skia::RefPtr<class GrContext> gr_context_; |
70 | 69 |
71 gpu::gles2::ContextCreationAttribHelper attribs_; | |
72 bool lose_context_when_out_of_memory_; | |
73 gfx::AcceleratedWidget window_; | |
74 std::string debug_name_; | 70 std::string debug_name_; |
75 cc::ContextProvider::Capabilities capabilities_; | 71 cc::ContextProvider::Capabilities capabilities_; |
76 | 72 |
77 LostContextCallback lost_context_callback_; | 73 LostContextCallback lost_context_callback_; |
78 | 74 |
79 base::Lock destroyed_lock_; | 75 base::Lock destroyed_lock_; |
80 bool destroyed_; | 76 bool destroyed_; |
81 | 77 |
82 base::Lock context_lock_; | 78 base::Lock context_lock_; |
83 | 79 |
84 DISALLOW_COPY_AND_ASSIGN(InProcessContextProvider); | 80 DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); |
85 }; | 81 }; |
86 | 82 |
87 } // namespace ui | 83 } // namespace android_webview |
88 | 84 |
89 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 85 #endif // ANDROID_WEBVIEW_BROWSER_CONTEXT_PROVIDER_IN_PROCESS_H_ |
OLD | NEW |