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

Commit 43e5a299 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 439b197d
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -723,7 +723,8 @@ status_t Surface::lock(
            return err;
            return err;
        }
        }
        // we're intending to do software rendering from this point
        // 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;
    ANativeWindowBuffer* out;
+5 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,11 @@ LOCAL_SHARED_LIBRARIES := \
	libui \
	libui \
	libgui
	libgui


ifeq ($(TARGET_USES_QCOM_BSP), true)
    LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
    LOCAL_CFLAGS += -DQCOM_BSP
endif

LOCAL_MODULE:= libsurfaceflinger
LOCAL_MODULE:= libsurfaceflinger


include $(BUILD_SHARED_LIBRARY)
include $(BUILD_SHARED_LIBRARY)
+36 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,10 @@


#include "DisplayHardware/HWComposer.h"
#include "DisplayHardware/HWComposer.h"


#ifdef QCOM_BSP
#include <gralloc_priv.h>
#endif

#define DEBUG_RESIZE    0
#define DEBUG_RESIZE    0


namespace android {
namespace android {
@@ -370,6 +374,15 @@ void Layer::setGeometry(
    frame.intersect(hw->getViewport(), &frame);
    frame.intersect(hw->getViewport(), &frame);
    const Transform& tr(hw->getTransform());
    const Transform& tr(hw->getTransform());
    layer.setFrame(tr.transform(frame));
    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.setCrop(computeCrop(hw));
    layer.setPlaneAlpha(s.alpha);
    layer.setPlaneAlpha(s.alpha);


@@ -1254,6 +1267,29 @@ Layer::LayerCleaner::~LayerCleaner() {
    mFlinger->onLayerDestroyed(mLayer);
    mFlinger->onLayerDestroyed(mLayer);
}
}


#ifdef QCOM_BSP
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 Original line Diff line number Diff line
@@ -276,6 +276,10 @@ public:
    // Updates the transform hint in our SurfaceFlingerConsumer to match
    // Updates the transform hint in our SurfaceFlingerConsumer to match
    // the current orientation of the display device.
    // the current orientation of the display device.
    virtual void updateTransformHint(const sp<const DisplayDevice>& hw) const;
    virtual void updateTransformHint(const sp<const DisplayDevice>& hw) const;
#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
     * returns the rectangle that crops the content of the layer and scales it
+32 −5
Original line number Original line Diff line number Diff line
@@ -889,8 +889,9 @@ void SurfaceFlinger::rebuildLayerStacks() {
            const sp<DisplayDevice>& hw(mDisplays[dpy]);
            const sp<DisplayDevice>& hw(mDisplays[dpy]);
            const Transform& tr(hw->getTransform());
            const Transform& tr(hw->getTransform());
            const Rect bounds(hw->getBounds());
            const Rect bounds(hw->getBounds());
            int dpyId = hw->getHwcDisplayId();
            if (hw->canDraw()) {
            if (hw->canDraw()) {
                SurfaceFlinger::computeVisibleRegions(currentLayers,
                SurfaceFlinger::computeVisibleRegions(dpyId, currentLayers,
                        hw->getLayerStack(), dirtyRegion, opaqueRegion);
                        hw->getLayerStack(), dirtyRegion, opaqueRegion);


                const size_t count = currentLayers.size();
                const size_t count = currentLayers.size();
@@ -1319,7 +1320,7 @@ void SurfaceFlinger::commitTransaction()
    mTransactionCV.broadcast();
    mTransactionCV.broadcast();
}
}


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


    outDirtyRegion.clear();
    outDirtyRegion.clear();

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


        // only consider the layers on the given layer stack
#ifdef QCOM_BSP
        if (s.layerStack != layerStack)
        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;
            continue;


        /*
        /*
Loading