summaryrefslogtreecommitdiffstats
path: root/chromium/components/viz/service/display_embedder/gpu_display_provider.h
blob: 5db0c61c19165604bdb47def16bd729c0b203f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_GPU_DISPLAY_PROVIDER_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_GPU_DISPLAY_PROVIDER_H_

#include <memory>

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/service/display_embedder/display_provider.h"
#include "components/viz/service/viz_service_export.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/ipc/common/surface_handle.h"
#include "gpu/ipc/in_process_command_buffer.h"

#if defined(OS_WIN)
#include "components/viz/service/display_embedder/output_device_backing.h"
#endif

namespace gpu {
class CommandBufferTaskExecutor;
class GpuChannelManagerDelegate;
class GpuMemoryBufferManager;
class ImageFactory;
class SharedContextState;
}  // namespace gpu

namespace viz {
class Display;
class GpuServiceImpl;
class ServerSharedBitmapManager;
class SoftwareOutputDevice;

#if defined(TOOLKIT_QT)
class OutputSurface;
class VizProcessContextProvider;
#endif

// In-process implementation of DisplayProvider.
class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider {
 public:
  GpuDisplayProvider(
      uint32_t restart_id,
      GpuServiceImpl* gpu_service_impl,
      gpu::CommandBufferTaskExecutor* task_executor,
      gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate,
      std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager,
      gpu::ImageFactory* image_factory,
      ServerSharedBitmapManager* server_shared_bitmap_manager,
      bool headless,
      bool wait_for_all_pipeline_stages_before_draw);
  // Software compositing only.
  GpuDisplayProvider(uint32_t restart_id,
                     ServerSharedBitmapManager* server_shared_bitmap_manager,
                     bool headless,
                     bool wait_for_all_pipeline_stages_before_draw);
  ~GpuDisplayProvider() override;

  // DisplayProvider implementation.
  std::unique_ptr<Display> CreateDisplay(
      const FrameSinkId& frame_sink_id,
      gpu::SurfaceHandle surface_handle,
      bool gpu_compositing,
      mojom::DisplayClient* display_client,
      BeginFrameSource* begin_frame_source,
      UpdateVSyncParametersCallback update_vsync_callback,
      const RendererSettings& renderer_settings,
      bool send_swap_size_notifications) override;
  uint32_t GetRestartId() const override;

 private:
#if defined(TOOLKIT_QT)
  std::unique_ptr<OutputSurface> CreateSoftwareOutputSurface(
      UpdateVSyncParametersCallback update_vsync_callback);
  std::unique_ptr<OutputSurface> CreateGLOutputSurface(
      scoped_refptr<VizProcessContextProvider> context_provider,
      UpdateVSyncParametersCallback update_vsync_callback);
#endif

  std::unique_ptr<SoftwareOutputDevice> CreateSoftwareOutputDeviceForPlatform(
      gpu::SurfaceHandle surface_handle,
      mojom::DisplayClient* display_client);

  const uint32_t restart_id_;
  GpuServiceImpl* const gpu_service_impl_;
  gpu::CommandBufferTaskExecutor* const task_executor_;
  gpu::GpuChannelManagerDelegate* const gpu_channel_manager_delegate_;
  std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_;
  gpu::ImageFactory* const image_factory_;
  ServerSharedBitmapManager* const server_shared_bitmap_manager_;

#if defined(OS_WIN)
  // Used for software compositing output on Windows.
  OutputDeviceBacking output_device_backing_;
#endif

  scoped_refptr<base::SingleThreadTaskRunner> task_runner_;

  // A shared context which will be used on display compositor thread.
  scoped_refptr<gpu::SharedContextState> shared_context_state_;
  std::unique_ptr<gpu::MailboxManager> mailbox_manager_;
  std::unique_ptr<gpu::SyncPointManager> sync_point_manager_;

  const bool headless_;
  const bool wait_for_all_pipeline_stages_before_draw_;

  DISALLOW_COPY_AND_ASSIGN(GpuDisplayProvider);
};

}  // namespace viz

#endif  //  COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_GPU_DISPLAY_PROVIDER_H_