Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / mus / surfaces / surfaces_context_provider.h
blob37cdfab770587cd3af6cbd438d669c087472794c
1 // Copyright 2014 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 COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_
6 #define COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_
8 #include "base/macros.h"
9 #include "base/synchronization/lock.h"
10 #include "base/threading/non_thread_safe.h"
11 #include "cc/output/context_provider.h"
12 #include "components/mus/gles2/command_buffer_local_client.h"
13 #include "ui/gfx/native_widget_types.h"
15 namespace gpu {
17 class TransferBuffer;
19 namespace gles2 {
20 class GLES2CmdHelper;
21 class GLES2Implementation;
24 } // namespace gpu
26 namespace mus {
28 class CommandBufferDriver;
29 class CommandBufferImpl;
30 class CommandBufferLocal;
31 class GpuState;
32 class SurfacesContextProviderDelegate;
34 class SurfacesContextProvider : public cc::ContextProvider,
35 public CommandBufferLocalClient,
36 public base::NonThreadSafe {
37 public:
38 SurfacesContextProvider(SurfacesContextProviderDelegate* delegate,
39 gfx::AcceleratedWidget widget,
40 const scoped_refptr<GpuState>& state);
42 // cc::ContextProvider implementation.
43 bool BindToCurrentThread() override;
44 gpu::gles2::GLES2Interface* ContextGL() override;
45 gpu::ContextSupport* ContextSupport() override;
46 class GrContext* GrContext() override;
47 void InvalidateGrContext(uint32_t state) override;
48 Capabilities ContextCapabilities() override;
49 void VerifyContexts() override {}
50 void DeleteCachedResources() override {}
51 bool DestroyedOnMainThread() override;
52 void SetLostContextCallback(
53 const LostContextCallback& lost_context_callback) override;
54 void SetMemoryPolicyChangedCallback(
55 const MemoryPolicyChangedCallback& memory_policy_changed_callback)
56 override {}
57 void SetupLock() override;
58 base::Lock* GetLock() override;
60 protected:
61 friend class base::RefCountedThreadSafe<SurfacesContextProvider>;
62 ~SurfacesContextProvider() override;
64 private:
65 // CommandBufferLocalClient:
66 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override;
67 void DidLoseContext() override;
69 // From GLES2Context:
70 // Initialized in BindToCurrentThread.
71 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_;
72 scoped_ptr<gpu::TransferBuffer> transfer_buffer_;
73 scoped_ptr<gpu::gles2::GLES2Implementation> implementation_;
75 cc::ContextProvider::Capabilities capabilities_;
76 LostContextCallback lost_context_callback_;
78 SurfacesContextProviderDelegate* delegate_;
79 gfx::AcceleratedWidget widget_;
80 scoped_ptr<CommandBufferLocal> command_buffer_local_;
82 base::Lock context_lock_;
84 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider);
87 } // namespace mus
89 #endif // COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_