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

Commit c9ea4c8b authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "we were sometimes not setting fences properly" into jb-mr1-dev

parents c1396dd1 85d751cb
Loading
Loading
Loading
Loading
+36 −26
Original line number Original line Diff line number Diff line
@@ -1264,15 +1264,13 @@ void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw,


void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty)
void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty)
{
{
    const int32_t id = hw->getHwcDisplayId();
    HWComposer& hwc(getHwComposer());
    HWComposer& hwc(getHwComposer());
    int32_t id = hw->getHwcDisplayId();
    HWComposer::LayerListIterator cur = hwc.begin(id);
    HWComposer::LayerListIterator cur = hwc.begin(id);
    const HWComposer::LayerListIterator end = hwc.end(id);
    const HWComposer::LayerListIterator end = hwc.end(id);


    const bool hasGlesComposition = hwc.hasGlesComposition(id);
    const bool hasGlesComposition = hwc.hasGlesComposition(id) || (cur==end);
    const bool hasHwcComposition = hwc.hasHwcComposition(id);
    if (hasGlesComposition) {
    if (cur==end || hasGlesComposition) {

        DisplayDevice::makeCurrent(hw, mEGLContext);
        DisplayDevice::makeCurrent(hw, mEGLContext);


        // set the frame buffer
        // set the frame buffer
@@ -1280,6 +1278,7 @@ void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const
        glLoadIdentity();
        glLoadIdentity();


        // Never touch the framebuffer if we don't have any framebuffer layers
        // Never touch the framebuffer if we don't have any framebuffer layers
        const bool hasHwcComposition = hwc.hasHwcComposition(id);
        if (hasHwcComposition) {
        if (hasHwcComposition) {
            // when using overlays, we assume a fully transparent framebuffer
            // when using overlays, we assume a fully transparent framebuffer
            // NOTE: we could reduce how much we need to clear, for instance
            // NOTE: we could reduce how much we need to clear, for instance
@@ -1296,6 +1295,7 @@ void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const
                drawWormhole(hw, region);
                drawWormhole(hw, region);
            }
            }
        }
        }
    }


    /*
    /*
     * and then, render the layers targeted at the framebuffer
     * and then, render the layers targeted at the framebuffer
@@ -1304,34 +1304,44 @@ void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const
    const Vector< sp<LayerBase> >& layers(hw->getVisibleLayersSortedByZ());
    const Vector< sp<LayerBase> >& layers(hw->getVisibleLayersSortedByZ());
    const size_t count = layers.size();
    const size_t count = layers.size();
    const Transform& tr = hw->getTransform();
    const Transform& tr = hw->getTransform();
        for (size_t i=0 ; i<count ; ++i) {
            const sp<LayerBase>& layer(layers[i]);
            const Region clip(dirty.intersect(tr.transform(layer->visibleRegion)));
    if (cur != end) {
    if (cur != end) {
        // we're using h/w composer
        // we're using h/w composer
        for (size_t i=0 ; i<count && cur!=end ; ++i, ++cur) {
            const sp<LayerBase>& layer(layers[i]);
            const Region clip(dirty.intersect(tr.transform(layer->visibleRegion)));
            if (!clip.isEmpty()) {
            if (!clip.isEmpty()) {
                    if (cur->getCompositionType() == HWC_OVERLAY) {
                switch (cur->getCompositionType()) {
                        if (i && (cur->getHints() & HWC_HINT_CLEAR_FB)
                    case HWC_OVERLAY: {
                                && layer->isOpaque()) {
                        if ((cur->getHints() & HWC_HINT_CLEAR_FB)
                                && i
                                && layer->isOpaque()
                                && hasGlesComposition) {
                            // never clear the very first layer since we're
                            // never clear the very first layer since we're
                            // guaranteed the FB is already cleared
                            // guaranteed the FB is already cleared
                            layer->clearWithOpenGL(hw, clip);
                            layer->clearWithOpenGL(hw, clip);
                        }
                        }
                    } else {
                        break;
                    }
                    case HWC_FRAMEBUFFER: {
                        layer->draw(hw, clip);
                        layer->draw(hw, clip);
                        break;
                    }
                }
            }
            }
            layer->setAcquireFence(hw, *cur);
            layer->setAcquireFence(hw, *cur);
        }
        }
                ++cur;
    } else {
    } else {
        // we're not using h/w composer
        // we're not using h/w composer
        for (size_t i=0 ; i<count ; ++i) {
            const sp<LayerBase>& layer(layers[i]);
            const Region clip(dirty.intersect(
                    tr.transform(layer->visibleRegion)));
            if (!clip.isEmpty()) {
            if (!clip.isEmpty()) {
                layer->draw(hw, clip);
                layer->draw(hw, clip);
            }
            }
        }
        }
    }
    }
}
}
}


void SurfaceFlinger::drawWormhole(const sp<const DisplayDevice>& hw,
void SurfaceFlinger::drawWormhole(const sp<const DisplayDevice>& hw,
        const Region& region) const
        const Region& region) const