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/liboverlay/overlayMdpRot.cpp b/liboverlay/overlayMdpRot.cpp
index 6105736..d322897 100755
--- a/liboverlay/overlayMdpRot.cpp
+++ b/liboverlay/overlayMdpRot.cpp
@@ -37,10 +37,18 @@
void MdpRot::setRotations(uint32_t r) { mRotImgInfo.rotations = (uint8_t)r; }
+int MdpRot::getSrcMemId() const {
+ return mRotDataInfo.src.memory_id;
+}
+
int MdpRot::getDstMemId() const {
return mRotDataInfo.dst.memory_id;
}
+uint32_t MdpRot::getSrcOffset() const {
+ return mRotDataInfo.src.offset;
+}
+
uint32_t MdpRot::getDstOffset() const {
return mRotDataInfo.dst.offset;
}
@@ -147,7 +155,6 @@
mRotImgInfo.enable = 0;
return false;
}
- save();
mRotDataInfo.session_id = mRotImgInfo.session_id;
}
return true;
@@ -238,7 +245,10 @@
}
bool MdpRot::queueBuffer(int fd, uint32_t offset) {
- if(enabled()) {
+ if(enabled() and (not isRotCached(fd,offset))) {
+ int prev_fd = getSrcMemId();
+ uint32_t prev_offset = getSrcOffset();
+
mRotDataInfo.src.memory_id = fd;
mRotDataInfo.src.offset = offset;
@@ -249,14 +259,17 @@
mRotDataInfo.dst.offset =
mMem.mRotOffset[mMem.mCurrIndex];
- mMem.mCurrIndex =
- (mMem.mCurrIndex + 1) % mMem.mem.numBufs();
if(!overlay::mdp_wrapper::rotate(mFd.getFD(), mRotDataInfo)) {
ALOGE("MdpRot failed rotate");
dump();
+ mRotDataInfo.src.memory_id = prev_fd;
+ mRotDataInfo.src.offset = prev_offset;
return false;
}
+ save();
+ mMem.mCurrIndex =
+ (mMem.mCurrIndex + 1) % mMem.mem.numBufs();
}
return true;
}