Setup a experiment to enable background tracing.
[chromium-blink-merge.git] / cc / surfaces / display_scheduler.h
blobae2ce8095e7eb1dbd76e1e7d61f2cb895839c538
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_SURFACES_DISPLAY_SCHEDULER_H_
6 #define CC_SURFACES_DISPLAY_SCHEDULER_H_
8 #include "base/cancelable_callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h"
12 #include "cc/scheduler/begin_frame_source.h"
13 #include "cc/surfaces/surface_id.h"
14 #include "cc/surfaces/surfaces_export.h"
16 namespace cc {
18 class OutputSurface;
19 class BeginFrameSource;
21 // TODO(brianderson): Reconcile with SurfacesScheduler crbug.com/476676
22 class CC_SURFACES_EXPORT DisplaySchedulerClient {
23 public:
24 virtual ~DisplaySchedulerClient() {}
26 virtual bool DrawAndSwap() = 0;
29 class CC_SURFACES_EXPORT DisplayScheduler : public BeginFrameObserverMixIn {
30 public:
31 DisplayScheduler(DisplaySchedulerClient* client,
32 BeginFrameSource* begin_frame_source,
33 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
34 int max_pending_swaps);
35 ~DisplayScheduler() override;
37 void SetRootSurfaceResourcesLocked(bool locked);
38 void ForceImmediateSwapIfPossible();
39 virtual void EntireDisplayDamaged(SurfaceId root_surface_id);
40 virtual void SurfaceDamaged(SurfaceId surface_id);
42 virtual void DidSwapBuffers();
43 void DidSwapBuffersComplete();
45 void OutputSurfaceLost();
47 // BeginFrameObserverMixIn implementation
48 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override;
50 protected:
51 base::TimeTicks DesiredBeginFrameDeadlineTime();
52 virtual void ScheduleBeginFrameDeadline();
53 void AttemptDrawAndSwap();
54 void OnBeginFrameDeadline();
55 void DrawAndSwap();
57 DisplaySchedulerClient* client_;
58 BeginFrameSource* begin_frame_source_;
59 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
61 BeginFrameArgs current_begin_frame_args_;
62 base::Closure begin_frame_deadline_closure_;
63 base::CancelableClosure begin_frame_deadline_task_;
64 base::TimeTicks begin_frame_deadline_task_time_;
66 bool output_surface_lost_;
67 bool root_surface_resources_locked_;
69 bool inside_begin_frame_deadline_interval_;
70 bool needs_draw_;
71 bool entire_display_damaged_;
72 bool all_active_child_surfaces_ready_to_draw_;
74 int pending_swaps_;
75 int max_pending_swaps_;
77 SurfaceId root_surface_id_;
78 bool root_surface_damaged_;
79 bool expect_damage_from_root_surface_;
81 std::set<SurfaceId> child_surface_ids_damaged_;
82 std::set<SurfaceId> child_surface_ids_damaged_prev_;
83 std::vector<SurfaceId> child_surface_ids_to_expect_damage_from_;
85 base::WeakPtrFactory<DisplayScheduler> weak_ptr_factory_;
87 private:
88 DISALLOW_COPY_AND_ASSIGN(DisplayScheduler);
91 } // namespace cc
93 #endif // CC_SURFACES_DISPLAY_SCHEDULER_H_