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.timeline import importer 6from tracing.trace_data import trace_data as trace_data_module 7 8 9class SurfaceFlingerTimelineImporter(importer.TimelineImporter): 10 def __init__(self, model, trace_data): 11 super(SurfaceFlingerTimelineImporter, self).__init__( 12 model, trace_data, import_order=2) 13 traces = trace_data.GetTracesFor(trace_data_module.SURFACE_FLINGER_PART) 14 assert len(traces) == 1 15 self._events = traces[0] 16 self._surface_flinger_process = None 17 18 @staticmethod 19 def GetSupportedPart(): 20 return trace_data_module.SURFACE_FLINGER_PART 21 22 def ImportEvents(self): 23 for event in self._events: 24 self._surface_flinger_process = self._model.GetOrCreateProcess( 25 event['pid']) 26 self._surface_flinger_process.name = 'SurfaceFlinger' 27 thread = self._surface_flinger_process.GetOrCreateThread(event['tid']) 28 thread.BeginSlice(event['cat'], 29 event['name'], 30 event['ts'], 31 args=event.get('args')) 32 thread.EndSlice(event['ts']) 33 34 def FinalizeImport(self): 35 """Called by the Model after all other importers have imported their 36 events.""" 37 self._model.UpdateBounds() 38 self._model.surface_flinger_process = self._surface_flinger_process 39