hwcomposer : Fix cache redraw logic of MDP composition.
Redraw the cache if current frame cache/drop data doesn't
match with cached frame data. Frame buffer z-order, fbcount
and mdp count are not reliable. With same fbz, fbcount and
mdpcount it is possible that layers in previous cached
frame are not part of current frame fb cache.
Change-Id: I858228dc1a3a8ab8673ab8d294e54fdbf43cc1ad
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index ff33e94..aacad00 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -242,10 +242,9 @@
void MDPComp::LayerCache::reset() {
memset(&hnd, 0, sizeof(hnd));
- mdpCount = 0;
- fbCount = 0;
+ memset(&isFBComposed, true, sizeof(isFBComposed));
+ memset(&drop, false, sizeof(drop));
layerCount = 0;
- fbZ = -1;
}
void MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) {
@@ -256,10 +255,21 @@
}
void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) {
- mdpCount = curFrame.mdpCount;
- fbCount = curFrame.fbCount;
layerCount = curFrame.layerCount;
- fbZ = curFrame.fbZ;
+ memcpy(&isFBComposed, &curFrame.isFBComposed, sizeof(isFBComposed));
+ memcpy(&drop, &curFrame.drop, sizeof(drop));
+}
+
+bool MDPComp::LayerCache::isSameFrame(const FrameInfo& curFrame) {
+ if(layerCount != curFrame.layerCount)
+ return false;
+ for(int i = 0; i < curFrame.layerCount; i++) {
+ if((curFrame.isFBComposed[i] != isFBComposed[i]) ||
+ (curFrame.drop[i] != drop[i])) {
+ return false;
+ }
+ }
+ return true;
}
bool MDPComp::isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer) {
@@ -1084,13 +1094,9 @@
} else { //Success
//Any change in composition types needs an FB refresh
mCurrentFrame.needsRedraw = false;
- if(mCurrentFrame.fbCount &&
- ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) ||
- (mCurrentFrame.fbCount != mCachedFrame.fbCount) ||
- (mCurrentFrame.fbZ != mCachedFrame.fbZ) ||
- (!mCurrentFrame.mdpCount) ||
+ if(!mCachedFrame.isSameFrame(mCurrentFrame) ||
(list->flags & HWC_GEOMETRY_CHANGED) ||
- isSkipPresent(ctx, mDpy))) {
+ isSkipPresent(ctx, mDpy)) {
mCurrentFrame.needsRedraw = true;
}
}
diff --git a/libhwcomposer/hwc_mdpcomp.h b/libhwcomposer/hwc_mdpcomp.h
index e1839cd..4aa21cc 100644
--- a/libhwcomposer/hwc_mdpcomp.h
+++ b/libhwcomposer/hwc_mdpcomp.h
@@ -108,10 +108,9 @@
/* cached data */
struct LayerCache {
int layerCount;
- int mdpCount;
- int fbCount;
- int fbZ;
buffer_handle_t hnd[MAX_NUM_APP_LAYERS];
+ bool isFBComposed[MAX_NUM_APP_LAYERS];
+ bool drop[MAX_NUM_APP_LAYERS];
/* c'tor */
LayerCache();
@@ -119,6 +118,7 @@
void reset();
void cacheAll(hwc_display_contents_1_t* list);
void updateCounts(const FrameInfo&);
+ bool isSameFrame(const FrameInfo& curFrame);
};
/* allocates pipe from pipe book */