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

Commit 3a7b2870 authored by Ramkumar Radhakrishnan's avatar Ramkumar Radhakrishnan Committed by Manish Kumar
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

Conflicts:

	services/surfaceflinger/Layer.cpp
	services/surfaceflinger/Layer.h
	services/surfaceflinger/SurfaceFlinger.cpp
(cherry picked from commit 42cd6bd3bc9e8d1e1eaabaaa06d16803b45942bd)
(cherry picked from commit 62af24e70035866aa8e8741a6f058fa8309d0028)
(cherry picked from commit 97112b478210c2adebdc1c0b41b60444e9ce6767)
parent 585cfbb1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -731,7 +731,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;
+5 −0
Original line number Diff line number Diff line
@@ -94,6 +94,11 @@ LOCAL_SHARED_LIBRARIES := \
	libui \
	libgui

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

LOCAL_MODULE:= libsurfaceflinger

include $(BUILD_SHARED_LIBRARY)
+35 −0
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@
#include "DisplayHardware/HWComposer.h"

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

#define DEBUG_RESIZE    0

@@ -364,6 +367,15 @@ void Layer::setGeometry(
    frame.intersect(hw->getViewport(), &frame);
    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);

@@ -1249,6 +1261,29 @@ Layer::LayerCleaner::~LayerCleaner() {
    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
// ---------------------------------------------------------------------------
}; // namespace android

+4 −0
Original line number Diff line number Diff line
@@ -258,6 +258,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) 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
+32 −5
Original line number Diff line number Diff line
@@ -1013,8 +1013,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->canDraw()) {
                SurfaceFlinger::computeVisibleRegions(layers,
                SurfaceFlinger::computeVisibleRegions(dpyId, currentLayers,
                        hw->getLayerStack(), dirtyRegion, opaqueRegion);

                const size_t count = layers.size();
@@ -1482,7 +1483,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)
{
@@ -1493,7 +1494,7 @@ void SurfaceFlinger::computeVisibleRegions(
    Region dirty;

    outDirtyRegion.clear();

    bool bIgnoreLayers = false;
    size_t i = currentLayers.size();
    while (i--) {
        const sp<Layer>& layer = currentLayers[i];
@@ -1501,8 +1502,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;

        /*
Loading