/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package android.surfaceflinger;

option optimize_for = LITE_RUNTIME;

message SFTimeStatsGlobalProto {
  // The start & end timestamps in UTC as
  // milliseconds since January 1, 1970
  optional int64 stats_start = 1;
  optional int64 stats_end = 2;
  // Total frames
  optional int32 total_frames = 3;
  // Total missed frames of SurfaceFlinger.
  optional int32 missed_frames = 4;
  // Total frames fallback to client composition.
  optional int32 client_composition_frames = 5;

  repeated SFTimeStatsLayerProto stats = 6;
}

message SFTimeStatsLayerProto {
  // The layer name
  optional string layer_name = 1;
  // The package name
  optional string package_name = 2;
  // The start & end timestamps in UTC as
  // milliseconds since January 1, 1970
  optional int64 stats_start = 3;
  optional int64 stats_end = 4;
  // Distinct frame count.
  optional int32 total_frames = 5;

  repeated SFTimeStatsDeltaProto deltas = 6;
}

message SFTimeStatsDeltaProto {
  // Name of the time interval
  optional string delta_name = 1;
  // Histogram of the delta time
  repeated SFTimeStatsHistogramBucketProto histograms = 2;
}

message SFTimeStatsHistogramBucketProto {
  // Lower bound of render time in milliseconds.
  optional int32 render_millis = 1;
  // Number of frames in the bucket.
  optional int32 frame_count = 2;
}
