hwc/overlay: Implement rotator caching
* A non-updating layer requiring rotation, can make use of
the older rotator buffer written when the layer got first
updated, rather than invoking a new rotator cycle.
* A rotator play is avoided in cases where incoming layer
buffer fd, offset, whf, src-rect, dst-rect, etc are similar
to that of the previous input layer to the rotator.
* For ex: In a usecase where video layer updates happen at
30fps and all other asynchrous UI updates happen at 60fps,
instead of the traditional 60 calls of rotator play per sec,
we now do only 30 thereby saving rotator bandwidth.
* Property "debug.rotcache.disable" can be used to disable
this feature.
Change-Id: I1d1c352c63007b7e0b4fee40882086ccd2f5a4aa
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index f3243fc..944f152 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -1324,7 +1324,9 @@
rotData.acq_fen_fd_cnt = 1; //1 ioctl call per rot session
}
int ret = 0;
- ret = ioctl(rotFd, MSMFB_BUFFER_SYNC, &rotData);
+ if(not ctx->mLayerRotMap[dpy]->isRotCached(i))
+ ret = ioctl(rotFd, MSMFB_BUFFER_SYNC, &rotData);
+
if(ret < 0) {
ALOGE("%s: ioctl MSMFB_BUFFER_SYNC failed for rot sync, err=%s",
__FUNCTION__, strerror(errno));
@@ -2260,9 +2262,27 @@
reset();
}
+bool LayerRotMap::isRotCached(uint32_t index) const {
+ overlay::Rotator* rot = getRot(index);
+ hwc_layer_1_t* layer = getLayer(index);
+
+ if(rot and layer and layer->handle) {
+ private_handle_t *hnd = (private_handle_t *)(layer->handle);
+ return (rot->isRotCached(hnd->fd,(uint32_t)(hnd->offset)));
+ }
+ return false;
+}
+
void LayerRotMap::setReleaseFd(const int& fence) {
for(uint32_t i = 0; i < mCount; i++) {
- mRot[i]->setReleaseFd(dup(fence));
+ if(mRot[i] and mLayer[i] and mLayer[i]->handle) {
+ /* Ensure that none of the above (Rotator-instance,
+ * layer and layer-handle) are NULL*/
+ if(isRotCached(i))
+ mRot[i]->setPrevBufReleaseFd(dup(fence));
+ else
+ mRot[i]->setCurrBufReleaseFd(dup(fence));
+ }
}
}