OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_COMPOSITOR_COMPOSITOR_H_ | 5 #ifndef UI_COMPOSITOR_COMPOSITOR_H_ |
6 #define UI_COMPOSITOR_COMPOSITOR_H_ | 6 #define UI_COMPOSITOR_COMPOSITOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 // This class abstracts the creation of the 3D context for the compositor. It is | 93 // This class abstracts the creation of the 3D context for the compositor. It is |
94 // a global object. | 94 // a global object. |
95 class COMPOSITOR_EXPORT ContextFactory { | 95 class COMPOSITOR_EXPORT ContextFactory { |
96 public: | 96 public: |
97 virtual ~ContextFactory() {} | 97 virtual ~ContextFactory() {} |
98 | 98 |
99 // Creates an output surface for the given compositor. The factory may keep | 99 // Creates an output surface for the given compositor. The factory may keep |
100 // per-compositor data (e.g. a shared context), that needs to be cleaned up | 100 // per-compositor data (e.g. a shared context), that needs to be cleaned up |
101 // by calling RemoveCompositor when the compositor gets destroyed. | 101 // by calling RemoveCompositor when the compositor gets destroyed. |
102 virtual void CreateOutputSurface(base::WeakPtr<Compositor> compositor) = 0; | 102 virtual void CreateCompositorFrameSink( |
| 103 base::WeakPtr<Compositor> compositor) = 0; |
103 | 104 |
104 // Creates a reflector that copies the content of the |mirrored_compositor| | 105 // Creates a reflector that copies the content of the |mirrored_compositor| |
105 // onto |mirroring_layer|. | 106 // onto |mirroring_layer|. |
106 virtual std::unique_ptr<Reflector> CreateReflector( | 107 virtual std::unique_ptr<Reflector> CreateReflector( |
107 Compositor* mirrored_compositor, | 108 Compositor* mirrored_compositor, |
108 Layer* mirroring_layer) = 0; | 109 Layer* mirroring_layer) = 0; |
109 // Removes the reflector, which stops the mirroring. | 110 // Removes the reflector, which stops the mirroring. |
110 virtual void RemoveReflector(Reflector* reflector) = 0; | 111 virtual void RemoveReflector(Reflector* reflector) = 0; |
111 | 112 |
112 // Return a reference to a shared offscreen context provider usable from the | 113 // Return a reference to a shared offscreen context provider usable from the |
(...skipping 22 matching lines...) Expand all Loading... |
135 virtual cc::TaskGraphRunner* GetTaskGraphRunner() = 0; | 136 virtual cc::TaskGraphRunner* GetTaskGraphRunner() = 0; |
136 | 137 |
137 // Allocate a new client ID for the display compositor. | 138 // Allocate a new client ID for the display compositor. |
138 virtual uint32_t AllocateSurfaceClientId() = 0; | 139 virtual uint32_t AllocateSurfaceClientId() = 0; |
139 | 140 |
140 // Gets the surface manager. | 141 // Gets the surface manager. |
141 virtual cc::SurfaceManager* GetSurfaceManager() = 0; | 142 virtual cc::SurfaceManager* GetSurfaceManager() = 0; |
142 | 143 |
143 // Inform the display corresponding to this compositor if it is visible. When | 144 // Inform the display corresponding to this compositor if it is visible. When |
144 // false it does not need to produce any frames. Visibility is reset for each | 145 // false it does not need to produce any frames. Visibility is reset for each |
145 // call to CreateOutputSurface. | 146 // call to CreateCompositorFrameSink. |
146 virtual void SetDisplayVisible(ui::Compositor* compositor, bool visible) = 0; | 147 virtual void SetDisplayVisible(ui::Compositor* compositor, bool visible) = 0; |
147 | 148 |
148 // Resize the display corresponding to this compositor to a particular size. | 149 // Resize the display corresponding to this compositor to a particular size. |
149 virtual void ResizeDisplay(ui::Compositor* compositor, | 150 virtual void ResizeDisplay(ui::Compositor* compositor, |
150 const gfx::Size& size) = 0; | 151 const gfx::Size& size) = 0; |
151 | 152 |
152 // Set the output color profile into which this compositor should render. | 153 // Set the output color profile into which this compositor should render. |
153 virtual void SetDisplayColorSpace(ui::Compositor* compositor, | 154 virtual void SetDisplayColorSpace(ui::Compositor* compositor, |
154 const gfx::ColorSpace& color_space) = 0; | 155 const gfx::ColorSpace& color_space) = 0; |
155 | 156 |
156 virtual void SetAuthoritativeVSyncInterval(ui::Compositor* compositor, | 157 virtual void SetAuthoritativeVSyncInterval(ui::Compositor* compositor, |
157 base::TimeDelta interval) = 0; | 158 base::TimeDelta interval) = 0; |
158 // Mac path for transporting vsync parameters to the display. Other platforms | 159 // Mac path for transporting vsync parameters to the display. Other platforms |
159 // update it via the BrowserCompositorOutputSurface directly. | 160 // update it via the BrowserCompositorCompositorFrameSink directly. |
160 virtual void SetDisplayVSyncParameters(ui::Compositor* compositor, | 161 virtual void SetDisplayVSyncParameters(ui::Compositor* compositor, |
161 base::TimeTicks timebase, | 162 base::TimeTicks timebase, |
162 base::TimeDelta interval) = 0; | 163 base::TimeDelta interval) = 0; |
163 | 164 |
164 virtual void SetOutputIsSecure(Compositor* compositor, bool secure) = 0; | 165 virtual void SetOutputIsSecure(Compositor* compositor, bool secure) = 0; |
165 | 166 |
166 virtual void AddObserver(ContextFactoryObserver* observer) = 0; | 167 virtual void AddObserver(ContextFactoryObserver* observer) = 0; |
167 | 168 |
168 virtual void RemoveObserver(ContextFactoryObserver* observer) = 0; | 169 virtual void RemoveObserver(ContextFactoryObserver* observer) = 0; |
169 }; | 170 }; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 public: | 206 public: |
206 Compositor(ui::ContextFactory* context_factory, | 207 Compositor(ui::ContextFactory* context_factory, |
207 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 208 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
208 ~Compositor() override; | 209 ~Compositor() override; |
209 | 210 |
210 ui::ContextFactory* context_factory() { return context_factory_; } | 211 ui::ContextFactory* context_factory() { return context_factory_; } |
211 | 212 |
212 void AddSurfaceClient(uint32_t client_id); | 213 void AddSurfaceClient(uint32_t client_id); |
213 void RemoveSurfaceClient(uint32_t client_id); | 214 void RemoveSurfaceClient(uint32_t client_id); |
214 | 215 |
215 void SetOutputSurface(std::unique_ptr<cc::OutputSurface> surface); | 216 void SetCompositorFrameSink(std::unique_ptr<cc::CompositorFrameSink> surface); |
216 | 217 |
217 // Schedules a redraw of the layer tree associated with this compositor. | 218 // Schedules a redraw of the layer tree associated with this compositor. |
218 void ScheduleDraw(); | 219 void ScheduleDraw(); |
219 | 220 |
220 // Sets the root of the layer tree drawn by this Compositor. The root layer | 221 // Sets the root of the layer tree drawn by this Compositor. The root layer |
221 // must have no parent. The compositor's root layer is reset if the root layer | 222 // must have no parent. The compositor's root layer is reset if the root layer |
222 // is destroyed. NULL can be passed to reset the root layer, in which case the | 223 // is destroyed. NULL can be passed to reset the root layer, in which case the |
223 // compositor will stop drawing anything. | 224 // compositor will stop drawing anything. |
224 // The Compositor does not own the root layer. | 225 // The Compositor does not own the root layer. |
225 const Layer* root_layer() const { return root_layer_; } | 226 const Layer* root_layer() const { return root_layer_; } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 bool ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset); | 278 bool ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset); |
278 | 279 |
279 // The "authoritative" vsync interval, if provided, will override interval | 280 // The "authoritative" vsync interval, if provided, will override interval |
280 // reported from 3D context. This is typically the value reported by a more | 281 // reported from 3D context. This is typically the value reported by a more |
281 // reliable source, e.g, the platform display configuration. | 282 // reliable source, e.g, the platform display configuration. |
282 // In the particular case of ChromeOS -- this is the value queried through | 283 // In the particular case of ChromeOS -- this is the value queried through |
283 // XRandR, which is more reliable than the value queried through the 3D | 284 // XRandR, which is more reliable than the value queried through the 3D |
284 // context. | 285 // context. |
285 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval); | 286 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval); |
286 | 287 |
287 // Most platforms set their vsync info via BrowerCompositorOutputSurface's | 288 // Most platforms set their vsync info via |
| 289 // BrowerCompositorCompositorFrameSink's |
288 // OnUpdateVSyncParametersFromGpu, but Mac routes vsync info via the | 290 // OnUpdateVSyncParametersFromGpu, but Mac routes vsync info via the |
289 // browser compositor instead through this path. | 291 // browser compositor instead through this path. |
290 void SetDisplayVSyncParameters(base::TimeTicks timebase, | 292 void SetDisplayVSyncParameters(base::TimeTicks timebase, |
291 base::TimeDelta interval); | 293 base::TimeDelta interval); |
292 | 294 |
293 // Sets the widget for the compositor to render into. | 295 // Sets the widget for the compositor to render into. |
294 void SetAcceleratedWidget(gfx::AcceleratedWidget widget); | 296 void SetAcceleratedWidget(gfx::AcceleratedWidget widget); |
295 // Releases the widget previously set through SetAcceleratedWidget(). | 297 // Releases the widget previously set through SetAcceleratedWidget(). |
296 // After returning it will not be used for rendering anymore. | 298 // After returning it will not be used for rendering anymore. |
297 // The compositor must be set to invisible when taking away a widget. | 299 // The compositor must be set to invisible when taking away a widget. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 void WillBeginMainFrame() override {} | 352 void WillBeginMainFrame() override {} |
351 void DidBeginMainFrame() override {} | 353 void DidBeginMainFrame() override {} |
352 void BeginMainFrame(const cc::BeginFrameArgs& args) override; | 354 void BeginMainFrame(const cc::BeginFrameArgs& args) override; |
353 void BeginMainFrameNotExpectedSoon() override; | 355 void BeginMainFrameNotExpectedSoon() override; |
354 void UpdateLayerTreeHost() override; | 356 void UpdateLayerTreeHost() override; |
355 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | 357 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
356 const gfx::Vector2dF& outer_delta, | 358 const gfx::Vector2dF& outer_delta, |
357 const gfx::Vector2dF& elastic_overscroll_delta, | 359 const gfx::Vector2dF& elastic_overscroll_delta, |
358 float page_scale, | 360 float page_scale, |
359 float top_controls_delta) override {} | 361 float top_controls_delta) override {} |
360 void RequestNewOutputSurface() override; | 362 void RequestNewCompositorFrameSink() override; |
361 void DidInitializeOutputSurface() override; | 363 void DidInitializeCompositorFrameSink() override; |
362 void DidFailToInitializeOutputSurface() override; | 364 void DidFailToInitializeCompositorFrameSink() override; |
363 void WillCommit() override {} | 365 void WillCommit() override {} |
364 void DidCommit() override; | 366 void DidCommit() override; |
365 void DidCommitAndDrawFrame() override; | 367 void DidCommitAndDrawFrame() override; |
366 void DidCompleteSwapBuffers() override; | 368 void DidCompleteSwapBuffers() override; |
367 void DidCompletePageScaleAnimation() override {} | 369 void DidCompletePageScaleAnimation() override {} |
368 | 370 |
369 // cc::LayerTreeHostSingleThreadClient implementation. | 371 // cc::LayerTreeHostSingleThreadClient implementation. |
370 void DidPostSwapBuffers() override; | 372 void DidPostSwapBuffers() override; |
371 void DidAbortSwapBuffers() override; | 373 void DidAbortSwapBuffers() override; |
372 | 374 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 base::ObserverList<CompositorObserver, true> observer_list_; | 408 base::ObserverList<CompositorObserver, true> observer_list_; |
407 base::ObserverList<CompositorAnimationObserver> animation_observer_list_; | 409 base::ObserverList<CompositorAnimationObserver> animation_observer_list_; |
408 | 410 |
409 gfx::AcceleratedWidget widget_; | 411 gfx::AcceleratedWidget widget_; |
410 #if defined(USE_AURA) | 412 #if defined(USE_AURA) |
411 ui::Window* window_; | 413 ui::Window* window_; |
412 #endif | 414 #endif |
413 // A map from child id to parent id. | 415 // A map from child id to parent id. |
414 std::unordered_map<uint32_t, uint32_t> surface_clients_; | 416 std::unordered_map<uint32_t, uint32_t> surface_clients_; |
415 bool widget_valid_; | 417 bool widget_valid_; |
416 bool output_surface_requested_; | 418 bool compositor_frame_sink_requested_; |
417 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 419 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
418 scoped_refptr<cc::Layer> root_web_layer_; | 420 scoped_refptr<cc::Layer> root_web_layer_; |
419 std::unique_ptr<cc::LayerTreeHost> host_; | 421 std::unique_ptr<cc::LayerTreeHost> host_; |
420 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 422 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
421 | 423 |
422 // The manager of vsync parameters for this compositor. | 424 // The manager of vsync parameters for this compositor. |
423 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 425 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
424 | 426 |
425 // The device scale factor of the monitor that this compositor is compositing | 427 // The device scale factor of the monitor that this compositor is compositing |
426 // layers on. | 428 // layers on. |
427 float device_scale_factor_; | 429 float device_scale_factor_; |
428 | 430 |
429 bool locks_will_time_out_; | 431 bool locks_will_time_out_; |
430 CompositorLock* compositor_lock_; | 432 CompositorLock* compositor_lock_; |
431 | 433 |
432 LayerAnimatorCollection layer_animator_collection_; | 434 LayerAnimatorCollection layer_animator_collection_; |
433 scoped_refptr<cc::AnimationTimeline> animation_timeline_; | 435 scoped_refptr<cc::AnimationTimeline> animation_timeline_; |
434 | 436 |
435 base::WeakPtrFactory<Compositor> weak_ptr_factory_; | 437 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
436 | 438 |
437 DISALLOW_COPY_AND_ASSIGN(Compositor); | 439 DISALLOW_COPY_AND_ASSIGN(Compositor); |
438 }; | 440 }; |
439 | 441 |
440 } // namespace ui | 442 } // namespace ui |
441 | 443 |
442 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 444 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |