Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / cc / output / begin_frame_args.h
1 // Copyright 2013 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.
4
5 #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_
6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h"
10 #include "base/values.h"
11 #include "cc/base/cc_export.h"
12
13 namespace base {
14 namespace debug {
15 class ConvertableToTraceFormat;
16 class TracedValue;
17 }
18 }
19
20 namespace cc {
21
22 struct CC_EXPORT BeginFrameArgs {
23   enum BeginFrameArgsType {
24     INVALID,
25     NORMAL,
26     SYNCHRONOUS,
27     MISSED,
28   };
29
30   // Creates an invalid set of values.
31   BeginFrameArgs();
32
33   // You should be able to find all instances where a BeginFrame has been
34   // created by searching for "BeginFrameArgs::Create".
35   static BeginFrameArgs Create(base::TimeTicks frame_time,
36                                base::TimeTicks deadline,
37                                base::TimeDelta interval);
38   static BeginFrameArgs CreateTyped(base::TimeTicks frame_time,
39                                     base::TimeTicks deadline,
40                                     base::TimeDelta interval,
41                                     BeginFrameArgsType type);
42   static BeginFrameArgs CreateForSynchronousCompositor(
43       base::TimeTicks now = base::TimeTicks());
44
45   // This is the default delta that will be used to adjust the deadline when
46   // proper draw-time estimations are not yet available.
47   static base::TimeDelta DefaultEstimatedParentDrawTime();
48
49   // This is the default interval to use to avoid sprinkling the code with
50   // magic numbers.
51   static base::TimeDelta DefaultInterval();
52
53   // This is the default amount of time after the frame_time to retroactively
54   // send a BeginFrame that had been skipped. This only has an effect if the
55   // deadline has passed, since the deadline is also used to trigger BeginFrame
56   // retroactively.
57   static base::TimeDelta DefaultRetroactiveBeginFramePeriod();
58
59   bool IsValid() const { return interval >= base::TimeDelta(); }
60
61   scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
62   void AsValueInto(base::debug::TracedValue* dict) const;
63
64   base::TimeTicks frame_time;
65   base::TimeTicks deadline;
66   base::TimeDelta interval;
67   BeginFrameArgsType type;
68
69  private:
70   BeginFrameArgs(base::TimeTicks frame_time,
71                  base::TimeTicks deadline,
72                  base::TimeDelta interval,
73                  BeginFrameArgsType type);
74 };
75
76 }  // namespace cc
77
78 #endif  // CC_OUTPUT_BEGIN_FRAME_ARGS_H_