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_
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"
20 class GLInProcessContext
;
21 class GpuMemoryBufferManager
;
27 class InProcessContextProvider
: public cc::ContextProvider
{
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 gfx::AcceleratedWidget window
,
34 const std::string
& debug_name
);
36 // Uses default attributes for creating an offscreen context.
37 static scoped_refptr
<InProcessContextProvider
> CreateOffscreen(
38 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager
,
39 gpu::ImageFactory
* image_factory
);
42 InProcessContextProvider(
43 const gpu::gles2::ContextCreationAttribHelper
& attribs
,
44 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager
,
45 gpu::ImageFactory
* image_factory
,
46 gfx::AcceleratedWidget window
,
47 const std::string
& debug_name
);
48 ~InProcessContextProvider() override
;
50 // cc::ContextProvider:
51 bool BindToCurrentThread() override
;
52 Capabilities
ContextCapabilities() override
;
53 gpu::gles2::GLES2Interface
* ContextGL() override
;
54 gpu::ContextSupport
* ContextSupport() override
;
55 class GrContext
* GrContext() override
;
56 void InvalidateGrContext(uint32_t state
) override
;
57 void SetupLock() override
;
58 base::Lock
* GetLock() override
;
59 void VerifyContexts() override
;
60 void DeleteCachedResources() override
;
61 bool DestroyedOnMainThread() override
;
62 void SetLostContextCallback(
63 const LostContextCallback
& lost_context_callback
) override
;
64 void SetMemoryPolicyChangedCallback(
65 const MemoryPolicyChangedCallback
& memory_policy_changed_callback
)
70 base::ThreadChecker main_thread_checker_
;
71 base::ThreadChecker context_thread_checker_
;
73 scoped_ptr
<gpu::GLInProcessContext
> context_
;
74 skia::RefPtr
<class GrContext
> gr_context_
;
76 gpu::gles2::ContextCreationAttribHelper attribs_
;
77 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager_
;
78 gpu::ImageFactory
* image_factory_
;
79 gfx::AcceleratedWidget window_
;
80 std::string debug_name_
;
81 cc::ContextProvider::Capabilities capabilities_
;
83 LostContextCallback lost_context_callback_
;
85 base::Lock destroyed_lock_
;
88 base::Lock context_lock_
;
90 DISALLOW_COPY_AND_ASSIGN(InProcessContextProvider
);
95 #endif // UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_