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

Side by Side Diff: cc/surfaces/display.h

Issue 2029323004: Get rid of virtual Display::CreateScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onscreendisplayclient
Patch Set: displaytest: androids Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SURFACES_DISPLAY_H_ 5 #ifndef CC_SURFACES_DISPLAY_H_
6 #define CC_SURFACES_DISPLAY_H_ 6 #define CC_SURFACES_DISPLAY_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 class TextureMailboxDeleter; 45 class TextureMailboxDeleter;
46 46
47 // A Display produces a surface that can be used to draw to a physical display 47 // A Display produces a surface that can be used to draw to a physical display
48 // (OutputSurface). The client is responsible for creating and sizing the 48 // (OutputSurface). The client is responsible for creating and sizing the
49 // surface IDs used to draw into the display and deciding when to draw. 49 // surface IDs used to draw into the display and deciding when to draw.
50 class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient, 50 class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient,
51 public OutputSurfaceClient, 51 public OutputSurfaceClient,
52 public RendererClient, 52 public RendererClient,
53 public SurfaceDamageObserver { 53 public SurfaceDamageObserver {
54 public: 54 public:
55 // When |begin_frame_source| is null, no scheduler is created, and the
56 // owner of this class is responsible for calling DrawAndSwap when needed.
55 Display(SurfaceManager* manager, 57 Display(SurfaceManager* manager,
56 SharedBitmapManager* bitmap_manager, 58 SharedBitmapManager* bitmap_manager,
57 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 59 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
58 const RendererSettings& settings, 60 const RendererSettings& settings,
59 uint32_t compositor_surface_namespace, 61 uint32_t compositor_surface_namespace,
60 base::SingleThreadTaskRunner* task_runner, 62 base::SingleThreadTaskRunner* task_runner,
63 BeginFrameSource* begin_frame_source,
61 std::unique_ptr<OutputSurface> output_surface); 64 std::unique_ptr<OutputSurface> output_surface);
65
66 // For tests. A delegating constructor that overrides the scheduler
67 // used in the Display. For tests.
68 Display(SurfaceManager* manager,
69 SharedBitmapManager* bitmap_manager,
70 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
71 const RendererSettings& settings,
72 uint32_t compositor_surface_namespace,
73 base::SingleThreadTaskRunner* task_runner,
74 BeginFrameSource* begin_frame_source,
75 std::unique_ptr<OutputSurface> output_surface,
76 std::unique_ptr<DisplayScheduler> display_scheduler_for_tests);
77
62 ~Display() override; 78 ~Display() override;
63 79
64 bool Initialize(DisplayClient* client); 80 bool Initialize(DisplayClient* client);
65 81
66 // When this variant is used, no DisplayScheduler is created, and the caller
67 // is responsible for calling DrawAndSwap when required.
68 bool InitializeSynchronous(DisplayClient* client);
69
70 // device_scale_factor is used to communicate to the external window system 82 // device_scale_factor is used to communicate to the external window system
71 // what scale this was rendered at. 83 // what scale this was rendered at.
72 void SetSurfaceId(SurfaceId id, float device_scale_factor); 84 void SetSurfaceId(SurfaceId id, float device_scale_factor);
73 void Resize(const gfx::Size& new_size); 85 void Resize(const gfx::Size& new_size);
74 void SetExternalClip(const gfx::Rect& clip); 86 void SetExternalClip(const gfx::Rect& clip);
75 void SetOutputIsSecure(bool secure); 87 void SetOutputIsSecure(bool secure);
76 88
77 SurfaceId CurrentSurfaceId(); 89 SurfaceId CurrentSurfaceId();
78 90
79 // DisplaySchedulerClient implementation. 91 // DisplaySchedulerClient implementation.
80 bool DrawAndSwap() override; 92 bool DrawAndSwap() override;
81 93
82 // OutputSurfaceClient implementation. 94 // OutputSurfaceClient implementation.
83 void CommitVSyncParameters(base::TimeTicks timebase, 95 void CommitVSyncParameters(base::TimeTicks timebase,
84 base::TimeDelta interval) override {} 96 base::TimeDelta interval) override;
85 void SetBeginFrameSource(BeginFrameSource* source) override; 97 void SetBeginFrameSource(BeginFrameSource* source) override;
86 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override; 98 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override;
87 void DidSwapBuffers() override; 99 void DidSwapBuffers() override;
88 void DidSwapBuffersComplete() override; 100 void DidSwapBuffersComplete() override;
89 void ReclaimResources(const CompositorFrameAck* ack) override; 101 void ReclaimResources(const CompositorFrameAck* ack) override;
90 void DidLoseOutputSurface() override; 102 void DidLoseOutputSurface() override;
91 void SetExternalTilePriorityConstraints( 103 void SetExternalTilePriorityConstraints(
92 const gfx::Rect& viewport_rect, 104 const gfx::Rect& viewport_rect,
93 const gfx::Transform& transform) override; 105 const gfx::Transform& transform) override;
94 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override; 106 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override;
95 void SetTreeActivationCallback(const base::Closure& callback) override; 107 void SetTreeActivationCallback(const base::Closure& callback) override;
96 void OnDraw(const gfx::Transform& transform, 108 void OnDraw(const gfx::Transform& transform,
97 const gfx::Rect& viewport, 109 const gfx::Rect& viewport,
98 const gfx::Rect& clip, 110 const gfx::Rect& clip,
99 bool resourceless_software_draw) override; 111 bool resourceless_software_draw) override;
100 112
101 // RendererClient implementation. 113 // RendererClient implementation.
102 void SetFullRootLayerDamage() override; 114 void SetFullRootLayerDamage() override;
103 115
104 // SurfaceDamageObserver implementation. 116 // SurfaceDamageObserver implementation.
105 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override; 117 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override;
106 118
107 void SetEnlargePassTextureAmountForTesting( 119 void SetEnlargePassTextureAmountForTesting(
108 const gfx::Size& enlarge_texture_amount) { 120 const gfx::Size& enlarge_texture_amount) {
109 enlarge_texture_amount_ = enlarge_texture_amount; 121 enlarge_texture_amount_ = enlarge_texture_amount;
110 } 122 }
111 123
112 protected: 124 protected:
113 // Virtual for tests. 125 DisplayScheduler* SchedulerForTesting() { return scheduler_.get(); }
114 virtual void CreateScheduler();
115 126
127 private:
116 void InitializeRenderer(); 128 void InitializeRenderer();
117 void UpdateRootSurfaceResourcesLocked(); 129 void UpdateRootSurfaceResourcesLocked();
118 130
119 DisplayClient* client_; 131 DisplayClient* client_;
120 SurfaceManager* surface_manager_; 132 SurfaceManager* surface_manager_;
121 SharedBitmapManager* bitmap_manager_; 133 SharedBitmapManager* bitmap_manager_;
122 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; 134 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
123 RendererSettings settings_; 135 RendererSettings settings_;
124 SurfaceId current_surface_id_; 136 SurfaceId current_surface_id_;
125 uint32_t compositor_surface_namespace_; 137 uint32_t compositor_surface_namespace_;
126 gfx::Size current_surface_size_; 138 gfx::Size current_surface_size_;
127 float device_scale_factor_ = 1.f; 139 float device_scale_factor_ = 1.f;
128 bool swapped_since_resize_ = false; 140 bool swapped_since_resize_ = false;
129 gfx::Rect external_clip_; 141 gfx::Rect external_clip_;
130 gfx::Size enlarge_texture_amount_; 142 gfx::Size enlarge_texture_amount_;
131 bool output_is_secure_ = false; 143 bool output_is_secure_ = false;
132 144
133 // TODO(danakj): Not needed if we create the scheduler from the constructor.
134 base::SingleThreadTaskRunner* task_runner_;
135
136 std::unique_ptr<OutputSurface> output_surface_; 145 std::unique_ptr<OutputSurface> output_surface_;
137 // An internal synthetic BFS. May be null when not used. 146 // An internal synthetic BFS. May be null when not used.
138 std::unique_ptr<BeginFrameSource> internal_begin_frame_source_; 147 std::unique_ptr<BeginFrameSource> internal_begin_frame_source_;
139 // The real BFS tied to vsync provided by the BrowserCompositorOutputSurface. 148 // The real BFS tied to vsync provided by the BrowserCompositorOutputSurface.
140 BeginFrameSource* vsync_begin_frame_source_ = nullptr; 149 BeginFrameSource* vsync_begin_frame_source_ = nullptr;
141 // The current BFS driving the Display/DisplayScheduler. 150 // The current BFS driving the Display/DisplayScheduler.
142 BeginFrameSource* observed_begin_frame_source_ = nullptr; 151 BeginFrameSource* observed_begin_frame_source_ = nullptr;
143 std::unique_ptr<DisplayScheduler> scheduler_; 152 std::unique_ptr<DisplayScheduler> scheduler_;
144 std::unique_ptr<ResourceProvider> resource_provider_; 153 std::unique_ptr<ResourceProvider> resource_provider_;
145 std::unique_ptr<SurfaceAggregator> aggregator_; 154 std::unique_ptr<SurfaceAggregator> aggregator_;
146 TextureMailboxDeleter texture_mailbox_deleter_; 155 TextureMailboxDeleter texture_mailbox_deleter_;
147 std::unique_ptr<DirectRenderer> renderer_; 156 std::unique_ptr<DirectRenderer> renderer_;
148 std::vector<ui::LatencyInfo> stored_latency_info_; 157 std::vector<ui::LatencyInfo> stored_latency_info_;
149 158
150 private: 159 private:
151 DISALLOW_COPY_AND_ASSIGN(Display); 160 DISALLOW_COPY_AND_ASSIGN(Display);
152 }; 161 };
153 162
154 } // namespace cc 163 } // namespace cc
155 164
156 #endif // CC_SURFACES_DISPLAY_H_ 165 #endif // CC_SURFACES_DISPLAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698