diff options
Diffstat (limited to 'cc/output/begin_frame_args.cc')
-rw-r--r-- | cc/output/begin_frame_args.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/cc/output/begin_frame_args.cc b/cc/output/begin_frame_args.cc index 216eb52..c50d5f8 100644 --- a/cc/output/begin_frame_args.cc +++ b/cc/output/begin_frame_args.cc @@ -5,6 +5,8 @@ #include "cc/output/begin_frame_args.h" #include "base/trace_event/trace_event_argument.h" +#include "cc/proto/base_conversions.h" +#include "cc/proto/begin_main_frame_and_commit_state.pb.h" namespace cc { @@ -23,6 +25,44 @@ const char* BeginFrameArgs::TypeToString(BeginFrameArgsType type) { return "???"; } +void BeginFrameArgs::BeginFrameArgsTypeToProtobuf( + proto::BeginFrameArgs* proto) const { + switch (type) { + case BeginFrameArgs::INVALID: + proto->set_type(proto::BeginFrameArgs::INVALID); + return; + case BeginFrameArgs::NORMAL: + proto->set_type(proto::BeginFrameArgs::NORMAL); + return; + case BeginFrameArgs::MISSED: + proto->set_type(proto::BeginFrameArgs::MISSED); + return; + case BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX: + proto->set_type(proto::BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX); + return; + } + NOTREACHED(); +} + +void BeginFrameArgs::BeginFrameArgsTypeFromProtobuf( + const proto::BeginFrameArgs& proto) { + switch (proto.type()) { + case proto::BeginFrameArgs::INVALID: + type = BeginFrameArgs::INVALID; + return; + case proto::BeginFrameArgs::NORMAL: + type = BeginFrameArgs::NORMAL; + return; + case proto::BeginFrameArgs::MISSED: + type = BeginFrameArgs::MISSED; + return; + case proto::BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX: + type = BeginFrameArgs::BEGIN_FRAME_ARGS_TYPE_MAX; + return; + } + NOTREACHED(); +} + BeginFrameArgs::BeginFrameArgs() : frame_time(base::TimeTicks()), deadline(base::TimeTicks()), @@ -78,6 +118,22 @@ void BeginFrameArgs::AsValueInto(base::trace_event::TracedValue* state) const { state->SetBoolean("on_critical_path", on_critical_path); } +void BeginFrameArgs::ToProtobuf(proto::BeginFrameArgs* proto) const { + proto->set_frame_time(TimeTicksToProto(frame_time)); + proto->set_deadline(TimeTicksToProto(deadline)); + proto->set_interval(interval.ToInternalValue()); + BeginFrameArgsTypeToProtobuf(proto); + proto->set_on_critical_path(on_critical_path); +} + +void BeginFrameArgs::FromProtobuf(const proto::BeginFrameArgs& proto) { + frame_time = ProtoToTimeTicks(proto.frame_time()); + deadline = ProtoToTimeTicks(proto.deadline()); + interval = base::TimeDelta::FromInternalValue(proto.interval()); + BeginFrameArgsTypeFromProtobuf(proto); + on_critical_path = proto.on_critical_path(); +} + // This is a hard-coded deadline adjustment that assumes 60Hz, to be used in // cases where a good estimated draw time is not known. Using 1/3 of the vsync // as the default adjustment gives the Browser the last 1/3 of a frame to |