Revert of [Chromecast] Ignore interfaces not used to connect to internet. (patchset...
[chromium-blink-merge.git] / content / common / gpu / client / context_provider_command_buffer.h
blob78c1b29b610a92837a665a181035017b08acb448
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 CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_
6 #define CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_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 "cc/blink/context_provider_web_context.h"
13 #include "cc/output/context_provider.h"
14 #include "content/common/content_export.h"
15 #include "content/common/gpu/client/command_buffer_metrics.h"
16 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
18 namespace content {
20 class GrContextForWebGraphicsContext3D;
22 // Implementation of cc::ContextProvider that provides a
23 // WebGraphicsContext3DCommandBufferImpl context and a GrContext.
24 class CONTENT_EXPORT ContextProviderCommandBuffer
25 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) {
26 public:
27 static scoped_refptr<ContextProviderCommandBuffer> Create(
28 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d,
29 CommandBufferContextType type);
31 CommandBufferProxyImpl* GetCommandBufferProxy();
33 // cc_blink::ContextProviderWebContext implementation.
34 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override;
36 // cc::ContextProvider implementation.
37 bool BindToCurrentThread() override;
38 void DetachFromThread() override;
39 gpu::gles2::GLES2Interface* ContextGL() override;
40 gpu::ContextSupport* ContextSupport() override;
41 class GrContext* GrContext() override;
42 void InvalidateGrContext(uint32_t state) override;
43 void SetupLock() override;
44 base::Lock* GetLock() override;
45 Capabilities ContextCapabilities() override;
46 bool IsContextLost() override;
47 void VerifyContexts() override;
48 void DeleteCachedResources() override;
49 bool DestroyedOnMainThread() override;
50 void SetLostContextCallback(
51 const LostContextCallback& lost_context_callback) override;
52 void SetMemoryPolicyChangedCallback(
53 const MemoryPolicyChangedCallback& memory_policy_changed_callback)
54 override;
56 protected:
57 ContextProviderCommandBuffer(
58 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d,
59 CommandBufferContextType type);
60 ~ContextProviderCommandBuffer() override;
62 void OnLostContext();
63 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation);
65 private:
66 void InitializeCapabilities();
68 base::ThreadChecker main_thread_checker_;
69 base::ThreadChecker context_thread_checker_;
71 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_;
72 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_;
74 cc::ContextProvider::Capabilities capabilities_;
75 CommandBufferContextType context_type_;
76 std::string debug_name_;
78 LostContextCallback lost_context_callback_;
79 MemoryPolicyChangedCallback memory_policy_changed_callback_;
81 base::Lock main_thread_lock_;
82 bool destroyed_;
84 base::Lock context_lock_;
86 class LostContextCallbackProxy;
87 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_;
90 } // namespace content
92 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_