File: in_process_context_factory.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (111 lines) | stat: -rw-r--r-- 4,669 bytes parent folder | download | duplicates (5)
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
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_FACTORY_H_
#define UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_FACTORY_H_

#include <stdint.h>

#include <memory>
#include <unordered_map>

#include "base/memory/raw_ptr.h"
#include "cc/test/test_task_graph_runner.h"
#include "components/viz/common/surfaces/frame_sink_id_allocator.h"
#include "components/viz/common/surfaces/subtree_capture_id_allocator.h"
#include "components/viz/service/display/display.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "gpu/command_buffer/service/scheduler.h"
#include "gpu/command_buffer/service/shared_image/shared_image_manager.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/ipc/common/surface_handle.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/viz/privileged/mojom/compositing/vsync_parameter_observer.mojom.h"
#include "ui/compositor/compositor.h"
namespace viz {
class HostFrameSinkManager;
class TestInProcessContextProvider;
}

namespace ui {

class InProcessContextFactory : public ContextFactory {
 public:
  // Both |host_frame_sink_manager| and |frame_sink_manager| must outlive the
  // ContextFactory.
  // TODO(crbug.com/40489946): |frame_sink_manager| should go away and we should
  // use the LayerTreeFrameSink from the HostFrameSinkManager.
  // The default for |output_to_window| will create an OutputSurface that does
  // not display anything. Set to true if you want to see results on the screen.
  InProcessContextFactory(viz::HostFrameSinkManager* host_frame_sink_manager,
                          viz::FrameSinkManagerImpl* frame_sink_manager,
                          bool output_to_window = false);

  InProcessContextFactory(const InProcessContextFactory&) = delete;
  InProcessContextFactory& operator=(const InProcessContextFactory&) = delete;

  ~InProcessContextFactory() override;

  viz::FrameSinkManagerImpl* GetFrameSinkManager() {
    return frame_sink_manager_;
  }

  // Setting a higher refresh rate will spend less time waiting for BeginFrame;
  // while setting a lower refresh rate will reduce the workload per unit of
  // time, which could be useful, e.g., when using mock time and fast forwarding
  // by a long duration.
  //
  // Takes effect for the next CreateLayerTreeFrameSink() call.
  void SetRefreshRateForTests(double refresh_rate);

  // ContextFactory implementation.
  void CreateLayerTreeFrameSink(base::WeakPtr<Compositor> compositor) override;

  scoped_refptr<viz::RasterContextProvider>
  SharedMainThreadRasterContextProvider() override;

  void RemoveCompositor(Compositor* compositor) override;
  cc::TaskGraphRunner* GetTaskGraphRunner() override;
  viz::FrameSinkId AllocateFrameSinkId() override;
  viz::SubtreeCaptureId AllocateSubtreeCaptureId() override;
  viz::HostFrameSinkManager* GetHostFrameSinkManager() override;

  SkM44 GetOutputColorMatrix(Compositor* compositor) const;
  gfx::DisplayColorSpaces GetDisplayColorSpaces(Compositor* compositor) const;
  base::TimeTicks GetDisplayVSyncTimeBase(Compositor* compositor) const;
  base::TimeDelta GetDisplayVSyncTimeInterval(Compositor* compositor) const;
  std::optional<base::TimeDelta> GetMaxVSyncInterval(
      Compositor* compositor) const;
  display::VariableRefreshRateState GetVrrState(Compositor* compositor) const;
  void ResetDisplayOutputParameters(Compositor* compositor);

 private:
  class PerCompositorData;

  PerCompositorData* CreatePerCompositorData(Compositor* compositor);

  scoped_refptr<viz::TestInProcessContextProvider> shared_main_thread_contexts_;
  scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider_;
  gpu::SharedImageManager shared_image_manager_;
  gpu::SyncPointManager sync_point_manager_;
  gpu::Scheduler gpu_scheduler_{&sync_point_manager_};
  cc::TestTaskGraphRunner task_graph_runner_;
  viz::FrameSinkIdAllocator frame_sink_id_allocator_;
  viz::SubtreeCaptureIdAllocator subtree_capture_id_allocator_;
  bool output_to_window_ = false;
  bool disable_vsync_ = false;
  double refresh_rate_ = 60.0;
  const raw_ptr<viz::HostFrameSinkManager> host_frame_sink_manager_;
  const raw_ptr<viz::FrameSinkManagerImpl> frame_sink_manager_;

  viz::RendererSettings renderer_settings_;
  viz::DebugRendererSettings debug_settings_;
  using PerCompositorDataMap =
      std::unordered_map<Compositor*, std::unique_ptr<PerCompositorData>>;
  PerCompositorDataMap per_compositor_data_;
};

}  // namespace ui

#endif  // UI_COMPOSITOR_TEST_IN_PROCESS_CONTEXT_FACTORY_H_