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

Side by Side Diff: services/ui/ws/frame_generator.h

Issue 2541683004: Add/remove surface references via MojoCompositorFrameSink. (Closed)
Patch Set: Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SERVICES_UI_WS_FRAME_GENERATOR_H_ 5 #ifndef SERVICES_UI_WS_FRAME_GENERATOR_H_
6 #define SERVICES_UI_WS_FRAME_GENERATOR_H_ 6 #define SERVICES_UI_WS_FRAME_GENERATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/timer/timer.h"
13 #include "cc/ipc/display_compositor.mojom.h"
14 #include "cc/surfaces/frame_sink_id.h" 13 #include "cc/surfaces/frame_sink_id.h"
15 #include "cc/surfaces/surface_id.h" 14 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_id_allocator.h" 15 #include "cc/surfaces/surface_id_allocator.h"
16 #include "cc/surfaces/surface_reference.h"
17 #include "services/ui/public/interfaces/window_tree_constants.mojom.h" 17 #include "services/ui/public/interfaces/window_tree_constants.mojom.h"
18 #include "services/ui/ws/ids.h" 18 #include "services/ui/ws/ids.h"
19 #include "services/ui/ws/server_window_delegate.h" 19 #include "services/ui/ws/server_window_delegate.h"
20 #include "services/ui/ws/server_window_tracker.h" 20 #include "services/ui/ws/server_window_tracker.h"
21 #include "ui/gfx/geometry/rect.h" 21 #include "ui/gfx/geometry/rect.h"
22 #include "ui/gfx/native_widget_types.h" 22 #include "ui/gfx/native_widget_types.h"
23 23
24 namespace cc { 24 namespace cc {
25 class CompositorFrame;
26 class RenderPass; 25 class RenderPass;
27 class SurfaceId;
28 }
29
30 namespace gpu {
31 class GpuChannelHost;
32 } 26 }
33 27
34 namespace ui { 28 namespace ui {
35
36 class DisplayCompositor;
37
38 namespace ws { 29 namespace ws {
39 30
40 namespace test { 31 namespace test {
41 class FrameGeneratorTest; 32 class FrameGeneratorTest;
42 } 33 }
43 34
44 class FrameGeneratorDelegate; 35 class FrameGeneratorDelegate;
45 class ServerWindow; 36 class ServerWindow;
46 37
47 // Responsible for redrawing the display in response to the redraw requests by 38 // Responsible for redrawing the display in response to the redraw requests by
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 88
98 // Does work necessary for adding the first surface reference. 89 // Does work necessary for adding the first surface reference.
99 void AddFirstReference(const cc::SurfaceId& surface_id, ServerWindow* window); 90 void AddFirstReference(const cc::SurfaceId& surface_id, ServerWindow* window);
100 91
101 // Finds all Surfaces with references from |old_surface_id| and adds a new 92 // Finds all Surfaces with references from |old_surface_id| and adds a new
102 // reference from |new_surface_id|. The caller should remove any references 93 // reference from |new_surface_id|. The caller should remove any references
103 // to |old_surface_id| afterwards to finish cleanup. 94 // to |old_surface_id| afterwards to finish cleanup.
104 void AddNewParentReferences(const cc::SurfaceId& old_surface_id, 95 void AddNewParentReferences(const cc::SurfaceId& old_surface_id,
105 const cc::SurfaceId& new_surface_id); 96 const cc::SurfaceId& new_surface_id);
106 97
98 // Adds all references to surfaces in |new_references_|.
99 void SendAddSurfaceReferences();
100
107 // Removes all references to surfaces in |dead_references_|. 101 // Removes all references to surfaces in |dead_references_|.
108 void RemoveDeadSurfaceReferences(); 102 void SendRemoveSurfaceReferences();
109 103
110 // Removes any retained references for the provided FrameSink. 104 // Removes any retained references for the provided FrameSink.
111 void RemoveFrameSinkReference(const cc::FrameSinkId& frame_sink_id); 105 void RemoveFrameSinkReference(const cc::FrameSinkId& frame_sink_id);
112 106
113 // Removes all retained references to surfaces. 107 // Removes all retained references to surfaces.
114 void RemoveAllSurfaceReferences(); 108 void RemoveAllSurfaceReferences();
115 109
116 cc::mojom::DisplayCompositor* GetDisplayCompositor();
117
118 // ServerWindowObserver implementation. 110 // ServerWindowObserver implementation.
119 void OnWindowDestroying(ServerWindow* window) override; 111 void OnWindowDestroying(ServerWindow* window) override;
120 112
121 FrameGeneratorDelegate* delegate_; 113 FrameGeneratorDelegate* delegate_;
122 ServerWindow* const root_window_; 114 ServerWindow* const root_window_;
123 115
124 gfx::Size last_submitted_frame_size_; 116 gfx::Size last_submitted_frame_size_;
125 cc::LocalFrameId local_frame_id_; 117 cc::LocalFrameId local_frame_id_;
126 cc::SurfaceIdAllocator id_allocator_; 118 cc::SurfaceIdAllocator id_allocator_;
127 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_; 119 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_;
128 120
129 // Represents the top level root surface id that should reference the display
130 // root surface. We don't know the actual value, because it's generated in
131 // another process, this is used internally as a placeholder.
132 const cc::SurfaceId top_level_root_surface_id_;
133
134 struct SurfaceReference {
135 cc::SurfaceId parent_id;
136 cc::SurfaceId child_id;
137 };
138
139 // Active references held by this client to surfaces that could be embedded in 121 // Active references held by this client to surfaces that could be embedded in
140 // a CompositorFrame submitted from FrameGenerator. 122 // a CompositorFrame submitted from FrameGenerator.
141 std::unordered_map<cc::FrameSinkId, SurfaceReference, cc::FrameSinkIdHash> 123 std::unordered_map<cc::FrameSinkId, cc::SurfaceReference, cc::FrameSinkIdHash>
142 active_references_; 124 active_references_;
143 125
144 // References to surfaces that should be removed after a CompositorFrame has 126 // References to surfaces that should be removed after a CompositorFrame has
145 // been submitted and the surfaces are not being used. 127 // been submitted and the surfaces are not being used.
146 std::vector<SurfaceReference> dead_references_; 128 std::vector<cc::SurfaceReference> dead_references_;
129
130 // References that should be added before the next CompositorFrame is
131 // submitted.
132 std::vector<cc::SurfaceReference> new_references_;
147 133
148 // If a CompositorFrame for a child surface is submitted before the first 134 // If a CompositorFrame for a child surface is submitted before the first
149 // display root CompositorFrame, we can't add a reference from the unknown 135 // display root CompositorFrame, we can't add a reference from the unknown
150 // display root SurfaceId. Track the child SurfaceId here and add a reference 136 // display root SurfaceId. Track the child SurfaceId here and add a reference
151 // to it when the display root SurfaceId is available. 137 // to it when the display root SurfaceId is available.
152 std::vector<cc::SurfaceId> waiting_for_references_; 138 std::vector<cc::SurfaceId> waiting_for_references_;
153 139
154 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_; 140 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_;
155 141
156 base::WeakPtrFactory<FrameGenerator> weak_factory_; 142 base::WeakPtrFactory<FrameGenerator> weak_factory_;
157 143
158 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); 144 DISALLOW_COPY_AND_ASSIGN(FrameGenerator);
159 }; 145 };
160 146
161 } // namespace ws 147 } // namespace ws
162 148
163 } // namespace ui 149 } // namespace ui
164 150
165 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ 151 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698