Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: services/ui/surfaces/mojo_frame_sink_manager.h

Issue 2795823003: Create //components/viz/frame_sinks and move code. (Closed)
Patch Set: Fix DEPS. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #ifndef SERVICES_UI_SURFACES_MOJO_FRAME_SINK_MANAGER_H_
6 #define SERVICES_UI_SURFACES_MOJO_FRAME_SINK_MANAGER_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <unordered_map>
12
13 #include "base/macros.h"
14 #include "base/threading/thread_checker.h"
15 #include "cc/ipc/frame_sink_manager.mojom.h"
16 #include "cc/surfaces/frame_sink_id.h"
17 #include "cc/surfaces/surface_manager.h"
18 #include "cc/surfaces/surface_observer.h"
19 #include "components/display_compositor/gpu_compositor_frame_sink_delegate.h"
20 #include "gpu/ipc/common/surface_handle.h"
21 #include "mojo/public/cpp/bindings/binding.h"
22
23 namespace ui {
24
25 class DisplayProvider;
26
27 // MojoFrameSinkManager manages state associated with CompositorFrameSinks. It
28 // provides a Mojo interface to create CompositorFrameSinks, manages BeginFrame
29 // hierarchy and manages surface lifetime.
30 //
31 // This is intended to be created in the viz or GPU process. For mus+ash this
32 // will be true after the mus process split. For non-mus Chrome this will be
33 // created in the browser process, at least until GPU implementations can be
34 // unified.
35 class MojoFrameSinkManager
36 : public cc::SurfaceObserver,
37 public display_compositor::GpuCompositorFrameSinkDelegate,
38 public cc::mojom::FrameSinkManager {
39 public:
40 MojoFrameSinkManager(DisplayProvider* display_provider,
41 cc::mojom::FrameSinkManagerRequest request,
42 cc::mojom::FrameSinkManagerClientPtr client);
43 ~MojoFrameSinkManager() override;
44
45 cc::SurfaceManager* manager() { return &manager_; }
46
47 // cc::mojom::MojoFrameSinkManager implementation:
48 void CreateRootCompositorFrameSink(
49 const cc::FrameSinkId& frame_sink_id,
50 gpu::SurfaceHandle surface_handle,
51 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request,
52 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
53 cc::mojom::MojoCompositorFrameSinkClientPtr client,
54 cc::mojom::DisplayPrivateAssociatedRequest display_private_request)
55 override;
56 void CreateCompositorFrameSink(
57 const cc::FrameSinkId& frame_sink_id,
58 cc::mojom::MojoCompositorFrameSinkRequest request,
59 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
60 cc::mojom::MojoCompositorFrameSinkClientPtr client) override;
61 void RegisterFrameSinkHierarchy(
62 const cc::FrameSinkId& parent_frame_sink_id,
63 const cc::FrameSinkId& child_frame_sink_id) override;
64 void UnregisterFrameSinkHierarchy(
65 const cc::FrameSinkId& parent_frame_sink_id,
66 const cc::FrameSinkId& child_frame_sink_id) override;
67 void DropTemporaryReference(const cc::SurfaceId& surface_id) override;
68
69 private:
70 // It is necessary to pass |frame_sink_id| by value because the id
71 // is owned by the GpuCompositorFrameSink in the map. When the sink is
72 // removed from the map, |frame_sink_id| would also be destroyed if it were a
73 // reference. But the map can continue to iterate and try to use it. Passing
74 // by value avoids this.
75 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id);
76
77 // cc::SurfaceObserver implementation.
78 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override;
79 void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
80 bool* changed) override;
81
82 // display_compositor::GpuCompositorFrameSinkDelegate implementation.
83 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id,
84 bool destroy_compositor_frame_sink) override;
85 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id,
86 bool destroy_compositor_frame_sink) override;
87
88 // SurfaceManager should be the first object constructed and the last object
89 // destroyed in order to ensure that all other objects that depend on it have
90 // access to a valid pointer for the entirety of their lifetimes.
91 cc::SurfaceManager manager_;
92
93 // Provides a cc::Display for CreateRootCompositorFrameSink().
94 DisplayProvider* const display_provider_;
95
96 std::unordered_map<cc::FrameSinkId,
97 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>,
98 cc::FrameSinkIdHash>
99 compositor_frame_sinks_;
100
101 base::ThreadChecker thread_checker_;
102
103 cc::mojom::FrameSinkManagerClientPtr client_;
104 mojo::Binding<cc::mojom::FrameSinkManager> binding_;
105
106 DISALLOW_COPY_AND_ASSIGN(MojoFrameSinkManager);
107 };
108
109 } // namespace ui
110
111 #endif // SERVICES_UI_SURFACES_MOJO_FRAME_SINK_MANAGER_H_
OLDNEW
« no previous file with comments | « services/ui/surfaces/display_provider.h ('k') | services/ui/surfaces/mojo_frame_sink_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698