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

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

Issue 2520513002: Add DisplayCompositorTest. (Closed)
Patch Set: Created 4 years, 1 month 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 | « services/ui/surfaces/BUILD.gn ('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 <unordered_map>
11 #include <vector>
12
10 #include "base/macros.h" 13 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
12 #include "cc/ipc/display_compositor.mojom.h" 15 #include "cc/ipc/display_compositor.mojom.h"
13 #include "cc/surfaces/frame_sink_id.h" 16 #include "cc/surfaces/frame_sink_id.h"
14 #include "cc/surfaces/local_frame_id.h" 17 #include "cc/surfaces/local_frame_id.h"
15 #include "cc/surfaces/surface_id.h" 18 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_manager.h" 19 #include "cc/surfaces/surface_manager.h"
17 #include "cc/surfaces/surface_observer.h" 20 #include "cc/surfaces/surface_observer.h"
18 21
19 namespace cc { 22 namespace cc {
20 class SurfaceHittest; 23 class SurfaceHittest;
21 class SurfaceManager; 24 class SurfaceManager;
22 } // namespace cc 25 } // namespace cc
23 26
24 namespace ui { 27 namespace ui {
25 28 namespace test {
26 class DisplayCompositorClient; 29 class DisplayCompositorTest;
30 }
27 31
28 // The DisplayCompositor object is an object global to the Window Server app 32 // The DisplayCompositor object is an object global to the Window Server app
29 // that holds the SurfaceServer and allocates new Surfaces namespaces. 33 // that holds the SurfaceServer and allocates new Surfaces namespaces.
30 // This object lives on the main thread of the Window Server. 34 // This object lives on the main thread of the Window Server.
31 // TODO(rjkroege, fsamuel): This object will need to change to support multiple 35 // TODO(rjkroege, fsamuel): This object will need to change to support multiple
32 // displays. 36 // displays.
33 class DisplayCompositor : public cc::SurfaceObserver, 37 class DisplayCompositor : public cc::SurfaceObserver,
34 public base::RefCounted<DisplayCompositor> { 38 public base::RefCounted<DisplayCompositor> {
35 public: 39 public:
36 explicit DisplayCompositor(cc::mojom::DisplayCompositorClientPtr client); 40 explicit DisplayCompositor(cc::mojom::DisplayCompositorClientPtr client);
37 41
38 // TODO(fsamuel): These methods should be behind a mojo interface. 42 // TODO(fsamuel): These methods should be behind a mojo interface.
39 void AddRootSurfaceReference(const cc::SurfaceId& child_id); 43 void AddRootSurfaceReference(const cc::SurfaceId& child_id);
40 void AddSurfaceReference(const cc::SurfaceId& parent_id, 44 void AddSurfaceReference(const cc::SurfaceId& parent_id,
41 const cc::SurfaceId& child_id); 45 const cc::SurfaceId& child_id);
42 void RemoveRootSurfaceReference(const cc::SurfaceId& child_id); 46 void RemoveRootSurfaceReference(const cc::SurfaceId& child_id);
43 void RemoveSurfaceReference(const cc::SurfaceId& parent_id, 47 void RemoveSurfaceReference(const cc::SurfaceId& parent_id,
44 const cc::SurfaceId& child_id); 48 const cc::SurfaceId& child_id);
45 49
46 cc::SurfaceManager* manager() { return &manager_; } 50 cc::SurfaceManager* manager() { return &manager_; }
47 51
52 void set_reference_manager_for_testing(
53 cc::SurfaceReferenceManager* reference_manager) {
54 reference_manager_ = reference_manager;
55 }
56
48 private: 57 private:
49 friend class base::RefCounted<DisplayCompositor>; 58 friend class base::RefCounted<DisplayCompositor>;
59 friend class test::DisplayCompositorTest;
60
50 virtual ~DisplayCompositor(); 61 virtual ~DisplayCompositor();
51 62
52 // cc::SurfaceObserver implementation. 63 // cc::SurfaceObserver implementation.
53 void OnSurfaceCreated(const cc::SurfaceId& surface_id, 64 void OnSurfaceCreated(const cc::SurfaceId& surface_id,
54 const gfx::Size& frame_size, 65 const gfx::Size& frame_size,
55 float device_scale_factor) override; 66 float device_scale_factor) override;
56 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, 67 void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
57 bool* changed) override; 68 bool* changed) override;
58 69
59 cc::mojom::DisplayCompositorClientPtr client_; 70 cc::mojom::DisplayCompositorClientPtr client_;
60 cc::SurfaceManager manager_; 71 cc::SurfaceManager manager_;
72 cc::SurfaceReferenceManager* reference_manager_;
Fady Samuel 2016/11/18 20:18:24 Can we avoid having two references to the same thi
kylechar 2016/11/24 20:43:14 Not easily, at least from what I can think of. We
73
74 // Local copy of top level root surface id, for convenience.
75 const cc::SurfaceId root_surface_id_;
61 76
62 // SurfaceIds that have temporary references from top level root so they 77 // SurfaceIds that have temporary references from top level root so they
63 // aren't GC'd before DisplayCompositorClient can add a real reference. This 78 // aren't GC'd before DisplayCompositorClient can add a real reference. This
64 // is basically a collection of surface ids, for example: 79 // is basically a collection of surface ids, for example:
65 // cc::SurfaceId surface_id(key, value[index]); 80 // cc::SurfaceId surface_id(key, value[index]);
66 // The LocalFrameIds are stored in the order the surfaces are created in. 81 // The LocalFrameIds are stored in the order the surfaces are created in.
67 std::unordered_map<cc::FrameSinkId, 82 std::unordered_map<cc::FrameSinkId,
68 std::vector<cc::LocalFrameId>, 83 std::vector<cc::LocalFrameId>,
69 cc::FrameSinkIdHash> 84 cc::FrameSinkIdHash>
70 temp_references_; 85 temp_references_;
71 86
72 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); 87 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor);
73 }; 88 };
74 89
75 } // namespace ui 90 } // namespace ui
76 91
77 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ 92 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « services/ui/surfaces/BUILD.gn ('k') | services/ui/surfaces/display_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698