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

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

Issue 2471503002: Mus+Ash: Unify CompositorFrameSinks (Closed)
Patch Set: Added comment Created 4 years, 1 month 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 10
(...skipping 30 matching lines...) Expand all
41 namespace test { 41 namespace test {
42 class FrameGeneratorTest; 42 class FrameGeneratorTest;
43 } 43 }
44 44
45 class FrameGeneratorDelegate; 45 class FrameGeneratorDelegate;
46 class ServerWindow; 46 class ServerWindow;
47 class ServerWindowCompositorFrameSink; 47 class ServerWindowCompositorFrameSink;
48 48
49 // Responsible for redrawing the display in response to the redraw requests by 49 // Responsible for redrawing the display in response to the redraw requests by
50 // submitting CompositorFrames to the owned CompositorFrameSink. 50 // submitting CompositorFrames to the owned CompositorFrameSink.
51 class FrameGenerator : public ServerWindowTracker { 51 class FrameGenerator : public ServerWindowTracker,
52 public cc::mojom::MojoCompositorFrameSinkClient {
52 public: 53 public:
53 FrameGenerator(FrameGeneratorDelegate* delegate, 54 FrameGenerator(FrameGeneratorDelegate* delegate,
54 ServerWindow* root_window, 55 ServerWindow* root_window,
55 scoped_refptr<DisplayCompositor> display_compositor); 56 scoped_refptr<DisplayCompositor> display_compositor);
56 ~FrameGenerator() override; 57 ~FrameGenerator() override;
57 58
58 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel); 59 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel);
59 60
60 // Schedules a redraw for the provided region. 61 // Schedules a redraw for the provided region.
61 void RequestRedraw(const gfx::Rect& redraw_region); 62 void RequestRedraw(const gfx::Rect& redraw_region);
62 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); 63 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget);
63 64
64 bool is_frame_pending() { return frame_pending_; } 65 bool is_frame_pending() { return frame_pending_; }
65 66
66 private: 67 private:
67 friend class ui::ws::test::FrameGeneratorTest; 68 friend class ui::ws::test::FrameGeneratorTest;
68 69
70 // cc::mojom::MojoCompositorFrameSinkClient implementation:
71 void DidReceiveCompositorFrameAck() override;
72 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
73
69 void WantToDraw(); 74 void WantToDraw();
70 75
71 // This method initiates a top level redraw of the display. 76 // This method initiates a top level redraw of the display.
72 // TODO(fsamuel): In polliwog, this only gets called when the window manager 77 // TODO(fsamuel): In polliwog, this only gets called when the window manager
73 // changes. 78 // changes.
74 void Draw(); 79 void Draw();
75 80
76 // This is called after the CompositorFrameSink has completed generating a new
77 // frame for the display.
78 void DidDraw();
79
80 // Generates the CompositorFrame for the current |dirty_rect_|. 81 // Generates the CompositorFrame for the current |dirty_rect_|.
81 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); 82 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect);
82 83
83 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad 84 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad
84 // for each that lacks one. 85 // for each that lacks one.
85 void DrawWindowTree(cc::RenderPass* pass, 86 void DrawWindowTree(cc::RenderPass* pass,
86 ServerWindow* window, 87 ServerWindow* window,
87 const gfx::Vector2d& parent_to_root_origin_offset, 88 const gfx::Vector2d& parent_to_root_origin_offset,
88 float opacity); 89 float opacity);
89 90
(...skipping 18 matching lines...) Expand all
108 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime 109 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime
109 // management. 110 // management.
110 void ReleaseAllSurfaceReferences(); 111 void ReleaseAllSurfaceReferences();
111 112
112 // ServerWindowObserver implementation. 113 // ServerWindowObserver implementation.
113 void OnWindowDestroying(ServerWindow* window) override; 114 void OnWindowDestroying(ServerWindow* window) override;
114 115
115 FrameGeneratorDelegate* delegate_; 116 FrameGeneratorDelegate* delegate_;
116 scoped_refptr<DisplayCompositor> display_compositor_; 117 scoped_refptr<DisplayCompositor> display_compositor_;
117 cc::FrameSinkId frame_sink_id_; 118 cc::FrameSinkId frame_sink_id_;
119 ServerWindow* const root_window_;
118 cc::SurfaceSequenceGenerator surface_sequence_generator_; 120 cc::SurfaceSequenceGenerator surface_sequence_generator_;
119 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; 121 scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
120 122
121 std::unique_ptr<DisplayCompositorFrameSink> compositor_frame_sink_; 123 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_;
122 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; 124 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
123 125
124 // The region that needs to be redrawn next time the compositor frame is 126 // The region that needs to be redrawn next time the compositor frame is
125 // generated. 127 // generated.
126 gfx::Rect dirty_rect_; 128 gfx::Rect dirty_rect_;
127 base::Timer draw_timer_; 129 base::Timer draw_timer_;
128 bool frame_pending_ = false; 130 bool frame_pending_ = false;
129 struct SurfaceDependency { 131 struct SurfaceDependency {
130 cc::LocalFrameId local_frame_id; 132 cc::LocalFrameId local_frame_id;
131 cc::SurfaceSequence sequence; 133 cc::SurfaceSequence sequence;
132 }; 134 };
133 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> 135 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash>
134 dependencies_; 136 dependencies_;
135 137
138 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_;
139
136 base::WeakPtrFactory<FrameGenerator> weak_factory_; 140 base::WeakPtrFactory<FrameGenerator> weak_factory_;
137 141
138 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); 142 DISALLOW_COPY_AND_ASSIGN(FrameGenerator);
139 }; 143 };
140 144
141 } // namespace ws 145 } // namespace ws
142 146
143 } // namespace ui 147 } // namespace ui
144 148
145 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ 149 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698