1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/*
* Copyright 2019 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.
*/
#pragma once
#include <utils/Timers.h>
#include <scheduler/Fps.h>
#include "VSyncDispatch.h"
namespace android::scheduler {
/*
* VSyncTracker is an interface for providing estimates on future Vsync signal times based on
* historical vsync timing data.
*/
class VSyncTracker {
public:
virtual ~VSyncTracker();
/*
* Adds a known timestamp from a vsync timing source (HWVsync signal, present fence)
* to the model.
*
* \param [in] timestamp The timestamp when the vsync signal was.
* \return True if the timestamp was consistent with the internal model,
* False otherwise
*/
virtual bool addVsyncTimestamp(nsecs_t timestamp) = 0;
/*
* Access the next anticipated vsync time such that the anticipated time >= timePoint.
* This will always give the best accurate at the time of calling; multiple
* calls with the same timePoint might give differing values if the internal model
* is updated.
*
* \param [in] timePoint The point in time after which to estimate a vsync event.
* \return A prediction of the timestamp of a vsync event.
*/
virtual nsecs_t nextAnticipatedVSyncTimeFrom(nsecs_t timePoint) const = 0;
/*
* The current period of the vsync signal.
*
* \return The current period of the vsync signal
*/
virtual nsecs_t currentPeriod() const = 0;
/*
* Inform the tracker that the period is changing and the tracker needs to recalibrate itself.
*
* \param [in] period The period that the system is changing into.
*/
virtual void setPeriod(nsecs_t period) = 0;
/* Inform the tracker that the samples it has are not accurate for prediction. */
virtual void resetModel() = 0;
virtual bool needsMoreSamples() const = 0;
/*
* Checks if a vsync timestamp is in phase for a frame rate
*
* \param [in] timePoint A vsync timestamp
* \param [in] frameRate The frame rate to check for
*/
virtual bool isVSyncInPhase(nsecs_t timePoint, Fps frameRate) const = 0;
virtual void dump(std::string& result) const = 0;
protected:
VSyncTracker(VSyncTracker const&) = delete;
VSyncTracker& operator=(VSyncTracker const&) = delete;
VSyncTracker() = default;
};
} // namespace android::scheduler
|