1#!/usr/bin/env python3 2# Copyright (C) 2019 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16from os import sys, path 17 18import synth_common 19 20class BufferEvent: 21 UNSPECIFIED = 0 22 DEQUEUE = 1 23 QUEUE = 2 24 POST = 3 25 ACQUIRE_FENCE = 4 26 LATCH = 5 27 HWC_COMPOSITION_QUEUED = 6 28 FALLBACK_COMPOSITION = 7 29 PRESENT_FENCE = 8 30 RELEASE_FENCE = 9 31 MODIFY = 10 32 DETACH = 11 33 ATTACH = 12 34 CANCEL = 13 35 36trace = synth_common.create_trace() 37# Layer 1 38trace.add_buffer_event_packet(ts=1, buffer_id=1, layer_name="layer1", frame_number=11, event_type=BufferEvent.DEQUEUE, duration=0) 39trace.add_buffer_event_packet(ts=4, buffer_id=1, layer_name="layer1", frame_number=11, event_type=BufferEvent.QUEUE, duration=0) 40trace.add_buffer_event_packet(ts=6, buffer_id=1, layer_name="layer1", frame_number=11, event_type=BufferEvent.ACQUIRE_FENCE, duration=0) 41trace.add_buffer_event_packet(ts=8, buffer_id=1, layer_name="layer1", frame_number=11, event_type=BufferEvent.LATCH, duration=0) 42trace.add_buffer_event_packet(ts=14, buffer_id=1, layer_name="layer1", frame_number=11, event_type=BufferEvent.PRESENT_FENCE, duration=0) 43# Layer 2 44trace.add_buffer_event_packet(ts=6, buffer_id=2, layer_name="layer2", frame_number=12, event_type=BufferEvent.DEQUEUE, duration=0) 45trace.add_buffer_event_packet(ts=8, buffer_id=2, layer_name="layer2", frame_number=12, event_type=BufferEvent.ACQUIRE_FENCE, duration=0) 46trace.add_buffer_event_packet(ts=9, buffer_id=2, layer_name="layer2", frame_number=12, event_type=BufferEvent.QUEUE, duration=0) 47trace.add_buffer_event_packet(ts=11, buffer_id=2, layer_name="layer2", frame_number=12, event_type=BufferEvent.LATCH, duration=0) 48trace.add_buffer_event_packet(ts=16, buffer_id=2, layer_name="layer2", frame_number=12, event_type=BufferEvent.PRESENT_FENCE, duration=0) 49# Next Present of layer 1 50trace.add_buffer_event_packet(ts=24, buffer_id=1, layer_name="layer1", frame_number=13, event_type=BufferEvent.PRESENT_FENCE, duration=0) 51# Missing id. 52trace.add_buffer_event_packet(ts=6, buffer_id=-1, layer_name="layer6", frame_number=14, event_type=BufferEvent.HWC_COMPOSITION_QUEUED, duration=0) 53# Missing type. 54trace.add_buffer_event_packet(ts=7, buffer_id=7, layer_name="layer7", frame_number=15, event_type=-1, duration=0) 55# Missing Acquire 56trace.add_buffer_event_packet(ts=31, buffer_id=1, layer_name="layer1", frame_number=21, event_type=BufferEvent.DEQUEUE, duration=0) 57trace.add_buffer_event_packet(ts=34, buffer_id=1, layer_name="layer1", frame_number=21, event_type=BufferEvent.QUEUE, duration=0) 58trace.add_buffer_event_packet(ts=37, buffer_id=1, layer_name="layer1", frame_number=22, event_type=BufferEvent.DEQUEUE, duration=0) 59trace.add_buffer_event_packet(ts=41, buffer_id=1, layer_name="layer1", frame_number=22, event_type=BufferEvent.QUEUE, duration=0) 60trace.add_buffer_event_packet(ts=46, buffer_id=1, layer_name="layer1", frame_number=22, event_type=BufferEvent.ACQUIRE_FENCE, duration=0) 61# Missing queue with acquire 62trace.add_buffer_event_packet(ts=53, buffer_id=2, layer_name="layer2", frame_number=24, event_type=BufferEvent.DEQUEUE, duration=0) 63trace.add_buffer_event_packet(ts=59, buffer_id=2, layer_name="layer2", frame_number=24, event_type=BufferEvent.ACQUIRE_FENCE, duration=0) 64trace.add_buffer_event_packet(ts=61, buffer_id=2, layer_name="layer2", frame_number=24, event_type=BufferEvent.LATCH, duration=0) 65# Missing queue without acquire 66trace.add_buffer_event_packet(ts=63, buffer_id=1, layer_name="layer1", frame_number=25, event_type=BufferEvent.DEQUEUE, duration=0) 67trace.add_buffer_event_packet(ts=73, buffer_id=1, layer_name="layer1", frame_number=26, event_type=BufferEvent.DEQUEUE, duration=0) 68trace.add_buffer_event_packet(ts=75, buffer_id=1, layer_name="layer1", frame_number=26, event_type=BufferEvent.QUEUE, duration=0) 69trace.add_buffer_event_packet(ts=79, buffer_id=1, layer_name="layer1", frame_number=26, event_type=BufferEvent.ACQUIRE_FENCE, duration=0) 70# Same buffer in multiple layers 71trace.add_buffer_event_packet(ts=81, buffer_id=1, layer_name="layer1", frame_number=30, event_type=BufferEvent.DEQUEUE, duration=0) 72trace.add_buffer_event_packet(ts=83, buffer_id=1, layer_name="layer1", frame_number=30, event_type=BufferEvent.QUEUE, duration=0) 73trace.add_buffer_event_packet(ts=90, buffer_id=1, layer_name="layer2", frame_number=35, event_type=BufferEvent.DEQUEUE, duration=0) 74trace.add_buffer_event_packet(ts=92, buffer_id=1, layer_name="layer2", frame_number=35, event_type=BufferEvent.QUEUE, duration=0) 75sys.stdout.buffer.write(trace.trace.SerializeToString()) 76