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

Commit d1296593 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix [2483456] Video orientation is wrong on Droid for some videos

Change-Id: I450191f1335f57bffc51aff3e27295395847dbc0
parent 06cc3e1b
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display)
      mOrientation(0),
      mLeft(0), mTop(0),
      mTransactionFlags(0),
      mPremultipliedAlpha(true),
      mPremultipliedAlpha(true), mDebug(false),
      mInvalidate(0)
{
    const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware());
@@ -65,6 +65,14 @@ LayerBase::~LayerBase()
{
}

void LayerBase::setName(const String8& name) {
    mName = name;
}

String8 LayerBase::getName() const {
    return mName;
}

const GraphicPlane& LayerBase::graphicPlane(int dpy) const
{ 
    return mFlinger->graphicPlane(dpy);
@@ -698,8 +706,7 @@ int32_t LayerBaseClient::sIdentity = 0;

LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display,
        const sp<Client>& client, int32_t i)
    : LayerBase(flinger, display), lcblk(NULL), client(client),
      mDebug(false), mIndex(i),
    : LayerBase(flinger, display), lcblk(NULL), client(client), mIndex(i),
      mIdentity(uint32_t(android_atomic_inc(&sIdentity)))
{
    lcblk = new SharedBufferServer(
@@ -724,14 +731,6 @@ LayerBaseClient::~LayerBaseClient()
    delete lcblk;
}

void LayerBaseClient::setName(const String8& name) {
    mName = name;
}

String8 LayerBaseClient::getName() const {
    return mName;
}

int32_t LayerBaseClient::serverIndex() const 
{
    sp<Client> client(this->client.promote());
+7 −7
Original line number Diff line number Diff line
@@ -101,6 +101,9 @@ public:
                Region          transparentRegion;
            };

            void setName(const String8& name);
            String8 getName() const;

            // modify current state
            bool setPosition(int32_t x, int32_t y);
            bool setLayer(uint32_t z);
@@ -287,6 +290,9 @@ protected:

                // don't change, don't need a lock
                bool            mPremultipliedAlpha;
                String8         mName;
    mutable     bool            mDebug;


                // atomic
    volatile    int32_t         mInvalidate;
@@ -320,8 +326,6 @@ public:
            const sp<Client>& client, int32_t i);
    virtual ~LayerBaseClient();
    virtual void onFirstRef();
    void setName(const String8& name);
    String8 getName() const;

    const wp<Client>    client;

@@ -369,15 +373,11 @@ public:

    friend class Surface;

protected:
    mutable     bool            mDebug;

