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

Commit 5ee229d6 authored by Ramkumar Radhakrishnan's avatar Ramkumar Radhakrishnan Committed by Linux Build Service Account
Browse files

frameworks/native: Add support for custom layers in Surfaceflinger

  - Check for the EXT_ONLY layer and add only that layer to external
    list and do not add that layer to the primary list
  - Check for INT_ONLY layer and remove that layer from external list
  - These are added to support EXTERNAL_ONLY & INTERNAL_ONLY feature

Change-Id: I8f84eeacebf97d44446f319f69b8a73e56f2cb6d
parent f3d922ad
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -824,7 +824,8 @@ status_t Surface::lock(
            return err;
        }
        // we're intending to do software rendering from this point
        setUsage(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
        setUsage(mReqUsage | GRALLOC_USAGE_SW_READ_OFTEN |
                GRALLOC_USAGE_SW_WRITE_OFTEN);
    }

    ANativeWindowBuffer* out;
+34 −0
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@
#include "DisplayHardware/HWComposer.h"

#include "RenderEngine/RenderEngine.h"
#ifdef QCOM_BSP
#include <gralloc_priv.h>
#endif

#define DEBUG_RESIZE    0

@@ -469,6 +472,15 @@ void Layer::setGeometry(

    const Transform& tr(hw->getTransform());
    layer.setFrame(tr.transform(frame));
#ifdef QCOM_BSP
    // set dest_rect to frame buffer width and height, if external_only flag
    // for the layer is enabled.
    if(isExtOnly()) {
        uint32_t w = hw->getWidth();
        uint32_t h = hw->getHeight();
        layer.setFrame(Rect(w,h));
    }
#endif
    layer.setCrop(computeCrop(hw));
    layer.setPlaneAlpha(s.alpha);

@@ -1453,6 +1465,28 @@ Layer::LayerCleaner::~LayerCleaner() {
bool Layer::hasNewFrame() const {
   return (mQueuedFrames > 0);
}

bool Layer::isExtOnly() const
{
    const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
    if (activeBuffer != 0) {
        uint32_t usage = activeBuffer->getUsage();
        if(usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY)
            return true;
    }
    return false;
}

bool Layer::isIntOnly() const
{
    const sp<GraphicBuffer>& activeBuffer(mActiveBuffer);
    if (activeBuffer != 0) {
        uint32_t usage = activeBuffer->getUsage();
        if(usage & GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY)
            return true;
    }
    return false;
}
#endif

// ---------------------------------------------------------------------------
+4 −0
Original line number Diff line number Diff line
@@ -274,6 +274,10 @@ public:
    // Updates the transform hint in our SurfaceFlingerConsumer to match
    // the current orientation of the display device.
    void updateTransformHint(const sp<const DisplayDevice>& hw);
#ifdef QCOM_BSP
    virtual bool isExtOnly() const;
    virtual bool isIntOnly() const;
#endif

    /*
     * returns the rectangle that crops the content of the layer and scales it
+32 −5
Original line number Diff line number Diff line
@@ -1029,8 +1029,9 @@ void SurfaceFlinger::rebuildLayerStacks() {
            const sp<DisplayDevice>& hw(mDisplays[dpy]);
            const Transform& tr(hw->getTransform());
            const Rect bounds(hw->getBounds());
            int dpyId = hw->getHwcDisplayId();
            if (hw->isDisplayOn()) {
                SurfaceFlinger::computeVisibleRegions(layers,
                SurfaceFlinger::computeVisibleRegions(dpyId, layers,
                        hw->getLayerStack(), dirtyRegion, opaqueRegion);

                const size_t count = layers.size();
@@ -1745,7 +1746,7 @@ void SurfaceFlinger::commitTransaction()
    mTransactionCV.broadcast();
}

void SurfaceFlinger::computeVisibleRegions(
void SurfaceFlinger::computeVisibleRegions(size_t dpy,
        const LayerVector& currentLayers, uint32_t layerStack,
        Region& outDirtyRegion, Region& outOpaqueRegion)
{
@@ -1756,7 +1757,7 @@ void SurfaceFlinger::computeVisibleRegions(
    Region dirty;

    outDirtyRegion.clear();

    bool bIgnoreLayers = false;
    size_t i = currentLayers.size();
    while (i--) {
        const sp<Layer>& layer = currentLayers[i];
@@ -1764,8 +1765,34 @@ void SurfaceFlinger::computeVisibleRegions(
        // start with the whole surface at its current location
        const Layer::State& s(layer->getDrawingState());

        // only consider the layers on the given layer stack
        if (s.layerStack != layerStack)
#ifdef QCOM_BSP
        if(bIgnoreLayers) {
            // Ignore all other layers except the layers marked as ext_only
            // by setting visible non transparent region empty.
            Region visibleNonTransRegion;
            visibleNonTransRegion.set(Rect(0,0));
            layer->setVisibleNonTransparentRegion(visibleNonTransRegion);
            continue;
        }
        // Only add the layer marked as "external_only" to external list and
        // only remove the layer marked as "external_only" from primary list
        // and do not add the layer marked as "internal_only" to external list
        if ((dpy && layer->isExtOnly())) {
            bIgnoreLayers = true;
        } else if(layer->isExtOnly() || (dpy && layer->isIntOnly())) {
            // Ignore only ext_only layers for primary by setting
            // visible non transparent region empty.
            Region visibleNonTransRegion;
            visibleNonTransRegion.set(Rect(0,0));
            layer->setVisibleNonTransparentRegion(visibleNonTransRegion);
            continue;
        }
#endif

        // only consider the layers on the given later stack
        // Override layers created using presentation class by the layers having
        // ext_only flag enabled
        if (s.layerStack != layerStack && !bIgnoreLayers)
            continue;

        /*
+1 −1
Original line number Diff line number Diff line
@@ -381,7 +381,7 @@ private:
     * Compositing
     */
    void invalidateHwcGeometry();
    static void computeVisibleRegions(
    static void computeVisibleRegions(size_t dpy,
            const LayerVector& currentLayers, uint32_t layerStack,
            Region& dirtyRegion, Region& opaqueRegion);