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