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 UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_FACTORY_H_
6 #define UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_FACTORY_H_
8 #include "cc/test/test_gpu_memory_buffer_manager.h"
9 #include "cc/test/test_shared_bitmap_manager.h"
10 #include "cc/test/test_task_graph_runner.h"
11 #include "ui/compositor/compositor.h"
18 class OnscreenDisplayClient
;
24 class InProcessContextFactory
: public ContextFactory
{
26 // surface_manager is owned by the creator of this and must outlive the
28 InProcessContextFactory(bool context_factory_for_test
,
29 cc::SurfaceManager
* surface_manager
);
30 ~InProcessContextFactory() override
;
32 // If true (the default) an OutputSurface is created that does not display
33 // anything. Set to false if you want to see results on the screen.
34 void set_use_test_surface(bool use_test_surface
) {
35 use_test_surface_
= use_test_surface
;
38 // ContextFactory implementation
39 void CreateOutputSurface(base::WeakPtr
<Compositor
> compositor
) override
;
41 scoped_ptr
<Reflector
> CreateReflector(Compositor
* mirrored_compositor
,
42 Layer
* mirroring_layer
) override
;
43 void RemoveReflector(Reflector
* reflector
) override
;
45 scoped_refptr
<cc::ContextProvider
> SharedMainThreadContextProvider() override
;
46 void RemoveCompositor(Compositor
* compositor
) override
;
47 bool DoesCreateTestContexts() override
;
48 uint32
GetImageTextureTarget() override
;
49 cc::SharedBitmapManager
* GetSharedBitmapManager() override
;
50 gpu::GpuMemoryBufferManager
* GetGpuMemoryBufferManager() override
;
51 cc::TaskGraphRunner
* GetTaskGraphRunner() override
;
52 scoped_ptr
<cc::SurfaceIdAllocator
> CreateSurfaceIdAllocator() override
;
53 void ResizeDisplay(ui::Compositor
* compositor
,
54 const gfx::Size
& size
) override
;
57 scoped_refptr
<cc::ContextProvider
> shared_main_thread_contexts_
;
58 cc::TestSharedBitmapManager shared_bitmap_manager_
;
59 cc::TestGpuMemoryBufferManager gpu_memory_buffer_manager_
;
60 cc::TestTaskGraphRunner task_graph_runner_
;
61 uint32_t next_surface_id_namespace_
;
62 bool use_test_surface_
;
63 bool context_factory_for_test_
;
64 cc::SurfaceManager
* surface_manager_
;
66 base::hash_map
<Compositor
*, cc::OnscreenDisplayClient
*> per_compositor_data_
;
68 DISALLOW_COPY_AND_ASSIGN(InProcessContextFactory
);
73 #endif // UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_FACTORY_H_