| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WS_FRAME_GENERATOR_H_ | 5 #ifndef SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| 6 #define SERVICES_UI_WS_FRAME_GENERATOR_H_ | 6 #define SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "cc/surfaces/frame_sink_id.h" | 13 #include "cc/surfaces/frame_sink_id.h" |
| 14 #include "cc/surfaces/local_frame_id.h" | 14 #include "cc/surfaces/local_frame_id.h" |
| 15 #include "cc/surfaces/surface_sequence.h" | 15 #include "cc/surfaces/surface_sequence.h" |
| 16 #include "cc/surfaces/surface_sequence_generator.h" | 16 #include "cc/surfaces/surface_sequence_generator.h" |
| 17 #include "services/ui/public/interfaces/window_tree_constants.mojom.h" |
| 17 #include "services/ui/ws/server_window_observer.h" | 18 #include "services/ui/ws/server_window_observer.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 20 | 21 |
| 21 namespace cc { | 22 namespace cc { |
| 22 class CompositorFrame; | 23 class CompositorFrame; |
| 23 class CopyOutputRequest; | 24 class CopyOutputRequest; |
| 24 class RenderPass; | 25 class RenderPass; |
| 25 class SurfaceId; | 26 class SurfaceId; |
| 26 } | 27 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 void DidDraw(); | 76 void DidDraw(); |
| 76 | 77 |
| 77 // Generates the CompositorFrame for the current |dirty_rect_|. | 78 // Generates the CompositorFrame for the current |dirty_rect_|. |
| 78 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); | 79 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); |
| 79 | 80 |
| 80 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad | 81 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad |
| 81 // for each that lacks one. | 82 // for each that lacks one. |
| 82 void DrawWindowTree(cc::RenderPass* pass, | 83 void DrawWindowTree(cc::RenderPass* pass, |
| 83 ServerWindow* window, | 84 ServerWindow* window, |
| 84 const gfx::Vector2d& parent_to_root_origin_offset, | 85 const gfx::Vector2d& parent_to_root_origin_offset, |
| 85 float opacity, | 86 float opacity); |
| 86 bool* may_contain_video); | |
| 87 | 87 |
| 88 // Adds a reference to the current cc::Surface of the provided | 88 // Adds a reference to the current cc::Surface of the provided |
| 89 // |window_compositor_frame_sink|. If an existing reference is held with a | 89 // |window_compositor_frame_sink|. If an existing reference is held with a |
| 90 // different LocalFrameId then release that reference first. This is called on | 90 // different LocalFrameId then release that reference first. This is called on |
| 91 // each ServerWindowCompositorFrameSink as FrameGenerator walks the window | 91 // each ServerWindowCompositorFrameSink as FrameGenerator walks the window |
| 92 // tree to generate a CompositorFrame. This is done to make sure that the | 92 // tree to generate a CompositorFrame. This is done to make sure that the |
| 93 // window surfaces are retained for the entirety of the time between | 93 // window surfaces are retained for the entirety of the time between |
| 94 // submission of the top-level frame to drawing the frame to screen. | 94 // submission of the top-level frame to drawing the frame to screen. |
| 95 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime | 95 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime |
| 96 // management. | 96 // management. |
| 97 void AddOrUpdateSurfaceReference( | 97 void AddOrUpdateSurfaceReference(mojom::CompositorFrameSinkType type, |
| 98 ServerWindowCompositorFrameSink* window_compositor_frame_sink); | 98 ServerWindow* window); |
| 99 | 99 |
| 100 // Releases any retained references for the provided FrameSink. | 100 // Releases any retained references for the provided FrameSink. |
| 101 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime | 101 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime |
| 102 // management. | 102 // management. |
| 103 void ReleaseFrameSinkReference(const cc::FrameSinkId& frame_sink_id); | 103 void ReleaseFrameSinkReference(const cc::FrameSinkId& frame_sink_id); |
| 104 | 104 |
| 105 // Releases all retained references to surfaces. | 105 // Releases all retained references to surfaces. |
| 106 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime | 106 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime |
| 107 // management. | 107 // management. |
| 108 void ReleaseAllSurfaceReferences(); | 108 void ReleaseAllSurfaceReferences(); |
| 109 | 109 |
| 110 // ServerWindowObserver implementation. | 110 // ServerWindowObserver implementation. |
| 111 void OnWindowDestroying(ServerWindow* window) override; | 111 void OnWindowDestroying(ServerWindow* window) override; |
| 112 | 112 |
| 113 FrameGeneratorDelegate* delegate_; | 113 FrameGeneratorDelegate* delegate_; |
| 114 scoped_refptr<DisplayCompositor> display_compositor_; | 114 scoped_refptr<DisplayCompositor> display_compositor_; |
| 115 cc::FrameSinkId frame_sink_id_; | 115 cc::FrameSinkId frame_sink_id_; |
| 116 cc::SurfaceSequenceGenerator surface_sequence_generator_; | 116 cc::SurfaceSequenceGenerator surface_sequence_generator_; |
| 117 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | 117 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
| 118 | 118 |
| 119 std::unique_ptr<DisplayCompositorFrameSink> compositor_frame_sink_; | 119 std::unique_ptr<DisplayCompositorFrameSink> compositor_frame_sink_; |
| 120 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; | 120 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; |
| 121 | 121 |
| 122 // The region that needs to be redrawn next time the compositor frame is | 122 // The region that needs to be redrawn next time the compositor frame is |
| 123 // generated. | 123 // generated. |
| 124 gfx::Rect dirty_rect_; | 124 gfx::Rect dirty_rect_; |
| 125 base::Timer draw_timer_; | 125 base::Timer draw_timer_; |
| 126 bool frame_pending_ = false; | 126 bool frame_pending_ = false; |
| 127 bool may_contain_video_ = false; | |
| 128 struct SurfaceDependency { | 127 struct SurfaceDependency { |
| 129 cc::LocalFrameId local_frame_id; | 128 cc::LocalFrameId local_frame_id; |
| 130 cc::SurfaceSequence sequence; | 129 cc::SurfaceSequence sequence; |
| 131 }; | 130 }; |
| 132 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> | 131 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> |
| 133 dependencies_; | 132 dependencies_; |
| 134 | 133 |
| 135 base::WeakPtrFactory<FrameGenerator> weak_factory_; | 134 base::WeakPtrFactory<FrameGenerator> weak_factory_; |
| 136 | 135 |
| 137 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 136 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
| 138 }; | 137 }; |
| 139 | 138 |
| 140 } // namespace ws | 139 } // namespace ws |
| 141 | 140 |
| 142 } // namespace ui | 141 } // namespace ui |
| 143 | 142 |
| 144 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 143 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| OLD | NEW |