Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / blimp / client / compositor / blimp_context_provider.h
blob922ae4db7320dd049601c7170fa5ce9d3ae47820
1 // Copyright 2015 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 BLIMP_CLIENT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_
6 #define BLIMP_CLIENT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/lock.h"
11 #include "base/threading/thread_checker.h"
12 #include "cc/output/context_provider.h"
13 #include "gpu/command_buffer/client/gl_in_process_context.h"
14 #include "skia/ext/refptr.h"
15 #include "ui/gl/gl_surface.h"
17 namespace blimp {
19 // Helper class to provide a graphics context for the compositor.
20 class BlimpContextProvider : public cc::ContextProvider {
21 public:
22 static scoped_refptr<BlimpContextProvider> Create(
23 gfx::AcceleratedWidget widget);
25 // cc::ContextProvider implementation.
26 bool BindToCurrentThread() override;
27 void DetachFromThread() override;
28 Capabilities ContextCapabilities() override;
29 gpu::gles2::GLES2Interface* ContextGL() override;
30 gpu::ContextSupport* ContextSupport() override;
31 class GrContext* GrContext() override;
32 void InvalidateGrContext(uint32_t state) override;
33 void SetupLock() override;
34 base::Lock* GetLock() override;
35 void VerifyContexts() override;
36 void DeleteCachedResources() override;
37 bool DestroyedOnMainThread() override;
38 void SetLostContextCallback(
39 const LostContextCallback& lost_context_callback) override;
40 void SetMemoryPolicyChangedCallback(
41 const MemoryPolicyChangedCallback& memory_policy_changed_callback)
42 override;
44 protected:
45 explicit BlimpContextProvider(gfx::AcceleratedWidget widget);
46 ~BlimpContextProvider() override;
48 private:
49 void OnLostContext();
51 base::ThreadChecker main_thread_checker_;
52 base::ThreadChecker context_thread_checker_;
54 base::Lock context_lock_;
55 scoped_ptr<gpu::GLInProcessContext> context_;
56 skia::RefPtr<class GrContext> gr_context_;
58 cc::ContextProvider::Capabilities capabilities_;
60 LostContextCallback lost_context_callback_;
62 base::Lock destroyed_lock_;
63 bool destroyed_;
65 DISALLOW_COPY_AND_ASSIGN(BlimpContextProvider);
68 } // namespace blimp
70 #endif // BLIMP_CLIENT_COMPOSITOR_BLIMP_CONTEXT_PROVIDER_H_