blob: fad54a19bb675e5e77ca550fd7323bfafd73e430 [file] [log] [blame]
// Copyright (C) 2015 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
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
// Package replay is used to issue replay requests to replay devices.
package replay
import (
// Generator is the interface for types that support replay generation.
type Generator interface {
// ReplayTransforms is called when a replay pass is ready to be sent to the
// replay device. ReplayTransforms returns an atom transform list that
// transforms the original, unaltered atom stream into a stream configured for
// the replay pass. The transforms should satisfy all the specified requests
// and config.
ctx Context,
cfg Config,
requests []Request,
postback Postback,
device *service.Device,
db database.Database,
logger log.Logger) atom.Transforms
// Context describes the source capture and replay target information used for
// issuing a replay request.
type Context struct {
DeviceID service.DeviceId // The identifier of the device being used for replay.
CaptureID service.CaptureId // The identifier of the capture that is being replayed.
// Config is a user-defined type used to describe the type of replay being
// requested. Replay requests made with configs that have equality (==) will
// likely be batched into the same replay pass. Configs can be used to force
// requests into different replay passes. For example, by issuing requests with
// different configs we can prevent a profiling Request from being issued in the
// same pass as a Request to render all draw calls in wireframe.
type Config interface{}
// Request is a user-defined type that holds information relevant to a single
// replay request. An example Request would be one that informs ReplayTransforms
// to insert a postback of the currently bound render-target content at a
// specific atom.
type Request interface{}
// Postback registers handler to be called with the postback data for the atom
// with the returned identifier. The returned atom identifier is unique,
// enforcing at most one postback handler per atom.
type Postback func(handler PostbackHandler) atom.ID
// PostbackHandler is a callback for an atom's postback data.
// If the postback was successful then data holds the postback data, and err is
// nil. If the postback failed to decode or was missing then data will be nil
// and err will be the error raised.
type PostbackHandler func(data interface{}, err error)