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

Commit 5f695d3d authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Steve Kondik
Browse files

Revert "remove support for glReadPixels screenshot path"

This reverts commit 3ca76f41.
parent 49b21043
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -120,7 +120,8 @@ public:
    virtual status_t captureScreen(const sp<IBinder>& display,
            const sp<IGraphicBufferProducer>& producer,
            uint32_t reqWidth, uint32_t reqHeight,
            uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
            uint32_t minLayerZ, uint32_t maxLayerZ,
            bool isCpuConsumer) = 0;
};

// ----------------------------------------------------------------------------
+6 −2
Original line number Diff line number Diff line
@@ -105,7 +105,8 @@ public:
    virtual status_t captureScreen(const sp<IBinder>& display,
            const sp<IGraphicBufferProducer>& producer,
            uint32_t reqWidth, uint32_t reqHeight,
            uint32_t minLayerZ, uint32_t maxLayerZ)
            uint32_t minLayerZ, uint32_t maxLayerZ,
            bool isCpuConsumer)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
@@ -115,6 +116,7 @@ public:
        data.writeInt32(reqHeight);
        data.writeInt32(minLayerZ);
        data.writeInt32(maxLayerZ);
        data.writeInt32(isCpuConsumer);
        remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
        return reply.readInt32();
    }
@@ -285,8 +287,10 @@ status_t BnSurfaceComposer::onTransact(
            uint32_t reqHeight = data.readInt32();
            uint32_t minLayerZ = data.readInt32();
            uint32_t maxLayerZ = data.readInt32();
            bool isCpuConsumer = data.readInt32();
            status_t res = captureScreen(display, producer,
                    reqWidth, reqHeight, minLayerZ, maxLayerZ);
                    reqWidth, reqHeight, minLayerZ, maxLayerZ,
                    isCpuConsumer);
            reply->writeInt32(res);
            return NO_ERROR;
        }
+3 −2
Original line number Diff line number Diff line
@@ -694,7 +694,8 @@ status_t ScreenshotClient::capture(
    sp<ISurfaceComposer> s(ComposerService::getComposerService());
    if (s == NULL) return NO_INIT;
    return s->captureScreen(display, producer,
            reqWidth, reqHeight, minLayerZ, maxLayerZ);
            reqWidth, reqHeight, minLayerZ, maxLayerZ,
            false);
}

ScreenshotClient::ScreenshotClient()
@@ -736,7 +737,7 @@ status_t ScreenshotClient::update(const sp<IBinder>& display,
    }

    status_t err = s->captureScreen(display, mBufferQueue,
            reqWidth, reqHeight, minLayerZ, maxLayerZ);
            reqWidth, reqHeight, minLayerZ, maxLayerZ, true);

    if (err == NO_ERROR) {
        err = mCpuConsumer->lockNextBuffer(&mBuffer);
+30 −13
Original line number Diff line number Diff line
@@ -185,8 +185,10 @@ void GLES11RenderEngine::disableBlending() {
}

void GLES11RenderEngine::bindImageAsFramebuffer(EGLImageKHR image,
        uint32_t* texName, uint32_t* fbName, uint32_t* status) {
        uint32_t* texName, uint32_t* fbName, uint32_t* status,
        bool useReadPixels, int reqWidth, int reqHeight) {
    GLuint tname, name;
    if (!useReadPixels) {
        // turn our EGLImage into a texture
        glGenTextures(1, &tname);
        glBindTexture(GL_TEXTURE_2D, tname);
@@ -197,16 +199,31 @@ void GLES11RenderEngine::bindImageAsFramebuffer(EGLImageKHR image,
        glBindFramebufferOES(GL_FRAMEBUFFER_OES, name);
        glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES,
                GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tname, 0);
    } else {
        // since we're going to use glReadPixels() anyways,
        // use an intermediate renderbuffer instead
        glGenRenderbuffersOES(1, &tname);
        glBindRenderbufferOES(GL_RENDERBUFFER_OES, tname);
        glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, reqWidth, reqHeight);
        // create a FBO to render into
        glGenFramebuffersOES(1, &name);
        glBindFramebufferOES(GL_FRAMEBUFFER_OES, name);
        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, tname);
    }

    *status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
    *texName = tname;
    *fbName = name;
}

void GLES11RenderEngine::unbindFramebuffer(uint32_t texName, uint32_t fbName) {
void GLES11RenderEngine::unbindFramebuffer(uint32_t texName, uint32_t fbName,
        bool useReadPixels) {
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
    glDeleteFramebuffersOES(1, &fbName);
    if (!useReadPixels)
        glDeleteTextures(1, &texName);
    else
        glDeleteRenderbuffersOES(1, &texName);
}

void GLES11RenderEngine::setupFillWithColor(float r, float g, float b, float a) {
+2 −2
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@ class GLES11RenderEngine : public RenderEngine {
    GLint mMaxTextureSize;

    virtual void bindImageAsFramebuffer(EGLImageKHR image,
            uint32_t* texName, uint32_t* fbName, uint32_t* status);
    virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName);
            uint32_t* texName, uint32_t* fbName, uint32_t* status, bool useReadPixels, int reqWidth, int reqHeight);
    virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName, bool useReadPixels);

public:
    GLES11RenderEngine();
Loading