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

Side by Side Diff: services/ui/surfaces/display_compositor.h

Issue 2481263002: Introduce Display Compositor mojo interface. Use InProcessContextProvider. (Closed)
Patch Set: Make ContextProvider NON_EXPORTED_BASE of InProcessContextProvider 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
OLDNEW
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_SURFACES_DISPLAY_COMPOSITOR_H_ 5 #ifndef SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ 6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "cc/ipc/display_compositor.mojom.h" 11 #include "cc/ipc/display_compositor.mojom.h"
13 #include "cc/surfaces/surface_manager.h" 12 #include "cc/surfaces/surface_manager.h"
14 #include "cc/surfaces/surface_observer.h" 13 #include "cc/surfaces/surface_observer.h"
14 #include "gpu/ipc/common/surface_handle.h"
15 #include "gpu/ipc/in_process_command_buffer.h"
16 #include "ipc/ipc_channel_handle.h"
17 #include "services/ui/surfaces/mus_gpu_memory_buffer_manager.h"
18
19 namespace gpu {
20 class ImageFactory;
21 }
15 22
16 namespace cc { 23 namespace cc {
17 class SurfaceHittest; 24 class SurfaceHittest;
18 class SurfaceManager; 25 class SurfaceManager;
19 } // namespace cc 26 } // namespace cc
20 27
21 namespace ui { 28 namespace ui {
22 29
23 class DisplayCompositorClient; 30 class DisplayCompositorClient;
31 class GpuCompositorFrameSink;
32 class MusGpuMemoryBufferManager;
24 33
25 // The DisplayCompositor object is an object global to the Window Server app 34 // The DisplayCompositor object is an object global to the Window Server app
26 // that holds the SurfaceServer and allocates new Surfaces namespaces. 35 // that holds the SurfaceServer and allocates new Surfaces namespaces.
27 // This object lives on the main thread of the Window Server. 36 // This object lives on the main thread of the Window Server.
28 // TODO(rjkroege, fsamuel): This object will need to change to support multiple 37 // TODO(rjkroege, fsamuel): This object will need to change to support multiple
29 // displays. 38 // displays.
30 class DisplayCompositor : public cc::SurfaceObserver, 39 class DisplayCompositor : public cc::SurfaceObserver,
31 public base::RefCounted<DisplayCompositor> { 40 public cc::mojom::DisplayCompositor {
32 public: 41 public:
33 explicit DisplayCompositor(cc::mojom::DisplayCompositorClientPtr client); 42 DisplayCompositor(
43 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
44 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager,
45 gpu::ImageFactory* image_factory,
46 cc::mojom::DisplayCompositorClientPtr client);
47 ~DisplayCompositor() override;
34 48
35 // TODO(fsamuel): These methods should be behind a mojo interface. 49 // cc::mojom::DisplayCompositor implementation:
36 void AddSurfaceReference(const cc::SurfaceId& surface_id, 50 void CreateCompositorFrameSink(
37 const cc::SurfaceSequence& surface_sequence); 51 const cc::FrameSinkId& frame_sink_id,
52 gpu::SurfaceHandle surface_handle,
53 cc::mojom::MojoCompositorFrameSinkRequest request,
54 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
55 cc::mojom::MojoCompositorFrameSinkClientPtr client) override;
56 void AddSurfaceReference(
57 const cc::SurfaceId& surface_id,
58 const cc::SurfaceSequence& surface_sequence) override;
38 void ReturnSurfaceReferences(const cc::FrameSinkId& frame_sink_id, 59 void ReturnSurfaceReferences(const cc::FrameSinkId& frame_sink_id,
39 const std::vector<uint32_t>& sequences); 60 const std::vector<uint32_t>& sequences) override;
40 61
41 cc::SurfaceManager* manager() { return &manager_; } 62 cc::SurfaceManager* manager() { return &manager_; }
42 63
64 // We must avoid destroying a GpuCompositorFrameSink until both the display
65 // compositor host and the client drop their connection to avoid getting into
66 // a state where surfaces references are inconsistent.
67 void OnCompositorFrameSinkClientConnectionLost(
68 const cc::FrameSinkId& frame_sink_id,
69 bool destroy_compositor_frame_sink);
70 void OnCompositorFrameSinkPrivateConnectionLost(
71 const cc::FrameSinkId& frame_sink_id,
72 bool destroy_compositor_frame_sink);
73
43 private: 74 private:
44 friend class base::RefCounted<DisplayCompositor>;
45 virtual ~DisplayCompositor();
46 75
47 // cc::SurfaceObserver implementation. 76 // cc::SurfaceObserver implementation.
48 void OnSurfaceCreated(const cc::SurfaceId& surface_id, 77 void OnSurfaceCreated(const cc::SurfaceId& surface_id,
49 const gfx::Size& frame_size, 78 const gfx::Size& frame_size,
50 float device_scale_factor) override; 79 float device_scale_factor) override;
51 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, 80 void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
52 bool* changed) override; 81 bool* changed) override;
53 82
83 std::unordered_map<cc::FrameSinkId,
84 std::unique_ptr<GpuCompositorFrameSink>,
85 cc::FrameSinkIdHash>
86 compositor_frame_sinks_;
87 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_;
88 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_;
89 gpu::ImageFactory* image_factory_;
54 cc::mojom::DisplayCompositorClientPtr client_; 90 cc::mojom::DisplayCompositorClientPtr client_;
55 cc::SurfaceManager manager_; 91 cc::SurfaceManager manager_;
56 92
57 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); 93 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor);
58 }; 94 };
59 95
60 } // namespace ui 96 } // namespace ui
61 97
62 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ 98 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698