OLD | NEW |
| (Empty) |
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 | |
5 #ifndef WEBKIT_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | |
6 #define WEBKIT_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/synchronization/lock.h" | |
11 #include "cc/output/context_provider.h" | |
12 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | |
13 #include "webkit/gpu/webkit_gpu_export.h" | |
14 | |
15 namespace webkit { | |
16 namespace gpu { | |
17 class GrContextForWebGraphicsContext3D; | |
18 | |
19 class WEBKIT_GPU_EXPORT ContextProviderInProcess | |
20 : NON_EXPORTED_BASE(public cc::ContextProvider) { | |
21 public: | |
22 static scoped_refptr<ContextProviderInProcess> Create() { | |
23 scoped_refptr<ContextProviderInProcess> provider = | |
24 new ContextProviderInProcess; | |
25 if (!provider->InitializeOnMainThread()) | |
26 return NULL; | |
27 return provider; | |
28 } | |
29 | |
30 virtual bool BindToCurrentThread() OVERRIDE; | |
31 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; | |
32 virtual class GrContext* GrContext() OVERRIDE; | |
33 virtual void VerifyContexts() OVERRIDE; | |
34 virtual bool DestroyedOnMainThread() OVERRIDE; | |
35 | |
36 protected: | |
37 ContextProviderInProcess(); | |
38 virtual ~ContextProviderInProcess(); | |
39 | |
40 bool InitializeOnMainThread(); | |
41 | |
42 void OnLostContextInternal(); | |
43 virtual void OnLostContext() {} | |
44 virtual void OnMemoryAllocationChanged(bool nonzero_allocation); | |
45 | |
46 private: | |
47 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> | |
48 context3d_; | |
49 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_; | |
50 | |
51 base::Lock destroyed_lock_; | |
52 bool destroyed_; | |
53 | |
54 class LostContextCallbackProxy; | |
55 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | |
56 | |
57 class MemoryAllocationCallbackProxy; | |
58 scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_; | |
59 }; | |
60 | |
61 } // namespace gpu | |
62 } // namespace webkit | |
63 | |
64 #endif // WEBKIT_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | |
OLD | NEW |