1# Copyright 2014 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
5from telemetry.internal.platform import tracing_agent
6from telemetry.timeline import trace_data
7
8
9class DisplayTracingAgent(tracing_agent.TracingAgent):
10  def __init__(self, platform_backend):
11    super(DisplayTracingAgent, self).__init__(platform_backend)
12
13  @classmethod
14  def IsSupported(cls, platform_backend):
15    return platform_backend.IsDisplayTracingSupported()
16
17  def StartAgentTracing(self, config, timeout):
18    del timeout  # unused
19    if config.enable_platform_display_trace:
20      self._platform_backend.StartDisplayTracing()
21      return True
22
23  def StopAgentTracing(self, trace_data_builder):
24    surface_flinger_trace_data = self._platform_backend.StopDisplayTracing()
25    trace_data_builder.AddEventsTo(
26          trace_data.SURFACE_FLINGER_PART, surface_flinger_trace_data)
27