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

Side by Side Diff: cc/trees/layer_tree_host_impl.h

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: android-vulkan Created 4 years, 3 months 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 | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_impl.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 CC_TREES_LAYER_TREE_HOST_IMPL_H_ 5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_
6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <bitset> 10 #include <bitset>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <unordered_map> 14 #include <unordered_map>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "cc/animation/layer_tree_mutator.h" 20 #include "cc/animation/layer_tree_mutator.h"
21 #include "cc/base/cc_export.h" 21 #include "cc/base/cc_export.h"
22 #include "cc/base/synced_property.h" 22 #include "cc/base/synced_property.h"
23 #include "cc/debug/micro_benchmark_controller_impl.h" 23 #include "cc/debug/micro_benchmark_controller_impl.h"
24 #include "cc/input/input_handler.h" 24 #include "cc/input/input_handler.h"
25 #include "cc/input/scrollbar_animation_controller.h" 25 #include "cc/input/scrollbar_animation_controller.h"
26 #include "cc/input/top_controls_manager_client.h" 26 #include "cc/input/top_controls_manager_client.h"
27 #include "cc/layers/layer_collections.h" 27 #include "cc/layers/layer_collections.h"
28 #include "cc/layers/render_pass_sink.h" 28 #include "cc/layers/render_pass_sink.h"
29 #include "cc/output/begin_frame_args.h" 29 #include "cc/output/begin_frame_args.h"
30 #include "cc/output/compositor_frame_sink_client.h"
30 #include "cc/output/context_cache_controller.h" 31 #include "cc/output/context_cache_controller.h"
31 #include "cc/output/managed_memory_policy.h" 32 #include "cc/output/managed_memory_policy.h"
32 #include "cc/output/output_surface_client.h"
33 #include "cc/quads/render_pass.h" 33 #include "cc/quads/render_pass.h"
34 #include "cc/resources/resource_provider.h" 34 #include "cc/resources/resource_provider.h"
35 #include "cc/resources/ui_resource_client.h" 35 #include "cc/resources/ui_resource_client.h"
36 #include "cc/scheduler/begin_frame_tracker.h" 36 #include "cc/scheduler/begin_frame_tracker.h"
37 #include "cc/scheduler/commit_earlyout_reason.h" 37 #include "cc/scheduler/commit_earlyout_reason.h"
38 #include "cc/scheduler/draw_result.h" 38 #include "cc/scheduler/draw_result.h"
39 #include "cc/scheduler/video_frame_controller.h" 39 #include "cc/scheduler/video_frame_controller.h"
40 #include "cc/tiles/image_decode_controller.h" 40 #include "cc/tiles/image_decode_controller.h"
41 #include "cc/tiles/tile_manager.h" 41 #include "cc/tiles/tile_manager.h"
42 #include "cc/trees/layer_tree_settings.h" 42 #include "cc/trees/layer_tree_settings.h"
43 #include "cc/trees/mutator_host_client.h" 43 #include "cc/trees/mutator_host_client.h"
44 #include "cc/trees/task_runner_provider.h" 44 #include "cc/trees/task_runner_provider.h"
45 #include "ui/gfx/geometry/rect.h" 45 #include "ui/gfx/geometry/rect.h"
46 46
47 namespace gfx { 47 namespace gfx {
48 class ScrollOffset; 48 class ScrollOffset;
49 } 49 }
50 50
51 namespace cc { 51 namespace cc {
52 52
53 class AnimationEvents; 53 class AnimationEvents;
54 class AnimationHost; 54 class AnimationHost;
55 class CompletionEvent; 55 class CompletionEvent;
56 class CompositorFrameMetadata; 56 class CompositorFrameMetadata;
57 class CompositorFrameSink;
57 class DebugRectHistory; 58 class DebugRectHistory;
58 class EvictionTilePriorityQueue; 59 class EvictionTilePriorityQueue;
59 class FrameRateCounter; 60 class FrameRateCounter;
60 class LayerImpl; 61 class LayerImpl;
61 class LayerTreeImpl; 62 class LayerTreeImpl;
62 class MemoryHistory; 63 class MemoryHistory;
63 class PageScaleAnimation; 64 class PageScaleAnimation;
64 class PendingTreeDurationHistogramTimer; 65 class PendingTreeDurationHistogramTimer;
65 class PictureLayerImpl; 66 class PictureLayerImpl;
66 class RasterTilePriorityQueue; 67 class RasterTilePriorityQueue;
(...skipping 22 matching lines...) Expand all
89 ON_FORCED, 90 ON_FORCED,
90 OFF_DEVICE, 91 OFF_DEVICE,
91 OFF_VIEWPORT, 92 OFF_VIEWPORT,
92 MSAA_CONTENT, 93 MSAA_CONTENT,
93 OFF_CONTENT 94 OFF_CONTENT
94 }; 95 };
95 96
96 // LayerTreeHost->Proxy callback interface. 97 // LayerTreeHost->Proxy callback interface.
97 class LayerTreeHostImplClient { 98 class LayerTreeHostImplClient {
98 public: 99 public:
99 virtual void DidLoseOutputSurfaceOnImplThread() = 0; 100 virtual void DidLoseCompositorFrameSinkOnImplThread() = 0;
100 virtual void SetBeginFrameSource(BeginFrameSource* source) = 0; 101 virtual void SetBeginFrameSource(BeginFrameSource* source) = 0;
101 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0; 102 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0;
102 virtual void DidSwapBuffersCompleteOnImplThread() = 0; 103 virtual void DidSwapBuffersCompleteOnImplThread() = 0;
103 virtual void OnCanDrawStateChanged(bool can_draw) = 0; 104 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
104 virtual void NotifyReadyToActivate() = 0; 105 virtual void NotifyReadyToActivate() = 0;
105 virtual void NotifyReadyToDraw() = 0; 106 virtual void NotifyReadyToDraw() = 0;
106 // Please call these 3 functions through 107 // Please call these 3 functions through
107 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and 108 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and
108 // SetNeedsOneBeginImplFrame(). 109 // SetNeedsOneBeginImplFrame().
109 virtual void SetNeedsRedrawOnImplThread() = 0; 110 virtual void SetNeedsRedrawOnImplThread() = 0;
110 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0; 111 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0;
111 virtual void SetNeedsOneBeginImplFrameOnImplThread() = 0; 112 virtual void SetNeedsOneBeginImplFrameOnImplThread() = 0;
112 virtual void SetNeedsCommitOnImplThread() = 0; 113 virtual void SetNeedsCommitOnImplThread() = 0;
113 virtual void SetNeedsPrepareTilesOnImplThread() = 0; 114 virtual void SetNeedsPrepareTilesOnImplThread() = 0;
114 virtual void SetVideoNeedsBeginFrames(bool needs_begin_frames) = 0; 115 virtual void SetVideoNeedsBeginFrames(bool needs_begin_frames) = 0;
115 virtual void PostAnimationEventsToMainThreadOnImplThread( 116 virtual void PostAnimationEventsToMainThreadOnImplThread(
116 std::unique_ptr<AnimationEvents> events) = 0; 117 std::unique_ptr<AnimationEvents> events) = 0;
117 virtual bool IsInsideDraw() = 0; 118 virtual bool IsInsideDraw() = 0;
118 virtual void RenewTreePriority() = 0; 119 virtual void RenewTreePriority() = 0;
119 virtual void PostDelayedAnimationTaskOnImplThread(const base::Closure& task, 120 virtual void PostDelayedAnimationTaskOnImplThread(const base::Closure& task,
120 base::TimeDelta delay) = 0; 121 base::TimeDelta delay) = 0;
121 virtual void DidActivateSyncTree() = 0; 122 virtual void DidActivateSyncTree() = 0;
122 virtual void WillPrepareTiles() = 0; 123 virtual void WillPrepareTiles() = 0;
123 virtual void DidPrepareTiles() = 0; 124 virtual void DidPrepareTiles() = 0;
124 125
125 // Called when page scale animation has completed on the impl thread. 126 // Called when page scale animation has completed on the impl thread.
126 virtual void DidCompletePageScaleAnimationOnImplThread() = 0; 127 virtual void DidCompletePageScaleAnimationOnImplThread() = 0;
127 128
128 // Called when output surface asks for a draw. 129 // Called when output surface asks for a draw.
129 virtual void OnDrawForOutputSurface(bool resourceless_software_draw) = 0; 130 virtual void OnDrawForCompositorFrameSink(
131 bool resourceless_software_draw) = 0;
130 132
131 protected: 133 protected:
132 virtual ~LayerTreeHostImplClient() {} 134 virtual ~LayerTreeHostImplClient() {}
133 }; 135 };
134 136
135 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering 137 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
136 // state. 138 // state.
137 class CC_EXPORT LayerTreeHostImpl 139 class CC_EXPORT LayerTreeHostImpl
138 : public InputHandler, 140 : public InputHandler,
139 public TileManagerClient, 141 public TileManagerClient,
140 public OutputSurfaceClient, 142 public CompositorFrameSinkClient,
141 public TopControlsManagerClient, 143 public TopControlsManagerClient,
142 public ScrollbarAnimationControllerClient, 144 public ScrollbarAnimationControllerClient,
143 public VideoFrameControllerClient, 145 public VideoFrameControllerClient,
144 public LayerTreeMutatorClient, 146 public LayerTreeMutatorClient,
145 public MutatorHostClient, 147 public MutatorHostClient,
146 public base::SupportsWeakPtr<LayerTreeHostImpl> { 148 public base::SupportsWeakPtr<LayerTreeHostImpl> {
147 public: 149 public:
148 static std::unique_ptr<LayerTreeHostImpl> Create( 150 static std::unique_ptr<LayerTreeHostImpl> Create(
149 const LayerTreeSettings& settings, 151 const LayerTreeSettings& settings,
150 LayerTreeHostImplClient* client, 152 LayerTreeHostImplClient* client,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 void PostDelayedScrollbarAnimationTask(const base::Closure& task, 359 void PostDelayedScrollbarAnimationTask(const base::Closure& task,
358 base::TimeDelta delay) override; 360 base::TimeDelta delay) override;
359 void SetNeedsAnimateForScrollbarAnimation() override; 361 void SetNeedsAnimateForScrollbarAnimation() override;
360 void SetNeedsRedrawForScrollbarAnimation() override; 362 void SetNeedsRedrawForScrollbarAnimation() override;
361 ScrollbarSet ScrollbarsFor(int scroll_layer_id) const override; 363 ScrollbarSet ScrollbarsFor(int scroll_layer_id) const override;
362 364
363 // VideoBeginFrameSource implementation. 365 // VideoBeginFrameSource implementation.
364 void AddVideoFrameController(VideoFrameController* controller) override; 366 void AddVideoFrameController(VideoFrameController* controller) override;
365 void RemoveVideoFrameController(VideoFrameController* controller) override; 367 void RemoveVideoFrameController(VideoFrameController* controller) override;
366 368
367 // OutputSurfaceClient implementation. 369 // CompositorFrameSinkClient implementation.
368 void SetBeginFrameSource(BeginFrameSource* source) override; 370 void SetBeginFrameSource(BeginFrameSource* source) override;
369 void SetNeedsRedrawRect(const gfx::Rect& rect) override; 371 void SetNeedsRedrawRect(const gfx::Rect& rect) override;
370 void SetExternalTilePriorityConstraints( 372 void SetExternalTilePriorityConstraints(
371 const gfx::Rect& viewport_rect, 373 const gfx::Rect& viewport_rect,
372 const gfx::Transform& transform) override; 374 const gfx::Transform& transform) override;
373 void DidLoseOutputSurface() override; 375 void DidLoseCompositorFrameSink() override;
374 void DidSwapBuffersComplete() override; 376 void DidSwapBuffersComplete() override;
375 void DidReceiveTextureInUseResponses( 377 void DidReceiveTextureInUseResponses(
376 const gpu::TextureInUseResponses& responses) override; 378 const gpu::TextureInUseResponses& responses) override;
377 void ReclaimResources(const ReturnedResourceArray& resources) override; 379 void ReclaimResources(const ReturnedResourceArray& resources) override;
378 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; 380 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override;
379 void SetTreeActivationCallback(const base::Closure& callback) override; 381 void SetTreeActivationCallback(const base::Closure& callback) override;
380 void OnDraw(const gfx::Transform& transform, 382 void OnDraw(const gfx::Transform& transform,
381 const gfx::Rect& viewport, 383 const gfx::Rect& viewport,
382 bool resourceless_software_draw) override; 384 bool resourceless_software_draw) override;
383 385
384 // LayerTreeMutatorClient. 386 // LayerTreeMutatorClient.
385 void SetNeedsMutate() override; 387 void SetNeedsMutate() override;
386 388
387 // Called from LayerTreeImpl. 389 // Called from LayerTreeImpl.
388 void OnCanDrawStateChangedForTree(); 390 void OnCanDrawStateChangedForTree();
389 391
390 // Implementation. 392 // Implementation.
391 int id() const { return id_; } 393 int id() const { return id_; }
392 bool CanDraw() const; 394 bool CanDraw() const;
393 OutputSurface* output_surface() const { return output_surface_; } 395 CompositorFrameSink* compositor_frame_sink() const {
394 void ReleaseOutputSurface(); 396 return compositor_frame_sink_;
397 }
398 void ReleaseCompositorFrameSink();
395 399
396 std::string LayerTreeAsJson() const; 400 std::string LayerTreeAsJson() const;
397 401
398 int RequestedMSAASampleCount() const; 402 int RequestedMSAASampleCount() const;
399 403
400 // TODO(danakj): Rename this, there is no renderer. 404 // TODO(danakj): Rename this, there is no renderer.
401 virtual bool InitializeRenderer(OutputSurface* output_surface); 405 virtual bool InitializeRenderer(CompositorFrameSink* compositor_frame_sink);
402 TileManager* tile_manager() { return &tile_manager_; } 406 TileManager* tile_manager() { return &tile_manager_; }
403 407
404 void SetHasGpuRasterizationTrigger(bool flag); 408 void SetHasGpuRasterizationTrigger(bool flag);
405 void SetContentIsSuitableForGpuRasterization(bool flag); 409 void SetContentIsSuitableForGpuRasterization(bool flag);
406 bool CanUseGpuRasterization(); 410 bool CanUseGpuRasterization();
407 bool use_gpu_rasterization() const { return use_gpu_rasterization_; } 411 bool use_gpu_rasterization() const { return use_gpu_rasterization_; }
408 bool use_msaa() const { return use_msaa_; } 412 bool use_msaa() const { return use_msaa_; }
409 413
410 GpuRasterizationStatus gpu_rasterization_status() const { 414 GpuRasterizationStatus gpu_rasterization_status() const {
411 return gpu_rasterization_status_; 415 return gpu_rasterization_status_;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 void SetWorkerContextVisibility(bool is_visible); 715 void SetWorkerContextVisibility(bool is_visible);
712 716
713 using UIResourceMap = std::unordered_map<UIResourceId, UIResourceData>; 717 using UIResourceMap = std::unordered_map<UIResourceId, UIResourceData>;
714 UIResourceMap ui_resource_map_; 718 UIResourceMap ui_resource_map_;
715 719
716 // Resources that were evicted by EvictAllUIResources. Resources are removed 720 // Resources that were evicted by EvictAllUIResources. Resources are removed
717 // from this when they are touched by a create or destroy from the UI resource 721 // from this when they are touched by a create or destroy from the UI resource
718 // request queue. 722 // request queue.
719 std::set<UIResourceId> evicted_ui_resources_; 723 std::set<UIResourceId> evicted_ui_resources_;
720 724
721 OutputSurface* output_surface_; 725 CompositorFrameSink* compositor_frame_sink_;
722 726
723 // The following scoped variables must not outlive the |output_surface_|. 727 // The following scoped variables must not outlive the
728 // |compositor_frame_sink_|.
724 // These should be transfered to ContextCacheController's 729 // These should be transfered to ContextCacheController's
725 // ClientBecameNotVisible() before the output surface is destroyed. 730 // ClientBecameNotVisible() before the output surface is destroyed.
726 std::unique_ptr<ContextCacheController::ScopedVisibility> 731 std::unique_ptr<ContextCacheController::ScopedVisibility>
727 compositor_context_visibility_; 732 compositor_context_visibility_;
728 std::unique_ptr<ContextCacheController::ScopedVisibility> 733 std::unique_ptr<ContextCacheController::ScopedVisibility>
729 worker_context_visibility_; 734 worker_context_visibility_;
730 735
731 std::unique_ptr<ResourceProvider> resource_provider_; 736 std::unique_ptr<ResourceProvider> resource_provider_;
732 bool need_update_gpu_rasterization_status_; 737 bool need_update_gpu_rasterization_status_;
733 bool content_is_suitable_for_gpu_rasterization_; 738 bool content_is_suitable_for_gpu_rasterization_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 // The maximum memory that would be used by the prioritized resource 796 // The maximum memory that would be used by the prioritized resource
792 // manager, if there were no limit on memory usage. 797 // manager, if there were no limit on memory usage.
793 size_t max_memory_needed_bytes_; 798 size_t max_memory_needed_bytes_;
794 799
795 // Viewport size passed in from the main thread, in physical pixels. This 800 // Viewport size passed in from the main thread, in physical pixels. This
796 // value is the default size for all concepts of physical viewport (draw 801 // value is the default size for all concepts of physical viewport (draw
797 // viewport, scrolling viewport and device viewport), but it can be 802 // viewport, scrolling viewport and device viewport), but it can be
798 // overridden. 803 // overridden.
799 gfx::Size device_viewport_size_; 804 gfx::Size device_viewport_size_;
800 805
801 // Optional top-level constraints that can be set by the OutputSurface. 806 // Optional top-level constraints that can be set by the CompositorFrameSink.
802 // - external_transform_ applies a transform above the root layer 807 // - external_transform_ applies a transform above the root layer
803 // - external_viewport_ is used DrawProperties, tile management and 808 // - external_viewport_ is used DrawProperties, tile management and
804 // glViewport/window projection matrix. 809 // glViewport/window projection matrix.
805 // - viewport_rect_for_tile_priority_ is the rect in view space used for 810 // - viewport_rect_for_tile_priority_ is the rect in view space used for
806 // tiling priority. 811 // tiling priority.
807 gfx::Transform external_transform_; 812 gfx::Transform external_transform_;
808 gfx::Rect external_viewport_; 813 gfx::Rect external_viewport_;
809 gfx::Rect viewport_rect_for_tile_priority_; 814 gfx::Rect viewport_rect_for_tile_priority_;
810 bool resourceless_software_draw_; 815 bool resourceless_software_draw_;
811 816
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 848
844 std::unique_ptr<PendingTreeDurationHistogramTimer> 849 std::unique_ptr<PendingTreeDurationHistogramTimer>
845 pending_tree_duration_timer_; 850 pending_tree_duration_timer_;
846 851
847 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); 852 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
848 }; 853 };
849 854
850 } // namespace cc 855 } // namespace cc
851 856
852 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ 857 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698