Chromium Code Reviews| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 } | 42 } |
| 43 | 43 |
| 44 class FrameGeneratorDelegate; | 44 class FrameGeneratorDelegate; |
| 45 class ServerWindow; | 45 class ServerWindow; |
| 46 | 46 |
| 47 // Responsible for redrawing the display in response to the redraw requests by | 47 // Responsible for redrawing the display in response to the redraw requests by |
| 48 // submitting CompositorFrames to the owned CompositorFrameSink. | 48 // submitting CompositorFrames to the owned CompositorFrameSink. |
| 49 class FrameGenerator : public ServerWindowTracker, | 49 class FrameGenerator : public ServerWindowTracker, |
| 50 public cc::mojom::MojoCompositorFrameSinkClient { | 50 public cc::mojom::MojoCompositorFrameSinkClient { |
| 51 public: | 51 public: |
| 52 FrameGenerator(FrameGeneratorDelegate* delegate, ServerWindow* root_window); | 52 FrameGenerator(FrameGeneratorDelegate* delegate, |
| 53 ServerWindow* root_window, | |
| 54 float device_scale_factor); | |
|
kylechar
2016/12/05 14:46:11
Instead of adding another parameter to the constru
riajiang
2016/12/09 19:31:44
Done.
| |
| 53 ~FrameGenerator() override; | 55 ~FrameGenerator() override; |
| 54 | 56 |
| 55 // Schedules a redraw for the provided region. | 57 // Schedules a redraw for the provided region. |
| 56 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); | 58 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); |
| 57 | 59 |
| 58 // Adds a reference to new surface with |surface_id| for |window|. This | 60 // Adds a reference to new surface with |surface_id| for |window|. This |
| 59 // reference is to ensure the surface is not deleted while it's still being | 61 // reference is to ensure the surface is not deleted while it's still being |
| 60 // displayed. The display root surface has a reference from the top level | 62 // displayed. The display root surface has a reference from the top level |
| 61 // root. All child surfaces are embedded by the display root and receive a | 63 // root. All child surfaces are embedded by the display root and receive a |
| 62 // reference from it. | 64 // reference from it. |
| 63 // | 65 // |
| 64 // If a new display root Surface is created, then all child surfaces will | 66 // If a new display root Surface is created, then all child surfaces will |
| 65 // receive a reference from the new display root so they are not deleted with | 67 // receive a reference from the new display root so they are not deleted with |
| 66 // the old display root. | 68 // the old display root. |
| 67 // | 69 // |
| 68 // If there is an existing reference to an old surface with the same | 70 // If there is an existing reference to an old surface with the same |
| 69 // FrameSinkId then that reference will be removed after the next | 71 // FrameSinkId then that reference will be removed after the next |
| 70 // CompositorFrame is submitted. | 72 // CompositorFrame is submitted. |
| 71 void OnSurfaceCreated(const cc::SurfaceId& surface_id, ServerWindow* window); | 73 void OnSurfaceCreated(const cc::SurfaceId& surface_id, ServerWindow* window); |
| 72 | 74 |
| 75 void UpdateDeviceScaleFactor(float device_scale_factor); | |
| 76 | |
| 73 private: | 77 private: |
| 74 friend class ui::ws::test::FrameGeneratorTest; | 78 friend class ui::ws::test::FrameGeneratorTest; |
| 75 | 79 |
| 76 // cc::mojom::MojoCompositorFrameSinkClient implementation: | 80 // cc::mojom::MojoCompositorFrameSinkClient implementation: |
| 77 void DidReceiveCompositorFrameAck() override; | 81 void DidReceiveCompositorFrameAck() override; |
| 78 void OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) override; | 82 void OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) override; |
| 79 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; | 83 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
| 80 | 84 |
| 81 // Generates the CompositorFrame. | 85 // Generates the CompositorFrame. |
| 82 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); | 86 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 113 // Removes all retained references to surfaces. | 117 // Removes all retained references to surfaces. |
| 114 void RemoveAllSurfaceReferences(); | 118 void RemoveAllSurfaceReferences(); |
| 115 | 119 |
| 116 cc::mojom::DisplayCompositor* GetDisplayCompositor(); | 120 cc::mojom::DisplayCompositor* GetDisplayCompositor(); |
| 117 | 121 |
| 118 // ServerWindowObserver implementation. | 122 // ServerWindowObserver implementation. |
| 119 void OnWindowDestroying(ServerWindow* window) override; | 123 void OnWindowDestroying(ServerWindow* window) override; |
| 120 | 124 |
| 121 FrameGeneratorDelegate* delegate_; | 125 FrameGeneratorDelegate* delegate_; |
| 122 ServerWindow* const root_window_; | 126 ServerWindow* const root_window_; |
| 127 float device_scale_factor_; | |
| 123 | 128 |
| 124 gfx::Size last_submitted_frame_size_; | 129 gfx::Size last_submitted_frame_size_; |
| 125 cc::LocalFrameId local_frame_id_; | 130 cc::LocalFrameId local_frame_id_; |
| 126 cc::SurfaceIdAllocator id_allocator_; | 131 cc::SurfaceIdAllocator id_allocator_; |
| 127 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_; | 132 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_; |
| 128 | 133 |
| 129 // Represents the top level root surface id that should reference the display | 134 // Represents the top level root surface id that should reference the display |
| 130 // root surface. We don't know the actual value, because it's generated in | 135 // root surface. We don't know the actual value, because it's generated in |
| 131 // another process, this is used internally as a placeholder. | 136 // another process, this is used internally as a placeholder. |
| 132 const cc::SurfaceId top_level_root_surface_id_; | 137 const cc::SurfaceId top_level_root_surface_id_; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 156 base::WeakPtrFactory<FrameGenerator> weak_factory_; | 161 base::WeakPtrFactory<FrameGenerator> weak_factory_; |
| 157 | 162 |
| 158 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 163 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
| 159 }; | 164 }; |
| 160 | 165 |
| 161 } // namespace ws | 166 } // namespace ws |
| 162 | 167 |
| 163 } // namespace ui | 168 } // namespace ui |
| 164 | 169 |
| 165 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 170 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| OLD | NEW |