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