private:
                int32_t         mIndex;
    mutable     Mutex           mLock;
    mutable     wp<Surface>     mClientSurface;
    // only read
                String8         mName;
    const       uint32_t        mIdentity;
    static      int32_t         sIdentity;
};
+40 −36
Original line number Diff line number Diff line
@@ -65,17 +65,14 @@ Transform::Transform(uint32_t orientation) {
Transform::~Transform() {
}


bool Transform::absIsOne(float f) {
    return fabs(f) == 1.0f;
}
static const float EPSILON = 0.0f;

bool Transform::isZero(float f) {
    return fabs(f) == 0.0f;
    return fabs(f) <= EPSILON;
}

bool Transform::absEqual(float a, float b) {
    return fabs(a) == fabs(b);
bool Transform::absIsOne(float f) {
    return isZero(fabs(f) - 1.0f);
}

Transform Transform::operator * (const Transform& rhs) const
@@ -154,8 +151,14 @@ void Transform::set(float a, float b, float c, float d)
    mType = UNKNOWN_TYPE;
}

void Transform::set(uint32_t flags, float w, float h)
status_t Transform::set(uint32_t flags, float w, float h)
{
    if (flags & ROT_INVALID) {
        // that's not allowed!
        reset();
        return BAD_VALUE;
    }

    mType = flags << 8;
    float sx = (flags & FLIP_H) ? -1 : 1;
    float sy = (flags & FLIP_V) ? -1 : 1;
@@ -205,6 +208,8 @@ void Transform::set(uint32_t flags, float w, float h)
    M[0][0] = a;    M[1][0] = b;    M[2][0] = x;
    M[0][1] = c;    M[1][1] = d;    M[2][1] = y;
    M[0][2] = 0;    M[1][2] = 0;    M[2][2] = 1;

    return NO_ERROR;
}

Transform::vec2 Transform::transform(const vec2& v) const {
@@ -295,17 +300,12 @@ uint32_t Transform::type() const
        bool scale = false;
        uint32_t flags = ROT_0;
        if (isZero(b) && isZero(c)) {
            if (absEqual(a, d)) {
            if (a<0)    flags |= FLIP_H;
            if (d<0)    flags |= FLIP_V;
            if (!absIsOne(a) || !absIsOne(d)) {
                scale = true;
            }
            } else {
                flags = ROT_INVALID;
            }
        } else if (isZero(a) && isZero(d)) {
            if (absEqual(b, c)) {
            flags |= ROT_90;
            if (b>0)    flags |= FLIP_H;
            if (c<0)    flags |= FLIP_V;
@@ -315,9 +315,6 @@ uint32_t Transform::type() const
        } else {
            flags = ROT_INVALID;
        }
        } else {
            flags = ROT_INVALID;
        }

        mType = flags << 8;
        if (flags & ROT_INVALID) {
@@ -361,15 +358,22 @@ void Transform::dump(const char* name) const
    const mat33& m(mMatrix);
    uint32_t orient = mType >> 8;

    if (orient&ROT_INVALID)
    if (orient&ROT_INVALID) {
        flags.append("ROT_INVALID ");
    if (orient&ROT_90)
    } else {
        if (orient&ROT_90) {
            flags.append("ROT_90 ");
        } else {
            flags.append("ROT_0 ");
        }
        if (orient&FLIP_V)
            flags.append("FLIP_V ");
        if (orient&FLIP_H)
            flags.append("FLIP_H ");
    }

    if (!(mType&(SCALE|ROTATE|TRANSLATE)))
        type.append("IDENTITY ");
    if (mType&SCALE)
        type.append("SCALE ");
    if (mType&ROTATE)
@@ -377,10 +381,10 @@ void Transform::dump(const char* name) const
    if (mType&TRANSLATE)
        type.append("TRANSLATE ");

    LOGD("%s (%s, %s)", name, flags.string(), type.string());
    LOGD("%.2f  %.2f  %.2f", m[0][0], m[1][0], m[2][0]);
    LOGD("%.2f  %.2f  %.2f", m[0][1], m[1][1], m[2][1]);
    LOGD("%.2f  %.2f  %.2f", m[0][2], m[1][2], m[2][2]);
    LOGD("%s 0x%08x (%s, %s)", name, mType, flags.string(), type.string());
    LOGD("%.4f  %.4f  %.4f", m[0][0], m[1][0], m[2][0]);
    LOGD("%.4f  %.4f  %.4f", m[0][1], m[1][1], m[2][1]);
    LOGD("%.4f  %.4f  %.4f", m[0][2], m[1][2], m[2][2]);
}

// ---------------------------------------------------------------------------
+7 −7
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public:
            void        reset();
            void        set(float tx, float ty);
            void        set(float a, float b, float c, float d);
            void    set(uint32_t flags, float w, float h);
            status_t    set(uint32_t flags, float w, float h);

            // transform data
            Rect    makeBounds(int w, int h) const;
@@ -80,6 +80,9 @@ public:
            Region  transform(const Region& reg) const;
            Transform operator * (const Transform& rhs) const;

            // for debugging
            void dump(const char* name) const;

private:
    struct vec3 {
        float v[3];
@@ -113,11 +116,8 @@ private:
    Rect transform(const Rect& bounds) const;
    uint32_t type() const;
    static bool absIsOne(float f);
    static bool absEqual(float a, float b);
    static bool isZero(float f);

    void dump(const char* name) const;

    mat33               mMatrix;
    mutable uint32_t    mType;
};