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

Commit 756af1b6 authored by Naomi Luis's avatar Naomi Luis Committed by Giulio Cervera
Browse files

SurfaceFlinger: Call libQcomUI's clearRegion instead of glClear

Call libQcomUI's implementation of clearRegion instead of glClear. This
implementation is specifically designed to optimize the drawWormhole for non GPU
composition cases, in order to improve performace. If the qcom version
of this API returns an error, we fallback to SurfaceFlinger's implementation
of drawWormhole. The clearRegion API is only called if there are no layers
being drawn by the GPU.

Change-Id: I1a50cf5ba2a88ffcadf13ff78df16f5a30dfff3a
parent 0de03e4b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -84,6 +84,9 @@ public:

    uint32_t getPageFlipCount() const;
    EGLDisplay getEGLDisplay() const { return mDisplay; }
#ifdef QCOM_HARDWARE
    EGLDisplay getEGLSurface() const { return mSurface; }
#endif

    void dump(String8& res) const;

+49 −0
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@
#include "DisplayHardware/HWComposer.h"

#include <private/surfaceflinger/SharedBufferStack.h>
#ifdef QCOM_HARDWARE
#include <qcom_ui.h>
#endif

/* ideally AID_GRAPHICS would be in a semi-public header
 * or there would be a way to map a user/group name to its id
@@ -917,6 +920,29 @@ void SurfaceFlinger::handleRepaint()
    mDirtyRegion.clear();
}

#ifdef QCOM_HARDWARE
bool SurfaceFlinger::isGPULayerPresent()
{
    bool isGPULayerPresent = false;
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
    HWComposer& hwc(hw.getHwComposer());
    hwc_layer_t* const cur(hwc.getLayers());
    if (!cur) {
        isGPULayerPresent = true;
    }

    const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ);
    size_t count = layers.size();
    for (size_t i = 0; i<count; i++) {
        if (HWC_FRAMEBUFFER == cur[i].compositionType) {
            isGPULayerPresent = true;
            break;
        }
    }
    return isGPULayerPresent;
}
#endif

void SurfaceFlinger::setupHardwareComposer(Region& dirtyInOut)
{
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
@@ -1007,6 +1033,14 @@ void SurfaceFlinger::setupHardwareComposer(Region& dirtyInOut)
         */
#ifdef QCOM_HARDWARE
        if (!transparent.isEmpty() && !mCanSkipComposition) {
            // If we have any GPU layers present, don't use libQcomUI's
            // clearRegion
            if (false == isGPULayerPresent()) {
                if (0 == qcomuiClearRegion(transparent, hw.getEGLDisplay(),
                                        hw.getEGLSurface())) {
                    return;
                }
            }
#else
	if (!transparent.isEmpty()) {
#endif
@@ -1033,8 +1067,23 @@ void SurfaceFlinger::composeSurfaces(const Region& dirty)
    if (UNLIKELY(fbLayerCount && !mWormholeRegion.isEmpty())) {
        // should never happen unless the window manager has a bug
        // draw something...
#ifdef QCOM_HARDWARE
        if (false == isGPULayerPresent()) {
            // Use libQcomUI to draw the wormhole since there are no GPU layers
            const Region region(mWormholeRegion.intersect(mDirtyRegion));
            if (!region.isEmpty()) {
                if (0 != qcomuiClearRegion(region, hw.getEGLDisplay(),
                                             hw.getEGLSurface())) {
                    drawWormhole();
                }
            }
        } else {
            drawWormhole();
        }
#else
        drawWormhole();
#endif
    }

    /*
     * and then, render the layers targeted at the framebuffer
+3 −0
Original line number Diff line number Diff line
@@ -346,6 +346,9 @@ private:
            //HDMI Specific
            void updateHwcHDMI(bool enable);
#endif
#ifdef QCOM_HARDWARE
            bool isGPULayerPresent();
#endif

    mutable     MessageQueue    mEventQueue;