| OLD | NEW |
| 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" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "cc/ipc/display_compositor.mojom.h" | 12 #include "cc/ipc/display_compositor.mojom.h" |
| 13 #include "cc/surfaces/frame_sink_id.h" |
| 14 #include "cc/surfaces/local_frame_id.h" |
| 15 #include "cc/surfaces/surface_id.h" |
| 13 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" |
| 14 #include "cc/surfaces/surface_observer.h" | 17 #include "cc/surfaces/surface_observer.h" |
| 15 | 18 |
| 16 namespace cc { | 19 namespace cc { |
| 17 class SurfaceHittest; | 20 class SurfaceHittest; |
| 18 class SurfaceManager; | 21 class SurfaceManager; |
| 19 } // namespace cc | 22 } // namespace cc |
| 20 | 23 |
| 21 namespace ui { | 24 namespace ui { |
| 22 | 25 |
| 23 class DisplayCompositorClient; | 26 class DisplayCompositorClient; |
| 24 | 27 |
| 25 // The DisplayCompositor object is an object global to the Window Server app | 28 // The DisplayCompositor object is an object global to the Window Server app |
| 26 // that holds the SurfaceServer and allocates new Surfaces namespaces. | 29 // that holds the SurfaceServer and allocates new Surfaces namespaces. |
| 27 // This object lives on the main thread of the Window Server. | 30 // This object lives on the main thread of the Window Server. |
| 28 // TODO(rjkroege, fsamuel): This object will need to change to support multiple | 31 // TODO(rjkroege, fsamuel): This object will need to change to support multiple |
| 29 // displays. | 32 // displays. |
| 30 class DisplayCompositor : public cc::SurfaceObserver, | 33 class DisplayCompositor : public cc::SurfaceObserver, |
| 31 public base::RefCounted<DisplayCompositor> { | 34 public base::RefCounted<DisplayCompositor> { |
| 32 public: | 35 public: |
| 33 explicit DisplayCompositor(cc::mojom::DisplayCompositorClientPtr client); | 36 explicit DisplayCompositor(cc::mojom::DisplayCompositorClientPtr client); |
| 34 | 37 |
| 35 // TODO(fsamuel): These methods should be behind a mojo interface. | 38 // TODO(fsamuel): These methods should be behind a mojo interface. |
| 36 void AddSurfaceReference(const cc::SurfaceId& surface_id, | 39 void AddRootSurfaceReference(const cc::SurfaceId& child_id); |
| 37 const cc::SurfaceSequence& surface_sequence); | 40 void AddSurfaceReference(const cc::SurfaceId& parent_id, |
| 38 void ReturnSurfaceReferences(const cc::FrameSinkId& frame_sink_id, | 41 const cc::SurfaceId& child_id); |
| 39 const std::vector<uint32_t>& sequences); | 42 void RemoveRootSurfaceReference(const cc::SurfaceId& child_id); |
| 43 void RemoveSurfaceReference(const cc::SurfaceId& parent_id, |
| 44 const cc::SurfaceId& child_id); |
| 40 | 45 |
| 41 cc::SurfaceManager* manager() { return &manager_; } | 46 cc::SurfaceManager* manager() { return &manager_; } |
| 42 | 47 |
| 43 private: | 48 private: |
| 44 friend class base::RefCounted<DisplayCompositor>; | 49 friend class base::RefCounted<DisplayCompositor>; |
| 45 virtual ~DisplayCompositor(); | 50 virtual ~DisplayCompositor(); |
| 46 | 51 |
| 47 // cc::SurfaceObserver implementation. | 52 // cc::SurfaceObserver implementation. |
| 48 void OnSurfaceCreated(const cc::SurfaceId& surface_id, | 53 void OnSurfaceCreated(const cc::SurfaceId& surface_id, |
| 49 const gfx::Size& frame_size, | 54 const gfx::Size& frame_size, |
| 50 float device_scale_factor) override; | 55 float device_scale_factor) override; |
| 51 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, | 56 void OnSurfaceDamaged(const cc::SurfaceId& surface_id, |
| 52 bool* changed) override; | 57 bool* changed) override; |
| 53 | 58 |
| 54 cc::mojom::DisplayCompositorClientPtr client_; | 59 cc::mojom::DisplayCompositorClientPtr client_; |
| 55 cc::SurfaceManager manager_; | 60 cc::SurfaceManager manager_; |
| 56 | 61 |
| 62 // SurfaceIds that have temporary references from top level root so they |
| 63 // aren't GC'd before DisplayCompositorClient can add a real reference. This |
| 64 // is basically a collection of surface ids, for example: |
| 65 // cc::SurfaceId surface_id(key, value[index]); |
| 66 // The LocalFrameIds are stored in the order the surfaces are created in. |
| 67 std::unordered_map<cc::FrameSinkId, |
| 68 std::vector<cc::LocalFrameId>, |
| 69 cc::FrameSinkIdHash> |
| 70 temp_references_; |
| 71 |
| 57 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); | 72 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); |
| 58 }; | 73 }; |
| 59 | 74 |
| 60 } // namespace ui | 75 } // namespace ui |
| 61 | 76 |
| 62 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ | 77 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_ |
| OLD | NEW |