[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 1fb9e7e | 2013-05-26 03:23:48 | [diff] [blame] | 5 | #ifndef WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
6 | #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | ||||
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 7 | |
tfarina | 9c951cf | 2015-01-16 23:26:53 | [diff] [blame] | 8 | #include <string> |
9 | |||||
10 | #include "base/macros.h" | ||||
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 11 | #include "base/memory/scoped_ptr.h" |
12 | #include "base/synchronization/lock.h" | ||||
[email protected] | 6b14423 | 2013-07-30 22:27:55 | [diff] [blame] | 13 | #include "base/threading/thread_checker.h" |
tfarina | ae8232df | 2015-02-04 13:10:02 | [diff] [blame] | 14 | #include "cc/blink/context_provider_web_context.h" |
[email protected] | 1fb9e7e | 2013-05-26 03:23:48 | [diff] [blame] | 15 | #include "webkit/common/gpu/webkit_gpu_export.h" |
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 16 | |
[email protected] | c32e2708 | 2013-11-07 06:58:20 | [diff] [blame] | 17 | namespace blink { class WebGraphicsContext3D; } |
[email protected] | 59fe2c3 | 2013-06-21 10:03:37 | [diff] [blame] | 18 | |
tfarina | 9c951cf | 2015-01-16 23:26:53 | [diff] [blame] | 19 | namespace gpu_blink { |
20 | class WebGraphicsContext3DInProcessCommandBufferImpl; | ||||
21 | } | ||||
22 | |||||
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 23 | namespace webkit { |
24 | namespace gpu { | ||||
25 | class GrContextForWebGraphicsContext3D; | ||||
26 | |||||
[email protected] | 372a337 | 2013-03-13 16:35:02 | [diff] [blame] | 27 | class WEBKIT_GPU_EXPORT ContextProviderInProcess |
tfarina | ae8232df | 2015-02-04 13:10:02 | [diff] [blame] | 28 | : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { |
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 29 | public: |
[email protected] | 3d6b512 | 2013-08-14 22:25:34 | [diff] [blame] | 30 | static scoped_refptr<ContextProviderInProcess> Create( |
tfarina | 70da38b | 2015-01-09 03:16:10 | [diff] [blame] | 31 | scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> |
32 | context3d, | ||||
[email protected] | af13d83 | 2013-09-13 06:56:27 | [diff] [blame] | 33 | const std::string& debug_name); |
[email protected] | 3d6b512 | 2013-08-14 22:25:34 | [diff] [blame] | 34 | |
[email protected] | 828a393 | 2014-04-02 14:43:13 | [diff] [blame] | 35 | // Uses default attributes for creating an offscreen context. |
36 | static scoped_refptr<ContextProviderInProcess> CreateOffscreen( | ||||
37 | bool lose_context_when_out_of_memory); | ||||
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 38 | |
tfarina | 9c951cf | 2015-01-16 23:26:53 | [diff] [blame] | 39 | private: |
40 | ContextProviderInProcess( | ||||
41 | scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> | ||||
42 | context3d, | ||||
43 | const std::string& debug_name); | ||||
44 | ~ContextProviderInProcess() override; | ||||
45 | |||||
tfarina | ae8232df | 2015-02-04 13:10:02 | [diff] [blame] | 46 | // cc_blink::ContextProviderWebContext: |
dcheng | 5794dbf | 2014-12-23 00:00:27 | [diff] [blame] | 47 | blink::WebGraphicsContext3D* WebContext3D() override; |
[email protected] | e7e7ebd | 2014-01-16 00:11:11 | [diff] [blame] | 48 | |
tfarina | 9c951cf | 2015-01-16 23:26:53 | [diff] [blame] | 49 | // cc::ContextProvider: |
dcheng | 5794dbf | 2014-12-23 00:00:27 | [diff] [blame] | 50 | bool BindToCurrentThread() override; |
vmiura | 78b6928 | 2015-02-14 00:01:17 | [diff] [blame] | 51 | void DetachFromThread() override; |
dcheng | 5794dbf | 2014-12-23 00:00:27 | [diff] [blame] | 52 | Capabilities ContextCapabilities() override; |
53 | ::gpu::gles2::GLES2Interface* ContextGL() override; | ||||
54 | ::gpu::ContextSupport* ContextSupport() override; | ||||
55 | class GrContext* GrContext() override; | ||||
jbauman | 3595209 | 2015-02-13 00:57:48 | [diff] [blame] | 56 | void SetupLock() override; |
57 | base::Lock* GetLock() override; | ||||
dcheng | 5794dbf | 2014-12-23 00:00:27 | [diff] [blame] | 58 | bool IsContextLost() override; |
59 | void VerifyContexts() override; | ||||
60 | void DeleteCachedResources() override; | ||||
61 | bool DestroyedOnMainThread() override; | ||||
62 | void SetLostContextCallback( | ||||
anujk.sharma | c4fa57e | 2014-10-07 07:31:15 | [diff] [blame] | 63 | const LostContextCallback& lost_context_callback) override; |
dcheng | 5794dbf | 2014-12-23 00:00:27 | [diff] [blame] | 64 | void SetMemoryPolicyChangedCallback( |
[email protected] | 0634cdd4 | 2013-08-16 00:46:09 | [diff] [blame] | 65 | const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
anujk.sharma | c4fa57e | 2014-10-07 07:31:15 | [diff] [blame] | 66 | override; |
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 67 | |
[email protected] | 6b14423 | 2013-07-30 22:27:55 | [diff] [blame] | 68 | void OnLostContext(); |
[email protected] | 6d66889 | 2013-12-04 21:37:12 | [diff] [blame] | 69 | void InitializeCapabilities(); |
70 | |||||
[email protected] | 6b14423 | 2013-07-30 22:27:55 | [diff] [blame] | 71 | base::ThreadChecker main_thread_checker_; |
72 | base::ThreadChecker context_thread_checker_; | ||||
73 | |||||
tfarina | 70da38b | 2015-01-09 03:16:10 | [diff] [blame] | 74 | scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> |
[email protected] | 0634cdd4 | 2013-08-16 00:46:09 | [diff] [blame] | 75 | context3d_; |
tfarina | 9c951cf | 2015-01-16 23:26:53 | [diff] [blame] | 76 | scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; |
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 77 | |
[email protected] | 6b14423 | 2013-07-30 22:27:55 | [diff] [blame] | 78 | LostContextCallback lost_context_callback_; |
79 | |||||
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 80 | base::Lock destroyed_lock_; |
81 | bool destroyed_; | ||||
82 | |||||
jbauman | 7dc2605 | 2015-02-14 00:22:45 | [diff] [blame] | 83 | base::Lock context_lock_; |
[email protected] | af13d83 | 2013-09-13 06:56:27 | [diff] [blame] | 84 | std::string debug_name_; |
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 85 | class LostContextCallbackProxy; |
86 | scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | ||||
87 | |||||
[email protected] | 6d66889 | 2013-12-04 21:37:12 | [diff] [blame] | 88 | cc::ContextProvider::Capabilities capabilities_; |
89 | |||||
[email protected] | f44d555 | 2013-10-29 04:56:29 | [diff] [blame] | 90 | DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); |
[email protected] | d03d784 | 2013-02-28 23:08:17 | [diff] [blame] | 91 | }; |
92 | |||||
93 | } // namespace gpu | ||||
94 | } // namespace webkit | ||||
95 | |||||
[email protected] | 1fb9e7e | 2013-05-26 03:23:48 | [diff] [blame] | 96 | #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |