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

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

Issue 2541683004: Add/remove surface references via MojoCompositorFrameSink. (Closed)
Patch Set: Cleanup. 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
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.cc ('k') | services/ui/ws/frame_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/timer/timer.h"
13 #include "cc/ipc/display_compositor.mojom.h" 14 #include "cc/ipc/display_compositor.mojom.h"
14 #include "cc/surfaces/frame_sink_id.h" 15 #include "cc/surfaces/frame_sink_id.h"
15 #include "cc/surfaces/surface_id.h" 16 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_id_allocator.h" 17 #include "cc/surfaces/surface_id_allocator.h"
18 #include "cc/surfaces/surface_reference.h"
17 #include "services/ui/public/interfaces/window_tree_constants.mojom.h" 19 #include "services/ui/public/interfaces/window_tree_constants.mojom.h"
18 #include "services/ui/ws/ids.h" 20 #include "services/ui/ws/ids.h"
19 #include "services/ui/ws/server_window_delegate.h" 21 #include "services/ui/ws/server_window_delegate.h"
20 #include "services/ui/ws/server_window_tracker.h" 22 #include "services/ui/ws/server_window_tracker.h"
21 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
22 #include "ui/gfx/native_widget_types.h" 24 #include "ui/gfx/native_widget_types.h"
23 25
24 namespace cc { 26 namespace cc {
25 class CompositorFrame;
26 class RenderPass; 27 class RenderPass;
27 class SurfaceId; 28 class SurfaceId;
28 } 29 }
29 30
30 namespace ui { 31 namespace ui {
31
32 class DisplayCompositor;
33
34 namespace ws { 32 namespace ws {
35 33
36 namespace test { 34 namespace test {
37 class FrameGeneratorTest; 35 class FrameGeneratorTest;
38 } 36 }
39 37
40 class FrameGeneratorDelegate; 38 class FrameGeneratorDelegate;
41 class ServerWindow; 39 class ServerWindow;
42 40
43 // Responsible for redrawing the display in response to the redraw requests by 41 // Responsible for redrawing the display in response to the redraw requests by
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 92
95 // Does work necessary for adding the first surface reference. 93 // Does work necessary for adding the first surface reference.
96 void AddFirstReference(const cc::SurfaceId& surface_id, ServerWindow* window); 94 void AddFirstReference(const cc::SurfaceId& surface_id, ServerWindow* window);
97 95
98 // Finds all Surfaces with references from |old_surface_id| and adds a new 96 // Finds all Surfaces with references from |old_surface_id| and adds a new
99 // reference from |new_surface_id|. The caller should remove any references 97 // reference from |new_surface_id|. The caller should remove any references
100 // to |old_surface_id| afterwards to finish cleanup. 98 // to |old_surface_id| afterwards to finish cleanup.
101 void AddNewParentReferences(const cc::SurfaceId& old_surface_id, 99 void AddNewParentReferences(const cc::SurfaceId& old_surface_id,
102 const cc::SurfaceId& new_surface_id); 100 const cc::SurfaceId& new_surface_id);
103 101
104 // Removes all references to surfaces in |dead_references_|. 102 // Sends IPC to add references in |references_to_add_|.
105 void RemoveDeadSurfaceReferences(); 103 void PerformAddSurfaceReferences();
106 104
107 // Removes any retained references for the provided FrameSink. 105 // Sends IPC to remove all references in |references_to_remove_|.
106 void PerformRemoveSurfaceReferences();
107
108 // Removes any retained references for |frame_sink_id_|.
108 void RemoveFrameSinkReference(const cc::FrameSinkId& frame_sink_id); 109 void RemoveFrameSinkReference(const cc::FrameSinkId& frame_sink_id);
109 110
110 // Removes all retained references to surfaces. 111 // Removes all retained references to surfaces.
111 void RemoveAllSurfaceReferences(); 112 void RemoveAllSurfaceReferences();
112 113
113 cc::mojom::DisplayCompositor* GetDisplayCompositor(); 114 cc::mojom::DisplayCompositor* GetDisplayCompositor();
114 115
115 // ServerWindowObserver implementation. 116 // ServerWindowObserver implementation.
116 void OnWindowDestroying(ServerWindow* window) override; 117 void OnWindowDestroying(ServerWindow* window) override;
117 118
118 FrameGeneratorDelegate* delegate_; 119 FrameGeneratorDelegate* delegate_;
119 ServerWindow* const root_window_; 120 ServerWindow* const root_window_;
120 121
121 gfx::Size last_submitted_frame_size_; 122 gfx::Size last_submitted_frame_size_;
122 cc::LocalFrameId local_frame_id_; 123 cc::LocalFrameId local_frame_id_;
123 cc::SurfaceIdAllocator id_allocator_; 124 cc::SurfaceIdAllocator id_allocator_;
124 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_; 125 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_;
125 126
126 // Represents the top level root surface id that should reference the display
127 // root surface. We don't know the actual value, because it's generated in
128 // another process, this is used internally as a placeholder.
129 const cc::SurfaceId top_level_root_surface_id_;
130
131 struct SurfaceReference {
132 cc::SurfaceId parent_id;
133 cc::SurfaceId child_id;
134 };
135
136 // Active references held by this client to surfaces that could be embedded in 127 // Active references held by this client to surfaces that could be embedded in
137 // a CompositorFrame submitted from FrameGenerator. 128 // a CompositorFrame submitted from FrameGenerator.
138 std::unordered_map<cc::FrameSinkId, SurfaceReference, cc::FrameSinkIdHash> 129 std::unordered_map<cc::FrameSinkId, cc::SurfaceReference, cc::FrameSinkIdHash>
139 active_references_; 130 active_references_;
140 131
141 // References to surfaces that should be removed after a CompositorFrame has 132 // References to surfaces that should be removed after a CompositorFrame has
142 // been submitted and the surfaces are not being used. 133 // been submitted and the surfaces are not being used.
143 std::vector<SurfaceReference> dead_references_; 134 std::vector<cc::SurfaceReference> references_to_remove_;
135
136 // References that should be added before the next CompositorFrame is
137 // submitted.
138 std::vector<cc::SurfaceReference> references_to_add_;
144 139
145 // If a CompositorFrame for a child surface is submitted before the first 140 // If a CompositorFrame for a child surface is submitted before the first
146 // display root CompositorFrame, we can't add a reference from the unknown 141 // display root CompositorFrame, we can't add a reference from the unknown
147 // display root SurfaceId. Track the child SurfaceId here and add a reference 142 // display root SurfaceId. Track the child SurfaceId here and add a reference
148 // to it when the display root SurfaceId is available. 143 // to it when the display root SurfaceId is available.
149 std::vector<cc::SurfaceId> waiting_for_references_; 144 std::vector<cc::SurfaceId> waiting_for_references_;
150 145
151 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_; 146 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_;
152 147
153 base::WeakPtrFactory<FrameGenerator> weak_factory_; 148 base::WeakPtrFactory<FrameGenerator> weak_factory_;
154 149
155 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); 150 DISALLOW_COPY_AND_ASSIGN(FrameGenerator);
156 }; 151 };
157 152
158 } // namespace ws 153 } // namespace ws
159 154
160 } // namespace ui 155 } // namespace ui
161 156
162 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ 157 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_
OLDNEW
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.cc ('k') | services/ui/ws/frame_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698