summaryrefslogtreecommitdiff
path: root/chromium/cc/output/begin_frame_args.h
blob: 025a4075c25e6b84ab9597dabac7e5c83b34ea1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_
#define CC_OUTPUT_BEGIN_FRAME_ARGS_H_

#include "base/time/time.h"
#include "cc/base/cc_export.h"

namespace cc {

struct CC_EXPORT BeginFrameArgs {
  // Creates an invalid set of values.
  BeginFrameArgs();

  // You should be able to find all instances where a BeginFrame has been
  // created by searching for "BeginFrameArgs::Create".
  static BeginFrameArgs Create(base::TimeTicks frame_time,
                               base::TimeTicks deadline,
                               base::TimeDelta interval);
  static BeginFrameArgs CreateForSynchronousCompositor();
  static BeginFrameArgs CreateForTesting();
  static BeginFrameArgs CreateExpiredForTesting();

  // This is the default delta that will be used to adjust the deadline when
  // proper draw-time estimations are not yet available.
  static base::TimeDelta DefaultDeadlineAdjustment();

  // This is the default interval to use to avoid sprinkling the code with
  // magic numbers.
  static base::TimeDelta DefaultInterval();

  // This is the default amount of time after the frame_time to retroactively
  // send a BeginFrame that had been skipped. This only has an effect if the
  // deadline has passed, since the deadline is also used to trigger BeginFrame
  // retroactively.
  static base::TimeDelta DefaultRetroactiveBeginFramePeriod();

  bool IsValid() const { return interval >= base::TimeDelta(); }

  base::TimeTicks frame_time;
  base::TimeTicks deadline;
  base::TimeDelta interval;

 private:
  BeginFrameArgs(base::TimeTicks frame_time,
                 base::TimeTicks deadline,
                 base::TimeDelta interval);
};

}  // namespace cc

#endif  // CC_OUTPUT_BEGIN_FRAME_ARGS_H_