Loading services/surfaceflinger/DisplayDevice.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ DisplayDevice::DisplayDevice( const sp<DisplaySurface>& displaySurface, const sp<DisplaySurface>& displaySurface, const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer, EGLConfig config) EGLConfig config) : mFlinger(flinger), : lastCompositionHadVisibleLayers(false), mFlinger(flinger), mType(type), mHwcDisplayId(hwcId), mType(type), mHwcDisplayId(hwcId), mDisplayToken(displayToken), mDisplayToken(displayToken), mDisplaySurface(displaySurface), mDisplaySurface(displaySurface), Loading services/surfaceflinger/DisplayDevice.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,7 @@ public: mutable Region swapRegion; mutable Region swapRegion; // region in screen space // region in screen space Region undefinedRegion; Region undefinedRegion; bool lastCompositionHadVisibleLayers; enum DisplayType { enum DisplayType { DISPLAY_ID_INVALID = -1, DISPLAY_ID_INVALID = -1, Loading services/surfaceflinger/SurfaceFlinger.cpp +25 −2 Original line number Original line Diff line number Diff line Loading @@ -987,9 +987,32 @@ void SurfaceFlinger::rebuildLayerStacks() { void SurfaceFlinger::setUpHWComposer() { void SurfaceFlinger::setUpHWComposer() { for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { bool mustRecompose = bool dirty = !mDisplays[dpy]->getDirtyRegion(false).isEmpty(); !(mDisplays[dpy]->getDirtyRegion(false).isEmpty()); bool empty = mDisplays[dpy]->getVisibleLayersSortedByZ().size() == 0; bool wasEmpty = !mDisplays[dpy]->lastCompositionHadVisibleLayers; // If nothing has changed (!dirty), don't recompose. // If something changed, but we don't currently have any visible layers, // and didn't when we last did a composition, then skip it this time. // The second rule does two things: // - When all layers are removed from a display, we'll emit one black // frame, then nothing more until we get new layers. // - When a display is created with a private layer stack, we won't // emit any black frames until a layer is added to the layer stack. bool mustRecompose = dirty && !(empty && wasEmpty); ALOGV_IF(mDisplays[dpy]->getDisplayType() == DisplayDevice::DISPLAY_VIRTUAL, "dpy[%zu]: %s composition (%sdirty %sempty %swasEmpty)", dpy, mustRecompose ? "doing" : "skipping", dirty ? "+" : "-", empty ? "+" : "-", wasEmpty ? "+" : "-"); mDisplays[dpy]->beginFrame(mustRecompose); mDisplays[dpy]->beginFrame(mustRecompose); if (mustRecompose) { mDisplays[dpy]->lastCompositionHadVisibleLayers = !empty; } } } HWComposer& hwc(getHwComposer()); HWComposer& hwc(getHwComposer()); Loading Loading
services/surfaceflinger/DisplayDevice.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ DisplayDevice::DisplayDevice( const sp<DisplaySurface>& displaySurface, const sp<DisplaySurface>& displaySurface, const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer, EGLConfig config) EGLConfig config) : mFlinger(flinger), : lastCompositionHadVisibleLayers(false), mFlinger(flinger), mType(type), mHwcDisplayId(hwcId), mType(type), mHwcDisplayId(hwcId), mDisplayToken(displayToken), mDisplayToken(displayToken), mDisplaySurface(displaySurface), mDisplaySurface(displaySurface), Loading
services/surfaceflinger/DisplayDevice.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,7 @@ public: mutable Region swapRegion; mutable Region swapRegion; // region in screen space // region in screen space Region undefinedRegion; Region undefinedRegion; bool lastCompositionHadVisibleLayers; enum DisplayType { enum DisplayType { DISPLAY_ID_INVALID = -1, DISPLAY_ID_INVALID = -1, Loading
services/surfaceflinger/SurfaceFlinger.cpp +25 −2 Original line number Original line Diff line number Diff line Loading @@ -987,9 +987,32 @@ void SurfaceFlinger::rebuildLayerStacks() { void SurfaceFlinger::setUpHWComposer() { void SurfaceFlinger::setUpHWComposer() { for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { bool mustRecompose = bool dirty = !mDisplays[dpy]->getDirtyRegion(false).isEmpty(); !(mDisplays[dpy]->getDirtyRegion(false).isEmpty()); bool empty = mDisplays[dpy]->getVisibleLayersSortedByZ().size() == 0; bool wasEmpty = !mDisplays[dpy]->lastCompositionHadVisibleLayers; // If nothing has changed (!dirty), don't recompose. // If something changed, but we don't currently have any visible layers, // and didn't when we last did a composition, then skip it this time. // The second rule does two things: // - When all layers are removed from a display, we'll emit one black // frame, then nothing more until we get new layers. // - When a display is created with a private layer stack, we won't // emit any black frames until a layer is added to the layer stack. bool mustRecompose = dirty && !(empty && wasEmpty); ALOGV_IF(mDisplays[dpy]->getDisplayType() == DisplayDevice::DISPLAY_VIRTUAL, "dpy[%zu]: %s composition (%sdirty %sempty %swasEmpty)", dpy, mustRecompose ? "doing" : "skipping", dirty ? "+" : "-", empty ? "+" : "-", wasEmpty ? "+" : "-"); mDisplays[dpy]->beginFrame(mustRecompose); mDisplays[dpy]->beginFrame(mustRecompose); if (mustRecompose) { mDisplays[dpy]->lastCompositionHadVisibleLayers = !empty; } } } HWComposer& hwc(getHwComposer()); HWComposer& hwc(getHwComposer()); Loading