Revert of Enabling audio quality test on mac. (patchset #1 id:1 of https://codereview...
[chromium-blink-merge.git] / webkit / common / gpu / context_provider_in_process.h
blob3df327b76a51eeb469fbfe2cec846dc4d9cf2615
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.
5 #ifndef WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_
6 #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/lock.h"
11 #include "base/threading/thread_checker.h"
12 #include "webkit/common/gpu/context_provider_web_context.h"
13 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
14 #include "webkit/common/gpu/webkit_gpu_export.h"
16 namespace blink { class WebGraphicsContext3D; }
18 namespace webkit {
19 namespace gpu {
20 class GrContextForWebGraphicsContext3D;
22 class WEBKIT_GPU_EXPORT ContextProviderInProcess
23 : NON_EXPORTED_BASE(public ContextProviderWebContext) {
24 public:
25 static scoped_refptr<ContextProviderInProcess> Create(
26 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
27 const std::string& debug_name);
29 // Uses default attributes for creating an offscreen context.
30 static scoped_refptr<ContextProviderInProcess> CreateOffscreen(
31 bool lose_context_when_out_of_memory);
33 virtual blink::WebGraphicsContext3D* WebContext3D() OVERRIDE;
35 virtual bool BindToCurrentThread() OVERRIDE;
36 virtual Capabilities ContextCapabilities() OVERRIDE;
37 virtual ::gpu::gles2::GLES2Interface* ContextGL() OVERRIDE;
38 virtual ::gpu::ContextSupport* ContextSupport() OVERRIDE;
39 virtual class GrContext* GrContext() OVERRIDE;
40 virtual bool IsContextLost() OVERRIDE;
41 virtual void VerifyContexts() OVERRIDE;
42 virtual void DeleteCachedResources() OVERRIDE;
43 virtual bool DestroyedOnMainThread() OVERRIDE;
44 virtual void SetLostContextCallback(
45 const LostContextCallback& lost_context_callback) OVERRIDE;
46 virtual void SetMemoryPolicyChangedCallback(
47 const MemoryPolicyChangedCallback& memory_policy_changed_callback)
48 OVERRIDE;
50 protected:
51 ContextProviderInProcess(
52 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
53 const std::string& debug_name);
54 virtual ~ContextProviderInProcess();
56 void OnLostContext();
58 private:
59 void InitializeCapabilities();
61 base::ThreadChecker main_thread_checker_;
62 base::ThreadChecker context_thread_checker_;
64 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
65 context3d_;
66 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_;
68 LostContextCallback lost_context_callback_;
70 base::Lock destroyed_lock_;
71 bool destroyed_;
73 std::string debug_name_;
74 class LostContextCallbackProxy;
75 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_;
77 cc::ContextProvider::Capabilities capabilities_;
79 DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess);
82 } // namespace gpu
83 } // namespace webkit
85 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_