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