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

Side by Side Diff: ui/compositor/compositor.h

Issue 638653003: Make ui::Compositor use ui::Scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase with enable mode patch since that would probably go in before this Created 6 years 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 (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 <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "cc/surfaces/surface_sequence.h" 16 #include "cc/surfaces/surface_sequence.h"
17 #include "cc/trees/layer_tree_host_client.h" 17 #include "cc/trees/layer_tree_host_client.h"
18 #include "cc/trees/layer_tree_host_single_thread_client.h" 18 #include "cc/trees/layer_tree_host_single_thread_client.h"
19 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
20 #include "ui/compositor/compositor_animation_observer.h" 20 #include "ui/compositor/compositor_animation_observer.h"
21 #include "ui/compositor/compositor_export.h" 21 #include "ui/compositor/compositor_export.h"
22 #include "ui/compositor/compositor_observer.h" 22 #include "ui/compositor/compositor_observer.h"
23 #include "ui/compositor/layer_animator_collection.h" 23 #include "ui/compositor/layer_animator_collection.h"
24 #include "ui/gfx/native_widget_types.h" 24 #include "ui/gfx/native_widget_types.h"
25 #include "ui/gfx/size.h" 25 #include "ui/gfx/size.h"
26 #include "ui/gfx/vector2d.h" 26 #include "ui/gfx/vector2d.h"
27 27
28 class SkBitmap;
29
30 namespace base { 28 namespace base {
31 class MessageLoopProxy; 29 class MessageLoopProxy;
32 class RunLoop; 30 class RunLoop;
33 } 31 }
34 32
35 namespace cc { 33 namespace cc {
36 class ContextProvider; 34 class ContextProvider;
37 class Layer; 35 class Layer;
38 class LayerTreeDebugState; 36 class LayerTreeDebugState;
39 class LayerTreeHost; 37 class LayerTreeHost;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 166
169 // Called when we need the compositor to preserve the alpha channel in the 167 // Called when we need the compositor to preserve the alpha channel in the
170 // output for situations when we want to render transparently atop something 168 // output for situations when we want to render transparently atop something
171 // else, e.g. Aero glass. 169 // else, e.g. Aero glass.
172 void SetHostHasTransparentBackground(bool host_has_transparent_background); 170 void SetHostHasTransparentBackground(bool host_has_transparent_background);
173 171
174 // The scale factor of the device that this compositor is 172 // The scale factor of the device that this compositor is
175 // compositing layers on. 173 // compositing layers on.
176 float device_scale_factor() const { return device_scale_factor_; } 174 float device_scale_factor() const { return device_scale_factor_; }
177 175
178 // Draws the scene created by the layer tree and any visual effects.
179 void Draw();
180
181 // Where possible, draws are scissored to a damage region calculated from 176 // Where possible, draws are scissored to a damage region calculated from
182 // changes to layer properties. This bypasses that and indicates that 177 // changes to layer properties. This bypasses that and indicates that
183 // the whole frame needs to be drawn. 178 // the whole frame needs to be drawn.
184 void ScheduleFullRedraw(); 179 void ScheduleFullRedraw();
185 180
186 // Schedule redraw and append damage_rect to the damage region calculated 181 // Schedule redraw and append damage_rect to the damage region calculated
187 // from changes to layer properties. 182 // from changes to layer properties.
188 void ScheduleRedrawRect(const gfx::Rect& damage_rect); 183 void ScheduleRedrawRect(const gfx::Rect& damage_rect);
189 184
190 // Finishes all outstanding rendering and disables swapping on this surface 185 // Finishes all outstanding rendering and disables swapping on this surface
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 float page_scale, 252 float page_scale,
258 float top_controls_delta) override {} 253 float top_controls_delta) override {}
259 void RequestNewOutputSurface(bool fallback) override; 254 void RequestNewOutputSurface(bool fallback) override;
260 void DidInitializeOutputSurface() override {} 255 void DidInitializeOutputSurface() override {}
261 void WillCommit() override {} 256 void WillCommit() override {}
262 void DidCommit() override; 257 void DidCommit() override;
263 void DidCommitAndDrawFrame() override; 258 void DidCommitAndDrawFrame() override;
264 void DidCompleteSwapBuffers() override; 259 void DidCompleteSwapBuffers() override;
265 260
266 // cc::LayerTreeHostSingleThreadClient implementation. 261 // cc::LayerTreeHostSingleThreadClient implementation.
267 void ScheduleComposite() override;
268 void ScheduleAnimation() override;
269 void DidPostSwapBuffers() override; 262 void DidPostSwapBuffers() override;
270 void DidAbortSwapBuffers() override; 263 void DidAbortSwapBuffers() override;
271 264
272 int last_started_frame() { return last_started_frame_; }
273 int last_ended_frame() { return last_ended_frame_; }
274
275 bool IsLocked() { return compositor_lock_ != NULL; } 265 bool IsLocked() { return compositor_lock_ != NULL; }
276 266
277 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; 267 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const;
278 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); 268 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state);
279 const cc::RendererSettings& GetRendererSettings() const; 269 const cc::RendererSettings& GetRendererSettings() const;
280 270
281 LayerAnimatorCollection* layer_animator_collection() { 271 LayerAnimatorCollection* layer_animator_collection() {
282 return &layer_animator_collection_; 272 return &layer_animator_collection_;
283 } 273 }
284 274
285 cc::SurfaceIdAllocator* surface_id_allocator() { 275 cc::SurfaceIdAllocator* surface_id_allocator() {
286 return surface_id_allocator_.get(); 276 return surface_id_allocator_.get();
287 } 277 }
288 278
289 private: 279 private:
290 friend class base::RefCounted<Compositor>; 280 friend class base::RefCounted<Compositor>;
291 friend class CompositorLock; 281 friend class CompositorLock;
292 282
293 // Called by CompositorLock. 283 // Called by CompositorLock.
294 void UnlockCompositor(); 284 void UnlockCompositor();
295 285
296 // Called to release any pending CompositorLock 286 // Called to release any pending CompositorLock
297 void CancelCompositorLock(); 287 void CancelCompositorLock();
298 288
299 // Notifies the compositor that compositing is complete.
300 void NotifyEnd();
301
302 gfx::Size size_; 289 gfx::Size size_;
303 290
304 ui::ContextFactory* context_factory_; 291 ui::ContextFactory* context_factory_;
305 292
306 // The root of the Layer tree drawn by this compositor. 293 // The root of the Layer tree drawn by this compositor.
307 Layer* root_layer_; 294 Layer* root_layer_;
308 295
309 ObserverList<CompositorObserver> observer_list_; 296 ObserverList<CompositorObserver> observer_list_;
310 ObserverList<CompositorAnimationObserver> animation_observer_list_; 297 ObserverList<CompositorAnimationObserver> animation_observer_list_;
311 298
(...skipping 11 matching lines...) Expand all
323 // layers on. 310 // layers on.
324 float device_scale_factor_; 311 float device_scale_factor_;
325 312
326 int last_started_frame_; 313 int last_started_frame_;
327 int last_ended_frame_; 314 int last_ended_frame_;
328 315
329 bool disable_schedule_composite_; 316 bool disable_schedule_composite_;
330 317
331 CompositorLock* compositor_lock_; 318 CompositorLock* compositor_lock_;
332 319
333 // Prevent more than one draw from being scheduled.
334 bool defer_draw_scheduling_;
335
336 // Used to prevent Draw()s while a composite is in progress.
337 bool waiting_on_compositing_end_;
338 bool draw_on_compositing_end_;
339 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED };
340 SwapState swap_state_;
341
342 LayerAnimatorCollection layer_animator_collection_; 320 LayerAnimatorCollection layer_animator_collection_;
343 321
344 base::WeakPtrFactory<Compositor> weak_ptr_factory_; 322 base::WeakPtrFactory<Compositor> weak_ptr_factory_;
345 323
346 DISALLOW_COPY_AND_ASSIGN(Compositor); 324 DISALLOW_COPY_AND_ASSIGN(Compositor);
347 }; 325 };
348 326
349 } // namespace ui 327 } // namespace ui
350 328
351 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 329 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698