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

Commit 20f9ced8 authored by Raj Kamal's avatar Raj Kamal Committed by Linux Build Service Account
Browse files

SurfaceFlinger: Add support for DisplayUtils

Add DisplayUtils class which uses the custom implementations
of ExLayer, ExSurfaceFlinger, ExHWComposer,
and ExVirtualDisplaySurface classes if needed

Change-Id: Ibdd8da5d3d0d602f42b76a15d0994c6aa98bee3f
parent 8eaa1946
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@ LOCAL_SRC_FILES := \
    RenderEngine/Texture.cpp \
    RenderEngine/GLES10RenderEngine.cpp \
    RenderEngine/GLES11RenderEngine.cpp \
    RenderEngine/GLES20RenderEngine.cpp

    RenderEngine/GLES20RenderEngine.cpp \
    DisplayUtils.cpp

LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
@@ -106,6 +106,17 @@ LOCAL_SHARED_LIBRARIES := \
    libgui \
    libpowermanager

LOCAL_WHOLE_STATIC_LIBRARIES += libexsurfaceflinger

LOCAL_C_INCLUDES += $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/display-frameworks/native/services/surfaceflinger/

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

LOCAL_MODULE := libsurfaceflinger

LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
+6 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public:
            const sp<SurfaceFlinger>& flinger,
            EventHandler& handler);

    ~HWComposer();
    virtual ~HWComposer();

    status_t initCheck() const;

@@ -304,6 +304,11 @@ public:
    // for debugging ----------------------------------------------------------
    void dump(String8& out) const;

    /* ------------------------------------------------------------------------
     * Extensions
     */
    virtual inline bool isVDSEnabled() const { return true; };

private:
    void loadHwcModule();
    int loadFbHalModule();
+6 −2
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ status_t VirtualDisplaySurface::prepareFrame(CompositionType compositionType) {
        // format/usage and get a new buffer when the GLES driver calls
        // dequeueBuffer().
        mOutputFormat = mDefaultOutputFormat;
        mOutputUsage = GRALLOC_USAGE_HW_COMPOSER;
        setOutputUsage(GRALLOC_USAGE_HW_COMPOSER);
        refreshOutputBuffer();
    }

@@ -377,7 +377,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool
                    mSinkBufferWidth, mSinkBufferHeight,
                    buf->getPixelFormat(), buf->getUsage());
            mOutputFormat = format;
            mOutputUsage = usage;
            setOutputUsage(usage);
            result = refreshOutputBuffer();
            if (result < 0)
                return result;
@@ -616,6 +616,10 @@ const char* VirtualDisplaySurface::dbgSourceStr(Source s) {
    }
}

void VirtualDisplaySurface::setOutputUsage(uint32_t usage) {
    mOutputUsage = usage;
}

// ---------------------------------------------------------------------------
} // namespace android
// ---------------------------------------------------------------------------
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ class VirtualDisplaySurface : public DisplaySurface,
                              public BnGraphicBufferProducer,
                              private ConsumerBase {
public:
    friend class ExVirtualDisplaySurface;

    VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
            const sp<IGraphicBufferProducer>& sink,
            const sp<IGraphicBufferProducer>& bqProducer,
@@ -118,6 +120,7 @@ private:
    virtual status_t allowAllocation(bool allow);
    virtual status_t setGenerationNumber(uint32_t generationNumber);
    virtual String8 getConsumerName() const override;
    virtual void setOutputUsage(uint32_t flag);

    //
    // Utility methods
+106 −0
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>

#include <utils/Errors.h>
#include <utils/Log.h>

#include <ui/GraphicBuffer.h>

#include "DisplayUtils.h"
#include <ExSurfaceFlinger.h>
#include <ExLayer.h>
#include <DisplayHardware/ExHWComposer.h>
#include <DisplayHardware/ExVirtualDisplaySurface.h>
#include <dlfcn.h>

namespace android {

DisplayUtils* DisplayUtils::sDisplayUtils = NULL;
bool DisplayUtils::sUseExtendedImpls = false;

DisplayUtils::DisplayUtils() {
#ifdef QTI_BSP
    sUseExtendedImpls = true;
#endif
}

DisplayUtils* DisplayUtils::getInstance() {
    if(sDisplayUtils == NULL) {
        sDisplayUtils = new DisplayUtils();
    }
    return sDisplayUtils;
}

SurfaceFlinger* DisplayUtils::getSFInstance() {
    if(sUseExtendedImpls) {
        return new ExSurfaceFlinger();
    } else {
        return new SurfaceFlinger();
    }
}

Layer* DisplayUtils::getLayerInstance(SurfaceFlinger* flinger,
                            const sp<Client>& client, const String8& name,
                            uint32_t w, uint32_t h, uint32_t flags) {
    if(sUseExtendedImpls) {
        return new ExLayer(flinger, client, name, w, h, flags);
    } else {
        return new Layer(flinger, client, name, w, h, flags);
    }
}

HWComposer* DisplayUtils::getHWCInstance(
                        const sp<SurfaceFlinger>& flinger,
                        HWComposer::EventHandler& handler) {
    if(sUseExtendedImpls) {
        return new ExHWComposer(flinger, handler);
    } else {
        return new HWComposer(flinger,handler);
    }
}

VirtualDisplaySurface* DisplayUtils::getVDSInstance(HWComposer* hwc, int32_t hwcDisplayId,
        sp<IGraphicBufferProducer> currentStateSurface, sp<IGraphicBufferProducer> bqProducer,
        sp<IGraphicBufferConsumer> bqConsumer, String8 currentStateDisplayName,
        bool currentStateIsSecure)
{
    if(sUseExtendedImpls) {
        return new ExVirtualDisplaySurface(*hwc, hwcDisplayId, currentStateSurface, bqProducer,
                bqConsumer, currentStateDisplayName, currentStateIsSecure);
    } else {
        return new VirtualDisplaySurface(*hwc, hwcDisplayId, currentStateSurface, bqProducer,
                bqConsumer, currentStateDisplayName);
    }
}

}; // namespace android
Loading