diff options
author | Mathias Agopian <mathias@google.com> | 2010-03-09 19:17:47 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-03-11 12:55:39 -0800 |
commit | 015b59756eecdbec46f9aeda620ad0de1c8c9a23 (patch) | |
tree | 24ace4ee0eb7a936fc81d3146ce5adda1636d373 /libs/surfaceflinger | |
parent | 6fc4fe98ab72c5852b87f1f8699b9808c0dbecc5 (diff) | |
download | frameworks_base-015b59756eecdbec46f9aeda620ad0de1c8c9a23.zip frameworks_base-015b59756eecdbec46f9aeda620ad0de1c8c9a23.tar.gz frameworks_base-015b59756eecdbec46f9aeda620ad0de1c8c9a23.tar.bz2 |
fix [2483456] Video orientation is wrong on Droid for some videos
Change-Id: I450191f1335f57bffc51aff3e27295395847dbc0
Diffstat (limited to 'libs/surfaceflinger')
-rw-r--r-- | libs/surfaceflinger/LayerBase.cpp | 21 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.h | 14 | ||||
-rw-r--r-- | libs/surfaceflinger/Transform.cpp | 76 | ||||
-rw-r--r-- | libs/surfaceflinger/Transform.h | 14 |
4 files changed, 64 insertions, 61 deletions
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index fdf6627..140f10c 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -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()); diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index 852b9f9..a6e5644 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -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); @@ -121,7 +124,7 @@ public: void drawRegion(const Region& reg) const; void invalidate(); - + /** * draw - performs some global clipping optimizations * and calls onDraw(). @@ -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; }; diff --git a/libs/surfaceflinger/Transform.cpp b/libs/surfaceflinger/Transform.cpp index b2d5856..175f989 100644 --- a/libs/surfaceflinger/Transform.cpp +++ b/libs/surfaceflinger/Transform.cpp @@ -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,25 +300,17 @@ 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; + if (a<0) flags |= FLIP_H; + if (d<0) flags |= FLIP_V; + if (!absIsOne(a) || !absIsOne(d)) { + scale = true; } } 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; - if (!absIsOne(b) || !absIsOne(c)) { - scale = true; - } - } else { - flags = ROT_INVALID; + flags |= ROT_90; + if (b>0) flags |= FLIP_H; + if (c<0) flags |= FLIP_V; + if (!absIsOne(b) || !absIsOne(c)) { + scale = true; } } else { 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) - flags.append("ROT_90 "); - if (orient&FLIP_V) - flags.append("FLIP_V "); - if (orient&FLIP_H) - flags.append("FLIP_H "); + } 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]); } // --------------------------------------------------------------------------- diff --git a/libs/surfaceflinger/Transform.h b/libs/surfaceflinger/Transform.h index 51d3e3f..2e5b893 100644 --- a/libs/surfaceflinger/Transform.h +++ b/libs/surfaceflinger/Transform.h @@ -69,10 +69,10 @@ public: int ty() const; // modify the transform - 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); + void reset(); + void set(float tx, float ty); + void set(float a, float b, float c, float d); + 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; }; |