Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / compositor / test / in_process_context_provider.h
blobb3c9da091e18886d369dd6cb99b8d1d690d1a736
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 UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_
6 #define UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread_checker.h"
14 #include "cc/output/context_provider.h"
15 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
16 #include "skia/ext/refptr.h"
17 #include "ui/gfx/native_widget_types.h"
19 namespace gpu {
20 class GLInProcessContext;
23 namespace ui {
25 class InProcessContextProvider : public cc::ContextProvider {
26 public:
27 static scoped_refptr<InProcessContextProvider> Create(
28 const gpu::gles2::ContextCreationAttribHelper& attribs,
29 bool lose_context_when_out_of_memory,
30 gfx::AcceleratedWidget window,
31 const std::string& debug_name);
33 // Uses default attributes for creating an offscreen context.
34 static scoped_refptr<InProcessContextProvider> CreateOffscreen(
35 bool lose_context_when_out_of_memory);
37 private:
38 InProcessContextProvider(
39 const gpu::gles2::ContextCreationAttribHelper& attribs,
40 bool lose_context_when_out_of_memory,
41 gfx::AcceleratedWidget window,
42 const std::string& debug_name);
43 ~InProcessContextProvider() override;
45 // cc::ContextProvider:
46 bool BindToCurrentThread() override;
47 Capabilities ContextCapabilities() override;
48 gpu::gles2::GLES2Interface* ContextGL() override;
49 gpu::ContextSupport* ContextSupport() override;
50 class GrContext* GrContext() override;
51 void SetupLock() override;
52 base::Lock* GetLock() override;
53 bool IsContextLost() override;
54 void VerifyContexts() override;
55 void DeleteCachedResources() override;
56 bool DestroyedOnMainThread() override;
57 void SetLostContextCallback(
58 const LostContextCallback& lost_context_callback) override;
59 void SetMemoryPolicyChangedCallback(
60 const MemoryPolicyChangedCallback& memory_policy_changed_callback)
61 override;
63 void OnLostContext();
65 base::ThreadChecker main_thread_checker_;
66 base::ThreadChecker context_thread_checker_;
68 scoped_ptr<gpu::GLInProcessContext> context_;
69 skia::RefPtr<class GrContext> gr_context_;
71 gpu::gles2::ContextCreationAttribHelper attribs_;
72 bool lose_context_when_out_of_memory_;
73 gfx::AcceleratedWidget window_;
74 std::string debug_name_;
75 cc::ContextProvider::Capabilities capabilities_;
77 LostContextCallback lost_context_callback_;
79 base::Lock destroyed_lock_;
80 bool destroyed_;
82 base::Lock context_lock_;
84 DISALLOW_COPY_AND_ASSIGN(InProcessContextProvider);
87 } // namespace ui
89 #endif // UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_