Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b02087db authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: remove DisplayDevice::swapRegion

With SWAP_RECTANGLE and PARTIAL_UPDATES removed, it becomes clear
that swapRegion is not needed.  It also becomes clear that
DisplayDevice::flip and SurfaceFlinger::doComposeSurfaces do not
need the dirty region.

Test: SurfaceFlinger_test
Change-Id: Id9cd2b43812d3c7dcfa36f605d0f8a647264f228
parent 94e6a688
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ uint32_t DisplayDevice::getPageFlipCount() const {
    return mPageFlipCount;
}

void DisplayDevice::flip(const Region& /*dirty*/) const
void DisplayDevice::flip() const
{
    mFlinger->getRenderEngine().checkErrors();
    mPageFlipCount++;
+1 −3
Original line number Diff line number Diff line
@@ -56,8 +56,6 @@ public:
    // region in layer-stack space
    mutable Region dirtyRegion;
    // region in screen space
    mutable Region swapRegion;
    // region in screen space
    Region undefinedRegion;
    bool lastCompositionHadVisibleLayers;

@@ -97,7 +95,7 @@ public:

    // Flip the front and back buffers if the back buffer is "dirty".  Might
    // be instantaneous, might involve copying the frame buffer around.
    void flip(const Region& dirty) const;
    void flip() const;

    int         getWidth() const;
    int         getHeight() const;
+8 −28
Original line number Diff line number Diff line
@@ -1534,7 +1534,7 @@ void SurfaceFlinger::doDebugFlashRegions()
            const Region dirtyRegion(hw->getDirtyRegion(repaintEverything));
            if (!dirtyRegion.isEmpty()) {
                // redraw the whole screen
                doComposeSurfaces(hw, Region(hw->bounds()));
                doComposeSurfaces(hw);

                // and draw the dirty region
                const int32_t height = hw->getHeight();
@@ -2009,8 +2009,7 @@ void SurfaceFlinger::doComposition() {
            doDisplayComposition(hw, dirtyRegion);

            hw->dirtyRegion.clear();
            hw->flip(hw->swapRegion);
            hw->swapRegion.clear();
            hw->flip();
        }
    }
    postFramebuffer();
@@ -2643,30 +2642,17 @@ void SurfaceFlinger::doDisplayComposition(
    }

    ALOGV("doDisplayComposition");

    Region dirtyRegion(inDirtyRegion);

    // compute the invalid region
    displayDevice->swapRegion.orSelf(dirtyRegion);

    // we need to redraw everything (the whole screen)
    dirtyRegion.set(displayDevice->bounds());
    displayDevice->swapRegion = dirtyRegion;

    if (!doComposeSurfaces(displayDevice, dirtyRegion)) return;

    // update the swap region and clear the dirty region
    displayDevice->swapRegion.orSelf(dirtyRegion);
    if (!doComposeSurfaces(displayDevice)) return;

    // swap buffers (presentation)
    displayDevice->swapBuffers(getHwComposer());
}

bool SurfaceFlinger::doComposeSurfaces(
        const sp<const DisplayDevice>& displayDevice, const Region& dirty)
bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& displayDevice)
{
    ALOGV("doComposeSurfaces");

    const Region bounds(displayDevice->bounds());
    const DisplayRenderArea renderArea(displayDevice);
    const auto hwcId = displayDevice->getHwcDisplayId();

@@ -2708,10 +2694,7 @@ bool SurfaceFlinger::doComposeSurfaces(
            // We'll revisit later if needed.
            mRenderEngine->clearWithColor(0, 0, 0, 0);
        } else {
            // we start with the whole screen area
            const Region bounds(displayDevice->getBounds());

            // we remove the scissor part
            // we start with the whole screen area and remove the scissor part
            // we're left with the letterbox region
            // (common case is that letterbox ends-up being empty)
            const Region letterbox(bounds.subtract(displayDevice->getScissor()));
@@ -2719,9 +2702,6 @@ bool SurfaceFlinger::doComposeSurfaces(
            // compute the area to clear
            Region region(displayDevice->undefinedRegion.merge(letterbox));

            // but limit it to the dirty region
            region.andSelf(dirty);

            // screen is already cleared here
            if (!region.isEmpty()) {
                // can happen with SurfaceView
@@ -2758,7 +2738,7 @@ bool SurfaceFlinger::doComposeSurfaces(
        // we're using h/w composer
        bool firstLayer = true;
        for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
            const Region clip(dirty.intersect(
            const Region clip(bounds.intersect(
                    displayTransform.transform(layer->visibleRegion)));
            ALOGV("Layer: %s", layer->getName().string());
            ALOGV("  Composition type: %s",
@@ -2794,7 +2774,7 @@ bool SurfaceFlinger::doComposeSurfaces(
    } else {
        // we're not using h/w composer
        for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
            const Region clip(dirty.intersect(
            const Region clip(bounds.intersect(
                    displayTransform.transform(layer->visibleRegion)));
            if (!clip.isEmpty()) {
                layer->draw(renderArea, clip);
+1 −1
Original line number Diff line number Diff line
@@ -543,7 +543,7 @@ private:

    // compose surfaces for display hw. this fails if using GL and the surface
    // has been destroyed and is no longer valid.
    bool doComposeSurfaces(const sp<const DisplayDevice>& displayDevice, const Region& dirty);
    bool doComposeSurfaces(const sp<const DisplayDevice>& displayDevice);

    void postFramebuffer();
    void drawWormhole(const sp<const DisplayDevice>& displayDevice, const Region& region) const;