OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_SERVER_WINDOW_SURFACE_H_ | 5 #ifndef SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ |
6 #define SERVICES_UI_WS_SERVER_WINDOW_SURFACE_H_ | 6 #define SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "cc/ipc/compositor_frame.mojom.h" | 11 #include "cc/ipc/compositor_frame.mojom.h" |
12 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | 12 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
13 #include "cc/surfaces/frame_sink_id.h" | 13 #include "cc/surfaces/frame_sink_id.h" |
14 #include "cc/surfaces/surface_factory.h" | 14 #include "cc/surfaces/surface_factory.h" |
15 #include "cc/surfaces/surface_factory_client.h" | 15 #include "cc/surfaces/surface_factory_client.h" |
16 #include "cc/surfaces/surface_id.h" | 16 #include "cc/surfaces/surface_id.h" |
17 #include "cc/surfaces/surface_id_allocator.h" | 17 #include "cc/surfaces/surface_id_allocator.h" |
18 #include "cc/surfaces/surface_sequence_generator.h" | 18 #include "cc/surfaces/surface_sequence_generator.h" |
19 #include "mojo/public/cpp/bindings/binding.h" | 19 #include "mojo/public/cpp/bindings/binding.h" |
20 #include "services/ui/public/interfaces/window_tree.mojom.h" | 20 #include "services/ui/public/interfaces/window_tree.mojom.h" |
21 #include "services/ui/ws/ids.h" | 21 #include "services/ui/ws/ids.h" |
22 | 22 |
23 namespace ui { | 23 namespace ui { |
24 | 24 |
25 class DisplayCompositor; | 25 class DisplayCompositor; |
26 | 26 |
27 namespace ws { | 27 namespace ws { |
28 | 28 |
29 class ServerWindow; | 29 class ServerWindow; |
30 class ServerWindowSurfaceManager; | 30 class ServerWindowCompositorFrameSinkManager; |
31 | 31 |
32 // Server side representation of a WindowSurface. | 32 // Server side representation of a WindowSurface. |
33 class ServerWindowSurface : public cc::mojom::MojoCompositorFrameSink, | 33 class ServerWindowCompositorFrameSink |
34 public cc::SurfaceFactoryClient { | 34 : public cc::mojom::MojoCompositorFrameSink, |
| 35 public cc::SurfaceFactoryClient { |
35 public: | 36 public: |
36 ServerWindowSurface(ServerWindowSurfaceManager* manager, | 37 ServerWindowCompositorFrameSink( |
37 const cc::FrameSinkId& frame_sink_id, | 38 ServerWindowCompositorFrameSinkManager* manager, |
38 cc::mojom::MojoCompositorFrameSinkRequest request, | 39 const cc::FrameSinkId& frame_sink_id, |
39 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 40 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 41 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
40 | 42 |
41 ~ServerWindowSurface() override; | 43 ~ServerWindowCompositorFrameSink() override; |
42 | 44 |
43 const gfx::Size& last_submitted_frame_size() const { | 45 const gfx::Size& last_submitted_frame_size() const { |
44 return last_submitted_frame_size_; | 46 return last_submitted_frame_size_; |
45 } | 47 } |
46 | 48 |
47 bool may_contain_video() const { return may_contain_video_; } | 49 bool may_contain_video() const { return may_contain_video_; } |
48 | 50 |
49 // cc::mojom::MojoCompositorFrameSink: | 51 // cc::mojom::MojoCompositorFrameSink: |
50 void SetNeedsBeginFrame(bool needs_begin_frame) override; | 52 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
51 void SubmitCompositorFrame(cc::CompositorFrame frame) override; | 53 void SubmitCompositorFrame(cc::CompositorFrame frame) override; |
52 | 54 |
53 // There is a 1-1 correspondence between FrameSinks and frame sources. | 55 // There is a 1-1 correspondence between FrameSinks and frame sources. |
54 // The FrameSinkId uniquely identifies the FrameSink, and since there is | 56 // The FrameSinkId uniquely identifies the FrameSink, and since there is |
55 // one FrameSink per ServerWindowSurface, it allows the window server | 57 // one FrameSink per ServerWindowCompositorFrameSink, it allows the window |
56 // to uniquely identify the window, and the thus the client that generated the | 58 // server to uniquely identify the window, and the thus the client that |
57 // frame. | 59 // generated the frame. |
58 const cc::FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 60 const cc::FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
59 | 61 |
60 // The LocalFrameId can be thought of as an identifier to a bucket of | 62 // The LocalFrameId can be thought of as an identifier to a bucket of |
61 // sequentially submitted CompositorFrames in the same FrameSink all sharing | 63 // sequentially submitted CompositorFrames in the same FrameSink all sharing |
62 // the same size and device scale factor. | 64 // the same size and device scale factor. |
63 const cc::LocalFrameId& local_frame_id() const { return local_frame_id_; } | 65 const cc::LocalFrameId& local_frame_id() const { return local_frame_id_; } |
64 | 66 |
65 bool has_frame() const { return !local_frame_id_.is_null(); } | 67 bool has_frame() const { return !local_frame_id_.is_null(); } |
66 | 68 |
67 cc::SurfaceId GetSurfaceId() const; | 69 cc::SurfaceId GetSurfaceId() const; |
68 | 70 |
69 // Creates a surface dependency token that expires when this | 71 // Creates a surface dependency token that expires when this |
70 // ServerWindowSurface goes away. | 72 // ServerWindowCompositorFrameSink goes away. |
71 cc::SurfaceSequence CreateSurfaceSequence(); | 73 cc::SurfaceSequence CreateSurfaceSequence(); |
72 | 74 |
73 ServerWindow* window(); | 75 ServerWindow* window(); |
74 | 76 |
75 private: | 77 private: |
76 void DidReceiveCompositorFrameAck(); | 78 void DidReceiveCompositorFrameAck(); |
77 | 79 |
78 // SurfaceFactoryClient implementation. | 80 // SurfaceFactoryClient implementation. |
79 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 81 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
80 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 82 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
81 | 83 |
82 const cc::FrameSinkId frame_sink_id_; | 84 const cc::FrameSinkId frame_sink_id_; |
83 cc::SurfaceSequenceGenerator surface_sequence_generator_; | 85 cc::SurfaceSequenceGenerator surface_sequence_generator_; |
84 | 86 |
85 ServerWindowSurfaceManager* manager_; // Owns this. | 87 ServerWindowCompositorFrameSinkManager* manager_; // Owns this. |
86 | 88 |
87 gfx::Size last_submitted_frame_size_; | 89 gfx::Size last_submitted_frame_size_; |
88 | 90 |
89 cc::LocalFrameId local_frame_id_; | 91 cc::LocalFrameId local_frame_id_; |
90 cc::SurfaceIdAllocator surface_id_allocator_; | 92 cc::SurfaceIdAllocator surface_id_allocator_; |
91 cc::SurfaceFactory surface_factory_; | 93 cc::SurfaceFactory surface_factory_; |
92 | 94 |
93 cc::mojom::MojoCompositorFrameSinkClientPtr client_; | 95 cc::mojom::MojoCompositorFrameSinkClientPtr client_; |
94 mojo::Binding<MojoCompositorFrameSink> binding_; | 96 mojo::Binding<MojoCompositorFrameSink> binding_; |
95 | 97 |
96 bool may_contain_video_ = false; | 98 bool may_contain_video_ = false; |
97 | 99 |
98 DISALLOW_COPY_AND_ASSIGN(ServerWindowSurface); | 100 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSink); |
99 }; | 101 }; |
100 | 102 |
101 } // namespace ws | 103 } // namespace ws |
102 | 104 |
103 } // namespace ui | 105 } // namespace ui |
104 | 106 |
105 #endif // SERVICES_UI_WS_SERVER_WINDOW_SURFACE_H_ | 107 #endif // SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ |
OLD | NEW |