1
0
Fork 0

drm_hwcomposer: Don't pass hwc_procs_t to VsyncWorker

Introduce a new class to limit the hwc_procs_t callback
structure scope to hwcomposer.cpp

Change-Id: I68ec62e7947ca87702b3d6d0169ae850cfbf5d85
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
This commit is contained in:
Sean Paul 2016-02-10 10:00:08 -08:00 committed by Robert Foss
parent 8600e347e1
commit a5df1defa1
3 changed files with 37 additions and 13 deletions

View file

@ -34,7 +34,6 @@ namespace android {
VSyncWorker::VSyncWorker()
: Worker("vsync", HAL_PRIORITY_URGENT_DISPLAY),
drm_(NULL),
procs_(NULL),
display_(-1),
last_timestamp_(-1) {
}
@ -49,14 +48,14 @@ int VSyncWorker::Init(DrmResources *drm, int display) {
return InitWorker();
}
int VSyncWorker::SetProcs(hwc_procs_t const *procs) {
int VSyncWorker::RegisterCallback(std::shared_ptr<VsyncCallback> callback) {
int ret = Lock();
if (ret) {
ALOGE("Failed to lock vsync worker lock %d\n", ret);
return ret;
}
procs_ = procs;
callback_ = callback;
ret = Unlock();
if (ret) {
@ -151,7 +150,7 @@ void VSyncWorker::Routine() {
bool enabled = enabled_;
int display = display_;
hwc_procs_t const *procs = procs_;
std::shared_ptr<VsyncCallback> callback(callback_);
ret = Unlock();
if (ret) {
@ -188,16 +187,16 @@ void VSyncWorker::Routine() {
}
/*
* There's a race here where a change in procs_ will not take effect until
* There's a race here where a change in callback_ will not take effect until
* the next subsequent requested vsync. This is unavoidable since we can't
* call the vsync hook while holding the thread lock.
*
* We could shorten the race window by caching procs_ right before calling
* the hook. However, in practice, procs_ is only updated once, so it's not
* We could shorten the race window by caching callback_ right before calling
* the hook. However, in practice, callback_ is only updated once, so it's not
* worth the overhead.
*/
if (procs && procs->vsync)
procs->vsync(procs, display, timestamp);
if (callback)
callback->Callback(display, timestamp);
last_timestamp_ = timestamp;
}
}