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

Commit edb86f9f authored by Riley Andrews's avatar Riley Andrews Committed by Android (Google) Code Review
Browse files

Merge "Add rotation to surfaceflingers screen cap." into lmp-dev

parents 464e539c c3ebe66b
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -62,6 +62,13 @@ public:
        eDisplayIdHdmi = 1
        eDisplayIdHdmi = 1
    };
    };


    enum Rotation {
        eRotateNone = 0,
        eRotate90   = 1,
        eRotate180  = 2,
        eRotate270  = 3
    };

    /* create connection with surface flinger, requires
    /* create connection with surface flinger, requires
     * ACCESS_SURFACE_FLINGER permission
     * ACCESS_SURFACE_FLINGER permission
     */
     */
@@ -130,7 +137,8 @@ public:
            const sp<IGraphicBufferProducer>& producer,
            const sp<IGraphicBufferProducer>& producer,
            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
            uint32_t minLayerZ, uint32_t maxLayerZ,
            uint32_t minLayerZ, uint32_t maxLayerZ,
            bool useIdentityTransform) = 0;
            bool useIdentityTransform,
            Rotation rotation = eRotateNone) = 0;


    /* Clears the frame statistics for animations.
    /* Clears the frame statistics for animations.
     *
     *
+6 −2
Original line number Original line Diff line number Diff line
@@ -106,7 +106,8 @@ public:
            const sp<IGraphicBufferProducer>& producer,
            const sp<IGraphicBufferProducer>& producer,
            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
            uint32_t minLayerZ, uint32_t maxLayerZ,
            uint32_t minLayerZ, uint32_t maxLayerZ,
            bool useIdentityTransform)
            bool useIdentityTransform,
            ISurfaceComposer::Rotation rotation)
    {
    {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
@@ -118,6 +119,7 @@ public:
        data.writeInt32(minLayerZ);
        data.writeInt32(minLayerZ);
        data.writeInt32(maxLayerZ);
        data.writeInt32(maxLayerZ);
        data.writeInt32(static_cast<int32_t>(useIdentityTransform));
        data.writeInt32(static_cast<int32_t>(useIdentityTransform));
        data.writeInt32(static_cast<int32_t>(rotation));
        remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
        remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
        return reply.readInt32();
        return reply.readInt32();
    }
    }
@@ -329,10 +331,12 @@ status_t BnSurfaceComposer::onTransact(
            uint32_t minLayerZ = data.readInt32();
            uint32_t minLayerZ = data.readInt32();
            uint32_t maxLayerZ = data.readInt32();
            uint32_t maxLayerZ = data.readInt32();
            bool useIdentityTransform = static_cast<bool>(data.readInt32());
            bool useIdentityTransform = static_cast<bool>(data.readInt32());
            uint32_t rotation = data.readInt32();


            status_t res = captureScreen(display, producer,
            status_t res = captureScreen(display, producer,
                    sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
                    sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
                    useIdentityTransform);
                    useIdentityTransform,
                    static_cast<ISurfaceComposer::Rotation>(rotation));
            reply->writeInt32(res);
            reply->writeInt32(res);
            return NO_ERROR;
            return NO_ERROR;
        }
        }
+2 −1
Original line number Original line Diff line number Diff line
@@ -288,7 +288,8 @@ void DisplayDevice::setViewportAndProjection() const {
    size_t w = mDisplayWidth;
    size_t w = mDisplayWidth;
    size_t h = mDisplayHeight;
    size_t h = mDisplayHeight;
    Rect sourceCrop(0, 0, w, h);
    Rect sourceCrop(0, 0, w, h);
    mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, h, false);
    mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, h,
        false, Transform::ROT_0);
}
}


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
+20 −1
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@


#include <utils/String8.h>
#include <utils/String8.h>
#include <cutils/compiler.h>
#include <cutils/compiler.h>
#include <gui/ISurfaceComposer.h>


#include "GLES11RenderEngine.h"
#include "GLES11RenderEngine.h"
#include "Mesh.h"
#include "Mesh.h"
@@ -74,7 +75,8 @@ size_t GLES11RenderEngine::getMaxViewportDims() const {
}
}


void GLES11RenderEngine::setViewportAndProjection(
void GLES11RenderEngine::setViewportAndProjection(
        size_t vpw, size_t vph, Rect sourceCrop, size_t hwh, bool yswap) {
        size_t vpw, size_t vph, Rect sourceCrop, size_t hwh, bool yswap,
        Transform::orientation_flags rotation) {
    glViewport(0, 0, vpw, vph);
    glViewport(0, 0, vpw, vph);
    glMatrixMode(GL_PROJECTION);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glLoadIdentity();
@@ -91,6 +93,23 @@ void GLES11RenderEngine::setViewportAndProjection(
    } else {
    } else {
        glOrthof(l, r, b, t, 0, 1);
        glOrthof(l, r, b, t, 0, 1);
    }
    }

    switch (rotation) {
        case Transform::ROT_0:
            break;
        case Transform::ROT_90:
            glRotatef(90, 0, 0, 1);
            break;
        case Transform::ROT_180:
            glRotatef(180, 0, 0, 1);
            break;
        case Transform::ROT_270:
            glRotatef(270, 0, 0, 1);
            break;
        default:
            break;
    }

    glMatrixMode(GL_MODELVIEW);
    glMatrixMode(GL_MODELVIEW);
}
}


+2 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <sys/types.h>


#include <GLES/gl.h>
#include <GLES/gl.h>
#include <Transform.h>


#include "RenderEngine.h"
#include "RenderEngine.h"


@@ -50,7 +51,7 @@ protected:


    virtual void dump(String8& result);
    virtual void dump(String8& result);
    virtual void setViewportAndProjection(size_t vpw, size_t vph,
    virtual void setViewportAndProjection(size_t vpw, size_t vph,
            Rect sourceCrop, size_t hwh, bool yswap);
            Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation);
    virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha);
    virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha);
    virtual void setupDimLayerBlending(int alpha);
    virtual void setupDimLayerBlending(int alpha);
    virtual void setupLayerTexturing(const Texture& texture);
    virtual void setupLayerTexturing(const Texture& texture);
Loading