Roll src/third_party/skia 591a2ca:b3fe1b8
[chromium-blink-merge.git] / ui / compositor / test / in_process_context_provider.h
blob4edc464a684082b0220abb132219bf4c2eeea2b4
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;
21 class GpuMemoryBufferManager;
22 class ImageFactory;
25 namespace ui {
27 class InProcessContextProvider : public cc::ContextProvider {
28 public:
29 static scoped_refptr<InProcessContextProvider> Create(
30 const gpu::gles2::ContextCreationAttribHelper& attribs,
31 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
32 gpu::ImageFactory* image_factory,
33 bool lose_context_when_out_of_memory,
34 gfx::AcceleratedWidget window,
35 const std::string& debug_name);
37 // Uses default attributes for creating an offscreen context.
38 static scoped_refptr<InProcessContextProvider> CreateOffscreen(
39 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
40 gpu::ImageFactory* image_factory,
41 bool lose_context_when_out_of_memory);
43 private:
44 InProcessContextProvider(
45 const gpu::gles2::ContextCreationAttribHelper& attribs,
46 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
47 gpu::ImageFactory* image_factory,
48 bool lose_context_when_out_of_memory,
49 gfx::AcceleratedWidget window,
50 const std::string& debug_name);
51 ~InProcessContextProvider() override;
53 // cc::ContextProvider:
54 bool BindToCurrentThread() override;
55 Capabilities ContextCapabilities() override;
56 gpu::gles2::GLES2Interface* ContextGL() override;
57 gpu::ContextSupport* ContextSupport() override;
58 class GrContext* GrContext() override;
59 void InvalidateGrContext(uint32_t state) override;
60 void SetupLock() override;
61 base::Lock* GetLock() override;
62 void VerifyContexts() override;
63 void DeleteCachedResources() override;
64 bool DestroyedOnMainThread() override;
65 void SetLostContextCallback(
66 const LostContextCallback& lost_context_callback) override;
67 void SetMemoryPolicyChangedCallback(
68 const MemoryPolicyChangedCallback& memory_policy_changed_callback)
69 override;
71 void OnLostContext();
73 base::ThreadChecker main_thread_checker_;
74 base::ThreadChecker context_thread_checker_;
76 scoped_ptr<gpu::GLInProcessContext> context_;
77 skia::RefPtr<class GrContext> gr_context_;
79 gpu::gles2::ContextCreationAttribHelper attribs_;
80 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
81 gpu::ImageFactory* image_factory_;
82 bool lose_context_when_out_of_memory_;
83 gfx::AcceleratedWidget window_;
84 std::string debug_name_;
85 cc::ContextProvider::Capabilities capabilities_;
87 LostContextCallback lost_context_callback_;
89 base::Lock destroyed_lock_;
90 bool destroyed_;
92 base::Lock context_lock_;
94 DISALLOW_COPY_AND_ASSIGN(InProcessContextProvider);
97 } // namespace ui
99 #endif // UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_