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

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

Issue 2520513002: Add DisplayCompositorTest. (Closed)
Patch Set: Add non-exported base. 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
« no previous file with comments | « cc/surfaces/surface_reference_manager.h ('k') | services/ui/surfaces/display_compositor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory>
11 #include <unordered_map>
12 #include <vector>
13
10 #include "base/macros.h" 14 #include "base/macros.h"
11 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
12 #include "cc/ipc/display_compositor.mojom.h" 16 #include "cc/ipc/display_compositor.mojom.h"
13 #include "cc/surfaces/frame_sink_id.h" 17 #include "cc/surfaces/frame_sink_id.h"
14 #include "cc/surfaces/local_frame_id.h" 18 #include "cc/surfaces/local_frame_id.h"
15 #include "cc/surfaces/surface_id.h" 19 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_manager.h" 20 #include "cc/surfaces/surface_manager.h"
17 #include "cc/surfaces/surface_observer.h" 21 #include "cc/surfaces/surface_observer.h"
18 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 22 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
19 #include "gpu/ipc/common/surface_handle.h" 23 #include "gpu/ipc/common/surface_handle.h"
20 #include "gpu/ipc/in_process_command_buffer.h" 24 #include "gpu/ipc/in_process_command_buffer.h"
21 #include "ipc/ipc_channel_handle.h" 25 #include "ipc/ipc_channel_handle.h"
22 #include "mojo/public/cpp/bindings/binding.h" 26 #include "mojo/public/cpp/bindings/binding.h"
23 #include "services/ui/common/mus_gpu_memory_buffer_manager.h" 27 #include "services/ui/common/mus_gpu_memory_buffer_manager.h"
24 28
25 namespace gpu { 29 namespace gpu {
26 class GpuMemoryBufferManager; 30 class GpuMemoryBufferManager;
27 class ImageFactory; 31 class ImageFactory;
28 } 32 }
29 33
30 namespace cc { 34 namespace cc {
31 class SurfaceHittest; 35 class SurfaceHittest;
32 class SurfaceManager; 36 class SurfaceManager;
33 } // namespace cc 37 } // namespace cc
34 38
35 namespace ui { 39 namespace ui {
36 40
41 namespace test {
42 class DisplayCompositorTest;
43 }
44
37 class DisplayCompositorClient; 45 class DisplayCompositorClient;
38 class GpuCompositorFrameSink; 46 class GpuCompositorFrameSink;
39 47
40 // The DisplayCompositor object is an object global to the Window Server app 48 // The DisplayCompositor object is an object global to the Window Server app
41 // that holds the SurfaceServer and allocates new Surfaces namespaces. 49 // that holds the SurfaceServer and allocates new Surfaces namespaces.
42 // This object lives on the main thread of the Window Server. 50 // This object lives on the main thread of the Window Server.
43 // TODO(rjkroege, fsamuel): This object will need to change to support multiple 51 // TODO(rjkroege, fsamuel): This object will need to change to support multiple
44 // displays. 52 // displays.
45 class DisplayCompositor : public cc::SurfaceObserver, 53 class DisplayCompositor : public cc::SurfaceObserver,
46 public cc::mojom::DisplayCompositor { 54 public cc::mojom::DisplayCompositor {
(...skipping 26 matching lines...) Expand all
73 // compositor host and the client drop their connection to avoid getting into 81 // compositor host and the client drop their connection to avoid getting into
74 // a state where surfaces references are inconsistent. 82 // a state where surfaces references are inconsistent.
75 void OnCompositorFrameSinkClientConnectionLost( 83 void OnCompositorFrameSinkClientConnectionLost(
76 const cc::FrameSinkId& frame_sink_id, 84 const cc::FrameSinkId& frame_sink_id,
77 bool destroy_compositor_frame_sink); 85 bool destroy_compositor_frame_sink);
78 void OnCompositorFrameSinkPrivateConnectionLost( 86 void OnCompositorFrameSinkPrivateConnectionLost(
79 const cc::FrameSinkId& frame_sink_id, 87 const cc::FrameSinkId& frame_sink_id,
80 bool destroy_compositor_frame_sink); 88 bool destroy_compositor_frame_sink);
81 89
82 private: 90 private:
91 friend class test::DisplayCompositorTest;
92
93 const cc::SurfaceId& GetRootSurfaceId() const;
83 94
84 // cc::SurfaceObserver implementation. 95 // cc::SurfaceObserver implementation.
85 void OnSurfaceCreated(const cc::SurfaceId& surface_id, 96 void OnSurfaceCreated(const cc::SurfaceId& surface_id,
86 const gfx::Size& frame_size, 97 const gfx::Size& frame_size,
87 float device_scale_factor) override; 98 float device_scale_factor) override;
88 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, 99 void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
89 bool* changed) override; 100 bool* changed) override;
90 101
91 // SurfaceManager should be the first object constructed and the last object 102 // SurfaceManager should be the first object constructed and the last object
92 // destroyed in order to ensure that all other objects that depend on it have 103 // destroyed in order to ensure that all other objects that depend on it have
93 // access to a valid pointer for the entirety of their liftimes. 104 // access to a valid pointer for the entirety of their liftimes.
94 cc::SurfaceManager manager_; 105 cc::SurfaceManager manager_;
95 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_; 106 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_;
96 std::unordered_map<cc::FrameSinkId, 107 std::unordered_map<cc::FrameSinkId,
97 std::unique_ptr<GpuCompositorFrameSink>, 108 std::unique_ptr<GpuCompositorFrameSink>,
98 cc::FrameSinkIdHash> 109 cc::FrameSinkIdHash>
99 compositor_frame_sinks_; 110 compositor_frame_sinks_;
100 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_; 111 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_;
101 gpu::ImageFactory* image_factory_; 112 gpu::ImageFactory* image_factory_;
102 cc::mojom::DisplayCompositorClientPtr client_; 113 cc::mojom::DisplayCompositorClientPtr client_;
103 114
115 // Will normally point to |manager_| as it provides the interface. For tests
116 // it will be swapped out with a mock implementation.
117 cc::SurfaceReferenceManager* reference_manager_;
118
104 // SurfaceIds that have temporary references from top level root so they 119 // SurfaceIds that have temporary references from top level root so they
105 // aren't GC'd before DisplayCompositorClient can add a real reference. This 120 // aren't GC'd before DisplayCompositorClient can add a real reference. This
106 // is basically a collection of surface ids, for example: 121 // is basically a collection of surface ids, for example:
107 // cc::SurfaceId surface_id(key, value[index]); 122 // cc::SurfaceId surface_id(key, value[index]);
108 // The LocalFrameIds are stored in the order the surfaces are created in. 123 // The LocalFrameIds are stored in the order the surfaces are created in.
109 std::unordered_map<cc::FrameSinkId, 124 std::unordered_map<cc::FrameSinkId,
110 std::vector<cc::LocalFrameId>, 125 std::vector<cc::LocalFrameId>,
111 cc::FrameSinkIdHash> 126 cc::FrameSinkIdHash>
112 temp_references_; 127 temp_references_;
113 128
114 base::ThreadChecker thread_checker_; 129 base::ThreadChecker thread_checker_;
115 130
116 mojo::Binding<cc::mojom::DisplayCompositor> binding_; 131 mojo::Binding<cc::mojom::DisplayCompositor> binding_;
117 132
118 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); 133 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor);
119 }; 134 };
120 135
121 } // namespace ui 136 } // namespace ui
122 137
123 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ 138 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_reference_manager.h ('k') | services/ui/surfaces/display_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698