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

Commit 34fda34f authored by Harshad Bhutada's avatar Harshad Bhutada Committed by Giulio Cervera
Browse files

SurfaceTexture: Avoid binding texture if format not supported in GPU HW

Certain formats may not be supported in GPU HW. For them, avoid binding
textures. When the textures created from surface flinger, they may not
be needed if we are not using GPU composition.
parent 41edafd7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -141,7 +141,17 @@ public:
    //
    // This call may only be made while the OpenGL ES context to which the
    // target texture belongs is bound to the calling thread.
#ifndef QCOM_HARDWARE
    status_t updateTexImage();
#else
    //
    // In certain cases, we might not want to bind the texture because it
    // is not going to be used later (surface flinger not using
    // GPU for composition). During these times "avoidBindTexture" can be
    // set to true. This will avoid binding textures for formats that are
    // not directly supported in hardware.
    status_t updateTexImage(bool avoidBindTexture = false);
#endif

    // setBufferCountServer set the buffer count. If the client has requested
    // a buffer count using setBufferCount, the server-buffer count will
+9 −17
Original line number Diff line number Diff line
@@ -834,7 +834,11 @@ status_t SurfaceTexture::setScalingMode(int mode) {
    return OK;
}

#ifdef QCOM_HARDWARE
status_t SurfaceTexture::updateTexImage(bool avoidBindTexture) {
#else
status_t SurfaceTexture::updateTexImage() {
#endif
    ST_LOGV("updateTexImage");
    Mutex::Autolock lock(mMutex);

@@ -853,22 +857,11 @@ status_t SurfaceTexture::updateTexImage() {
        EGLImageKHR image = mSlots[buf].mEglImage;
        EGLDisplay dpy = eglGetCurrentDisplay();
#ifdef QCOM_HARDWARE
	if (isGPUSupportedFormat(mSlots[buf].mGraphicBuffer->format)) {
            // Update the GL texture object.
            EGLImageKHR image = mSlots[buf].mEglImage;
#else
        if (image == EGL_NO_IMAGE_KHR) {
            if (mSlots[buf].mGraphicBuffer == 0) {
                ST_LOGE("buffer at slot %d is null", buf);
                return BAD_VALUE;
            }
            image = createImage(dpy, mSlots[buf].mGraphicBuffer);
            mSlots[buf].mEglImage = image;
            mSlots[buf].mEglDisplay = dpy;
        if (isGPUSupportedFormat(mSlots[buf].mGraphicBuffer->format) &&
           (avoidBindTexture == false) ||
           (isGPUSupportedFormatInHW(mSlots[buf].mGraphicBuffer->format))) {
#endif
        if (image == EGL_NO_IMAGE_KHR) {
#ifdef QCOM_HARDWARE
		EGLDisplay dpy = eglGetCurrentDisplay();
            if (mSlots[buf].mGraphicBuffer == 0) {
                ST_LOGE("buffer at slot %d is null", buf);
                return BAD_VALUE;
@@ -877,7 +870,6 @@ status_t SurfaceTexture::updateTexImage() {
            mSlots[buf].mEglImage = image;
            mSlots[buf].mEglDisplay = dpy;
            if (image == EGL_NO_IMAGE_KHR) {
#endif
                // NOTE: if dpy was invalid, createImage() is guaranteed to
                // fail. so we'd end up here.
                return -EINVAL;
+9 −0
Original line number Diff line number Diff line
@@ -444,7 +444,16 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
            mFlinger->signalEvent();
        }

#ifdef QCOM_HARDWARE
        const DisplayHardware& hw(graphicPlane(0).displayHardware());
        
        bool avoidTex = (hw.getFlags() | DisplayHardware::C2D_COMPOSITION) ? 
                          true : false;

        if (mSurfaceTexture->updateTexImage(avoidTex) < NO_ERROR) {
#else
        if (mSurfaceTexture->updateTexImage() < NO_ERROR) {
#endif
            // something happened!
            recomputeVisibleRegions = true;
            return;