OSDN Git Service

fix [3312683] Camera mirroring problem after switching from back to front camera
authorMathias Agopian <mathias@google.com>
Fri, 14 Jan 2011 01:53:01 +0000 (17:53 -0800)
committerMathias Agopian <mathias@google.com>
Fri, 14 Jan 2011 01:53:01 +0000 (17:53 -0800)
the crop as well as buffer orientation can change at every frame, when that happens
we need to reset the hwc HAL (ie: set the GEOMETRY_CHANGED flag).
currently we achieve this by taking the same code path than an actual geometry change
which is a bit more heavy than necessary.

Change-Id: I751f9ed1eeec0c27db7df2e77d5d17c6bcc17a24

services/surfaceflinger/LayerBase.cpp
services/surfaceflinger/SurfaceFlinger.cpp
services/surfaceflinger/SurfaceFlinger.h

index 8a021cb..0c1fcf9 100644 (file)
@@ -503,12 +503,18 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
 
 void LayerBase::setBufferCrop(const Rect& crop) {
     if (!crop.isEmpty()) {
-        mBufferCrop = crop;
+        if (mBufferCrop != crop) {
+            mBufferCrop = crop;
+            mFlinger->invalidateHwcGeometry();
+        }
     }
 }
 
 void LayerBase::setBufferTransform(uint32_t transform) {
-    mBufferTransform = transform;
+    if (mBufferTransform != transform) {
+        mBufferTransform = transform;
+        mFlinger->invalidateHwcGeometry();
+    }
 }
 
 void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const
index c982ea5..9d32547 100644 (file)
@@ -460,7 +460,7 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags)
         handleTransactionLocked(transactionFlags, ditchedLayers);
         mLastTransactionTime = systemTime() - now;
         mDebugInTransaction = 0;
-        mHwWorkListDirty = true;
+        invalidateHwcGeometry();
         // here the transaction has been committed
     }
 
@@ -726,13 +726,18 @@ void SurfaceFlinger::handlePageFlip()
 
             mWormholeRegion = screenRegion.subtract(opaqueRegion);
             mVisibleRegionsDirty = false;
-            mHwWorkListDirty = true;
+            invalidateHwcGeometry();
         }
 
     unlockPageFlip(currentLayers);
     mDirtyRegion.andSelf(screenRegion);
 }
 
+void SurfaceFlinger::invalidateHwcGeometry()
+{
+    mHwWorkListDirty = true;
+}
+
 bool SurfaceFlinger::lockPageFlip(const LayerVector& currentLayers)
 {
     bool recomputeVisibleRegions = false;
@@ -1586,7 +1591,7 @@ status_t SurfaceFlinger::onTransact(
             case 1008:  // toggle use of hw composer
                 n = data.readInt32();
                 mDebugDisableHWC = n ? 1 : 0;
-                mHwWorkListDirty = true;
+                invalidateHwcGeometry();
                 // fall-through...
             case 1004:{ // repaint everything
                 Mutex::Autolock _l(mStateLock);
index 48642d4..0729879 100644 (file)
@@ -208,6 +208,7 @@ public:
     status_t removeLayer(const sp<LayerBase>& layer);
     status_t addLayer(const sp<LayerBase>& layer);
     status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
+    void invalidateHwcGeometry();
 
     sp<Layer> getLayer(const sp<ISurface>& sur) const;