sf: Invalidate and Delay eDisplayProjectionChanged binder transaction
Invalidate and Delay the binder thread by 50 ms on
eDisplayProjectionChanged to trigger a draw cycle, so that it can fix
one incorrect frame on External, when we disable external animation.
Change-Id: I8d10aa8d943e9016f6ab81a5351d8286cdc4d2c6
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index cf9845f..ff8ece6 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1068,24 +1068,29 @@
if (id >= 0) {
// Get the layers in the current drawying state
const LayerVector& layers(mDrawingState.layersSortedByZ);
+#ifdef QCOM_BSP
bool freezeSurfacePresent = false;
const size_t layerCount = layers.size();
char value[PROPERTY_VALUE_MAX];
property_get("sys.disable_ext_animation", value, "0");
- if(atoi(value)) {
+ if(atoi(value) && (id != HWC_DISPLAY_PRIMARY)) {
for (size_t i = 0 ; i < layerCount ; ++i) {
static int screenShotLen = strlen("ScreenshotSurface");
const sp<Layer>& layer(layers[i]);
- if(!strncmp(layer->getName(), "ScreenshotSurface",
+ const Layer::State& s(layer->getDrawingState());
+ // check the layers associated with external display
+ if(s.layerStack == hw->getLayerStack()) {
+ if(!strncmp(layer->getName(), "ScreenshotSurface",
screenShotLen)) {
- // Screenshot layer is present, and animation in
- // progress
- freezeSurfacePresent = true;
- break;
+ // Screenshot layer is present, and animation in
+ // progress
+ freezeSurfacePresent = true;
+ break;
+ }
}
}
}
-
+#endif
const Vector< sp<Layer> >& currentLayers(
hw->getVisibleLayersSortedByZ());
const size_t count = currentLayers.size();
@@ -1098,6 +1103,7 @@
*/
const sp<Layer>& layer(currentLayers[i]);
layer->setPerFrameData(hw, *cur);
+#ifdef QCOM_BSP
if(freezeSurfacePresent) {
// if freezeSurfacePresent, set ANIMATING flag
cur->setAnimating(true);
@@ -1107,17 +1113,14 @@
size_t dc = draw.size();
for (size_t i=0 ; i<dc ; i++) {
if (draw[i].isMainDisplay()) {
- HWComposer& hwc(getHwComposer());
- if (hwc.initCheck() == NO_ERROR)
- // Pass the current orientation to HWC
- // which will be used to block animation
- // on external
- hwc.eventControl(HWC_DISPLAY_PRIMARY,
- SurfaceFlinger::EVENT_ORIENTATION,
- uint32_t(draw[i].orientation));
+ // Pass the current orientation to HWC
+ hwc.eventControl(HWC_DISPLAY_PRIMARY,
+ SurfaceFlinger::EVENT_ORIENTATION,
+ uint32_t(draw[i].orientation));
}
}
}
+#endif
}
}
}
@@ -2118,6 +2121,24 @@
uint32_t flags)
{
ATRACE_CALL();
+ size_t count = displays.size();
+#ifdef QCOM_BSP
+ for (size_t i=0 ; i<count ; i++) {
+ const DisplayState& s(displays[i]);
+ if(s.token != mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]) {
+ const uint32_t what = s.what;
+ // Invalidate and Delay the binder thread by 50 ms on
+ // eDisplayProjectionChanged to trigger a draw cycle so that
+ // it can fix one incorrect frame on the External, when we disable
+ // external animation
+ if (what & DisplayState::eDisplayProjectionChanged) {
+ invalidateHwcGeometry();
+ repaintEverything();
+ usleep(50000);
+ }
+ }
+ }
+#endif
Mutex::Autolock _l(mStateLock);
uint32_t transactionFlags = 0;
@@ -2137,7 +2158,6 @@
}
}
- size_t count = displays.size();
for (size_t i=0 ; i<count ; i++) {
const DisplayState& s(displays[i]);
transactionFlags |= setDisplayStateLocked(s);