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

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

Issue 2481263002: Introduce Display Compositor mojo interface. Use InProcessContextProvider. (Closed)
Patch Set: Speculative fix for android build issue 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/frame_sink_id.h" 12 #include "cc/surfaces/frame_sink_id.h"
14 #include "cc/surfaces/local_frame_id.h" 13 #include "cc/surfaces/local_frame_id.h"
15 #include "cc/surfaces/surface_id.h" 14 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_manager.h" 15 #include "cc/surfaces/surface_manager.h"
17 #include "cc/surfaces/surface_observer.h" 16 #include "cc/surfaces/surface_observer.h"
17 #include "gpu/ipc/common/surface_handle.h"
18 #include "gpu/ipc/in_process_command_buffer.h"
19 #include "ipc/ipc_channel_handle.h"
20 #include "services/ui/surfaces/mus_gpu_memory_buffer_manager.h"
21
22 namespace gpu {
23 class ImageFactory;
24 }
18 25
19 namespace cc { 26 namespace cc {
20 class SurfaceHittest; 27 class SurfaceHittest;
21 class SurfaceManager; 28 class SurfaceManager;
22 } // namespace cc 29 } // namespace cc
23 30
24 namespace ui { 31 namespace ui {
25 32
26 class DisplayCompositorClient; 33 class DisplayCompositorClient;
34 class GpuCompositorFrameSink;
35 class MusGpuMemoryBufferManager;
27 36
28 // The DisplayCompositor object is an object global to the Window Server app 37 // The DisplayCompositor object is an object global to the Window Server app
29 // that holds the SurfaceServer and allocates new Surfaces namespaces. 38 // that holds the SurfaceServer and allocates new Surfaces namespaces.
30 // This object lives on the main thread of the Window Server. 39 // This object lives on the main thread of the Window Server.
31 // TODO(rjkroege, fsamuel): This object will need to change to support multiple 40 // TODO(rjkroege, fsamuel): This object will need to change to support multiple
32 // displays. 41 // displays.
33 class DisplayCompositor : public cc::SurfaceObserver, 42 class DisplayCompositor : public cc::SurfaceObserver,
34 public base::RefCounted<DisplayCompositor> { 43 public cc::mojom::DisplayCompositor {
35 public: 44 public:
36 explicit DisplayCompositor(cc::mojom::DisplayCompositorClientPtr client); 45 DisplayCompositor(
46 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
47 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager,
48 gpu::ImageFactory* image_factory,
49 cc::mojom::DisplayCompositorClientPtr client);
50 ~DisplayCompositor() override;
37 51
38 // TODO(fsamuel): These methods should be behind a mojo interface. 52 // cc::mojom::DisplayCompositor implementation:
39 void AddRootSurfaceReference(const cc::SurfaceId& child_id); 53 void CreateCompositorFrameSink(
54 const cc::FrameSinkId& frame_sink_id,
55 gpu::SurfaceHandle surface_handle,
56 cc::mojom::MojoCompositorFrameSinkRequest request,
57 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
58 cc::mojom::MojoCompositorFrameSinkClientPtr client) override;
59 void AddRootSurfaceReference(const cc::SurfaceId& child_id) override;
40 void AddSurfaceReference(const cc::SurfaceId& parent_id, 60 void AddSurfaceReference(const cc::SurfaceId& parent_id,
41 const cc::SurfaceId& child_id); 61 const cc::SurfaceId& child_id) override;
42 void RemoveRootSurfaceReference(const cc::SurfaceId& child_id); 62 void RemoveRootSurfaceReference(const cc::SurfaceId& child_id) override;
43 void RemoveSurfaceReference(const cc::SurfaceId& parent_id, 63 void RemoveSurfaceReference(const cc::SurfaceId& parent_id,
44 const cc::SurfaceId& child_id); 64 const cc::SurfaceId& child_id) override;
45 65
46 cc::SurfaceManager* manager() { return &manager_; } 66 cc::SurfaceManager* manager() { return &manager_; }
47 67
68 // We must avoid destroying a GpuCompositorFrameSink until both the display
69 // compositor host and the client drop their connection to avoid getting into
70 // a state where surfaces references are inconsistent.
71 void OnCompositorFrameSinkClientConnectionLost(
72 const cc::FrameSinkId& frame_sink_id,
73 bool destroy_compositor_frame_sink);
74 void OnCompositorFrameSinkPrivateConnectionLost(
75 const cc::FrameSinkId& frame_sink_id,
76 bool destroy_compositor_frame_sink);
77
48 private: 78 private:
49 friend class base::RefCounted<DisplayCompositor>;
50 virtual ~DisplayCompositor();
51 79
52 // cc::SurfaceObserver implementation. 80 // cc::SurfaceObserver implementation.
53 void OnSurfaceCreated(const cc::SurfaceId& surface_id, 81 void OnSurfaceCreated(const cc::SurfaceId& surface_id,
54 const gfx::Size& frame_size, 82 const gfx::Size& frame_size,
55 float device_scale_factor) override; 83 float device_scale_factor) override;
56 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, 84 void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
57 bool* changed) override; 85 bool* changed) override;
58 86
87 std::unordered_map<cc::FrameSinkId,
88 std::unique_ptr<GpuCompositorFrameSink>,
89 cc::FrameSinkIdHash>
90 compositor_frame_sinks_;
91 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_;
92 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_;
93 gpu::ImageFactory* image_factory_;
59 cc::mojom::DisplayCompositorClientPtr client_; 94 cc::mojom::DisplayCompositorClientPtr client_;
60 cc::SurfaceManager manager_; 95 cc::SurfaceManager manager_;
61 96
62 // SurfaceIds that have temporary references from top level root so they 97 // SurfaceIds that have temporary references from top level root so they
63 // aren't GC'd before DisplayCompositorClient can add a real reference. This 98 // aren't GC'd before DisplayCompositorClient can add a real reference. This
64 // is basically a collection of surface ids, for example: 99 // is basically a collection of surface ids, for example:
65 // cc::SurfaceId surface_id(key, value[index]); 100 // cc::SurfaceId surface_id(key, value[index]);
66 // The LocalFrameIds are stored in the order the surfaces are created in. 101 // The LocalFrameIds are stored in the order the surfaces are created in.
67 std::unordered_map<cc::FrameSinkId, 102 std::unordered_map<cc::FrameSinkId,
68 std::vector<cc::LocalFrameId>, 103 std::vector<cc::LocalFrameId>,
69 cc::FrameSinkIdHash> 104 cc::FrameSinkIdHash>
70 temp_references_; 105 temp_references_;
71 106
72 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); 107 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor);
73 }; 108 };
74 109
75 } // namespace ui 110 } // namespace ui
76 111
77 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ 112 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698