get rid of GraphicPlane

its functionality is now folded into DisplayHardware
there will be more changes in that area.
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index f4bf9ef..e4fd291 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -3,12 +3,12 @@
 
 LOCAL_SRC_FILES:= \
     Client.cpp                              \
+    DisplayHardware.cpp     				\
     EventThread.cpp                         \
     Layer.cpp                               \
     LayerBase.cpp                           \
     LayerDim.cpp                            \
     LayerScreenshot.cpp                     \
-    DisplayHardware/DisplayHardware.cpp     \
     DisplayHardware/DisplayHardwareBase.cpp \
     DisplayHardware/FramebufferSurface.cpp  \
     DisplayHardware/HWComposer.cpp          \
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware.cpp
similarity index 83%
rename from services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
rename to services/surfaceflinger/DisplayHardware.cpp
index bb537c9..eac9e04 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/services/surfaceflinger/DisplayHardware.cpp
@@ -30,14 +30,14 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 
-#include "DisplayHardware/DisplayHardware.h"
-#include "DisplayHardware/FramebufferSurface.h"
-
 #include <hardware/gralloc.h>
 
-#include "DisplayHardwareBase.h"
+#include "DisplayHardware/FramebufferSurface.h"
+#include "DisplayHardware/DisplayHardwareBase.h"
+#include "DisplayHardware/HWComposer.h"
+
+#include "DisplayHardware.h"
 #include "GLExtensions.h"
-#include "HWComposer.h"
 #include "SurfaceFlinger.h"
 
 using namespace android;
@@ -111,8 +111,8 @@
 float DisplayHardware::getDpiY() const          { return mDpiY; }
 float DisplayHardware::getDensity() const       { return mDensity; }
 float DisplayHardware::getRefreshRate() const   { return mRefreshRate; }
-int DisplayHardware::getWidth() const           { return mWidth; }
-int DisplayHardware::getHeight() const          { return mHeight; }
+int DisplayHardware::getWidth() const           { return mDisplayWidth; }
+int DisplayHardware::getHeight() const          { return mDisplayHeight; }
 PixelFormat DisplayHardware::getFormat() const  { return mFormat; }
 uint32_t DisplayHardware::getMaxTextureSize() const { return mMaxTextureSize; }
 
@@ -267,8 +267,8 @@
      */
 
     surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL);
-    eglQuerySurface(display, surface, EGL_WIDTH,  &mWidth);
-    eglQuerySurface(display, surface, EGL_HEIGHT, &mHeight);
+    eglQuerySurface(display, surface, EGL_WIDTH,  &mDisplayWidth);
+    eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight);
 
     if (mFlags & PARTIAL_UPDATES) {
         // if we have partial updates, we definitely don't need to
@@ -348,6 +348,36 @@
     if (mHwc->initCheck() == NO_ERROR) {
         mHwc->setFrameBuffer(mDisplay, mSurface);
     }
+
+
+    // initialize the display orientation transform.
+    // it's a constant that should come from the display driver.
+    int displayOrientation = ISurfaceComposer::eOrientationDefault;
+    char property[PROPERTY_VALUE_MAX];
+    if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
+        //displayOrientation
+        switch (atoi(property)) {
+        case 90:
+            displayOrientation = ISurfaceComposer::eOrientation90;
+            break;
+        case 270:
+            displayOrientation = ISurfaceComposer::eOrientation270;
+            break;
+        }
+    }
+
+    w = mDisplayWidth;
+    h = mDisplayHeight;
+    DisplayHardware::orientationToTransfrom(displayOrientation, w, h,
+            &mDisplayTransform);
+    if (displayOrientation & ISurfaceComposer::eOrientationSwapMask) {
+        mLogicalDisplayWidth = h;
+        mLogicalDisplayHeight = w;
+    } else {
+        mLogicalDisplayWidth = w;
+        mLogicalDisplayHeight = h;
+    }
+    DisplayHardware::setOrientation(ISurfaceComposer::eOrientationDefault);
 }
 
 void DisplayHardware::setVSyncHandler(const sp<VSyncHandler>& handler) {
@@ -476,3 +506,52 @@
 {
     mNativeWindow->dump(res);
 }
+
+// ----------------------------------------------------------------------------
+
+status_t DisplayHardware::orientationToTransfrom(
+        int orientation, int w, int h, Transform* tr)
+{
+    uint32_t flags = 0;
+    switch (orientation) {
+    case ISurfaceComposer::eOrientationDefault:
+        flags = Transform::ROT_0;
+        break;
+    case ISurfaceComposer::eOrientation90:
+        flags = Transform::ROT_90;
+        break;
+    case ISurfaceComposer::eOrientation180:
+        flags = Transform::ROT_180;
+        break;
+    case ISurfaceComposer::eOrientation270:
+        flags = Transform::ROT_270;
+        break;
+    default:
+        return BAD_VALUE;
+    }
+    tr->set(flags, w, h);
+    return NO_ERROR;
+}
+
+status_t DisplayHardware::setOrientation(int orientation)
+{
+    // If the rotation can be handled in hardware, this is where
+    // the magic should happen.
+
+    const int w = mLogicalDisplayWidth;
+    const int h = mLogicalDisplayHeight;
+    mUserDisplayWidth = w;
+    mUserDisplayHeight = h;
+
+    Transform orientationTransform;
+    DisplayHardware::orientationToTransfrom(orientation, w, h,
+            &orientationTransform);
+    if (orientation & ISurfaceComposer::eOrientationSwapMask) {
+        mUserDisplayWidth = h;
+        mUserDisplayHeight = w;
+    }
+
+    mOrientation = orientation;
+    mGlobalTransform = mDisplayTransform * orientationTransform;
+    return NO_ERROR;
+}
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.h b/services/surfaceflinger/DisplayHardware.h
similarity index 77%
rename from services/surfaceflinger/DisplayHardware/DisplayHardware.h
rename to services/surfaceflinger/DisplayHardware.h
index 31662dd..3da9f16 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.h
+++ b/services/surfaceflinger/DisplayHardware.h
@@ -28,10 +28,11 @@
 #include <EGL/eglext.h>
 
 #include "GLExtensions.h"
+#include "Transform.h"
 
 #include "DisplayHardware/DisplayHardwareBase.h"
-#include "HWComposer.h"
-#include "PowerHAL.h"
+#include "DisplayHardware/HWComposer.h"
+#include "DisplayHardware/PowerHAL.h"
 
 namespace android {
 
@@ -84,6 +85,11 @@
     nsecs_t     getRefreshTimestamp() const;
     void        makeCurrent() const;
 
+    status_t                setOrientation(int orientation);
+    int                     getOrientation() const { return mOrientation; }
+    const Transform&        getTransform() const { return mGlobalTransform; }
+    int                     getUserWidth() const { return mUserDisplayWidth; }
+    int                     getUserHeight() const { return mUserDisplayHeight; }
 
     void setVSyncHandler(const sp<VSyncHandler>& handler);
 
@@ -106,14 +112,14 @@
     status_t compositionComplete() const;
     
     Rect getBounds() const {
-        return Rect(mWidth, mHeight);
+        return Rect(mDisplayWidth, mDisplayHeight);
     }
     inline Rect bounds() const { return getBounds(); }
 
 private:
     virtual void onVSyncReceived(int dpy, nsecs_t timestamp);
-    void init(uint32_t displayIndex) __attribute__((noinline));
-    void fini() __attribute__((noinline));
+    void init(uint32_t displayIndex);
+    void fini();
 
     sp<SurfaceFlinger> mFlinger;
     EGLDisplay      mDisplay;
@@ -124,8 +130,8 @@
     float           mDpiY;
     float           mRefreshRate;
     float           mDensity;
-    int             mWidth;
-    int             mHeight;
+    int             mDisplayWidth;
+    int             mDisplayHeight;
     PixelFormat     mFormat;
     uint32_t        mFlags;
     mutable uint32_t mPageFlipCount;
@@ -140,6 +146,18 @@
     PowerHAL        mPowerHAL;
 
 
+    // this used to be in GraphicPlane
+    static status_t orientationToTransfrom(int orientation, int w, int h,
+            Transform* tr);
+    Transform               mGlobalTransform;
+    Transform               mDisplayTransform;
+    int                     mOrientation;
+    int                     mLogicalDisplayWidth;
+    int                     mLogicalDisplayHeight;
+    int                     mUserDisplayWidth;
+    int                     mUserDisplayHeight;
+
+
     mutable Mutex   mLock;
 
     // protected by mLock
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index 7c1aebe..0f11377 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -26,7 +26,7 @@
 #include <utils/Errors.h>
 #include <utils/Trace.h>
 
-#include "DisplayHardware/DisplayHardware.h"
+#include "DisplayHardware.h"
 #include "EventThread.h"
 #include "SurfaceFlinger.h"
 
@@ -38,7 +38,7 @@
 
 EventThread::EventThread(const sp<SurfaceFlinger>& flinger)
     : mFlinger(flinger),
-      mHw(flinger->graphicPlane(0).editDisplayHardware()),
+      mHw(const_cast<DisplayHardware&>(flinger->getDefaultDisplayHardware())), // XXX: eventthread will need rework
       mLastVSyncTimestamp(0),
       mVSyncTimestamp(0),
       mUseSoftwareVSync(false),
diff --git a/services/surfaceflinger/EventThread.h b/services/surfaceflinger/EventThread.h
index b42cab6..04c8f53 100644
--- a/services/surfaceflinger/EventThread.h
+++ b/services/surfaceflinger/EventThread.h
@@ -27,7 +27,7 @@
 #include <utils/threads.h>
 #include <utils/SortedVector.h>
 
-#include "DisplayHardware/DisplayHardware.h"
+#include "DisplayHardware.h"
 
 // ---------------------------------------------------------------------------
 
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 64e4b5f..6aba16a 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -36,13 +36,14 @@
 #include <gui/Surface.h>
 
 #include "clz.h"
-#include "DisplayHardware/DisplayHardware.h"
-#include "DisplayHardware/HWComposer.h"
+#include "DisplayHardware.h"
 #include "GLExtensions.h"
 #include "Layer.h"
 #include "SurfaceFlinger.h"
 #include "SurfaceTextureLayer.h"
 
+#include "DisplayHardware/HWComposer.h"
+
 #define DEBUG_RESIZE    0
 
 namespace android {
@@ -63,7 +64,6 @@
         mFormat(PIXEL_FORMAT_NONE),
         mGLExtensions(GLExtensions::getInstance()),
         mOpaqueLayer(true),
-        mNeedsDithering(false),
         mSecure(false),
         mProtectedByApp(false)
 {
@@ -77,7 +77,9 @@
     }
 
     if (mFrameLatencyNeeded) {
-        const DisplayHardware& hw(graphicPlane(0).displayHardware());
+        // we need a DisplayHardware for debugging only right now
+        // XXX: should this be called per DisplayHardware?
+        const DisplayHardware& hw(mFlinger->getDefaultDisplayHardware());
         mFrameStats[mFrameLatencyOffset].timestamp = mSurfaceTexture->getTimestamp();
         mFrameStats[mFrameLatencyOffset].set = systemTime();
         mFrameStats[mFrameLatencyOffset].vsync = hw.getRefreshTimestamp();
@@ -142,8 +144,8 @@
     mSurfaceTexture->setName(name);
 }
 
-void Layer::validateVisibility(const Transform& globalTransform) {
-    LayerBase::validateVisibility(globalTransform);
+void Layer::validateVisibility(const Transform& globalTransform, const DisplayHardware& hw) {
+    LayerBase::validateVisibility(globalTransform, hw);
 
     // This optimization allows the SurfaceTexture to bake in
     // the rotation so hardware overlays can be used
@@ -188,7 +190,8 @@
     }
 
     // the display's pixel format
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    // XXX: we shouldn't rely on the DisplayHardware to do this
+    const DisplayHardware& hw(mFlinger->getDefaultDisplayHardware());
     uint32_t const maxSurfaceDims = min(
             hw.getMaxTextureSize(), hw.getMaxViewportDims());
 
@@ -199,10 +202,6 @@
         return BAD_VALUE;
     }
 
-    PixelFormatInfo displayInfo;
-    getPixelFormatInfo(hw.getFormat(), &displayInfo);
-    const uint32_t hwFlags = hw.getFlags();
-    
     mFormat = format;
 
     mSecure = (flags & ISurfaceComposer::eSecure) ? true : false;
@@ -214,11 +213,6 @@
     mSurfaceTexture->setDefaultBufferFormat(format);
     mSurfaceTexture->setConsumerUsageBits(getEffectiveUsage(0));
 
-    // we use the red index
-    int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED);
-    int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED);
-    mNeedsDithering = layerRedsize > displayRedSize;
-
     return NO_ERROR;
 }
 
@@ -307,7 +301,7 @@
     layer.setBuffer(buffer);
 }
 
-void Layer::onDraw(const Region& clip) const
+void Layer::onDraw(const DisplayHardware& hw, const Region& clip) const
 {
     ATRACE_CALL();
 
@@ -334,7 +328,7 @@
         // if not everything below us is covered, we plug the holes!
         Region holes(clip.subtract(under));
         if (!holes.isEmpty()) {
-            clearWithOpenGL(holes, 0, 0, 0, 1);
+            clearWithOpenGL(hw, holes, 0, 0, 0, 1);
         }
         return;
     }
@@ -370,7 +364,7 @@
         glEnable(GL_TEXTURE_2D);
     }
 
-    drawWithOpenGL(clip);
+    drawWithOpenGL(hw, clip);
 
     glDisable(GL_TEXTURE_EXTERNAL_OES);
     glDisable(GL_TEXTURE_2D);
@@ -730,7 +724,7 @@
 {
     LayerBaseClient::dumpStats(result, buffer, SIZE);
     const size_t o = mFrameLatencyOffset;
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(mFlinger->getDefaultDisplayHardware());
     const nsecs_t period = hw.getRefreshPeriod();
     result.appendFormat("%lld\n", period);
     for (size_t i=0 ; i<128 ; i++) {
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 32456f4..d47f2e8 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -66,18 +66,17 @@
     // LayerBase interface
     virtual void setGeometry(HWComposer::HWCLayerInterface& layer);
     virtual void setPerFrameData(HWComposer::HWCLayerInterface& layer);
-    virtual void onDraw(const Region& clip) const;
+    virtual void onDraw(const DisplayHardware& hw, const Region& clip) const;
     virtual uint32_t doTransaction(uint32_t transactionFlags);
     virtual void lockPageFlip(bool& recomputeVisibleRegions);
     virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
     virtual bool isOpaque() const;
-    virtual bool needsDithering() const     { return mNeedsDithering; }
     virtual bool isSecure() const           { return mSecure; }
     virtual bool isProtected() const;
     virtual void onRemoved();
     virtual sp<Layer> getLayer() const { return const_cast<Layer*>(this); }
     virtual void setName(const String8& name);
-    virtual void validateVisibility(const Transform& globalTransform);
+    virtual void validateVisibility(const Transform& globalTransform, const DisplayHardware& hw);
 
     // LayerBaseClient interface
     virtual wp<IBinder> getSurfaceTextureBinder() const;
@@ -137,7 +136,6 @@
     PixelFormat mFormat;
     const GLExtensions& mGLExtensions;
     bool mOpaqueLayer;
-    bool mNeedsDithering;
 
     // page-flip thread (currently main thread)
     bool mSecure;         // no screenshots
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 893dcb9..fd4c223 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -32,7 +32,7 @@
 #include "Client.h"
 #include "LayerBase.h"
 #include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
+#include "DisplayHardware.h"
 
 namespace android {
 
@@ -50,8 +50,6 @@
       mTransactionFlags(0),
       mPremultipliedAlpha(true), mName("unnamed"), mDebug(false)
 {
-    const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware());
-    mFlags = hw.getFlags();
 }
 
 LayerBase::~LayerBase()
@@ -66,16 +64,6 @@
     return mName;
 }
 
-const GraphicPlane& LayerBase::graphicPlane(int dpy) const
-{ 
-    return mFlinger->graphicPlane(dpy);
-}
-
-GraphicPlane& LayerBase::graphicPlane(int dpy)
-{
-    return mFlinger->graphicPlane(dpy); 
-}
-
 void LayerBase::initStates(uint32_t w, uint32_t h, uint32_t flags)
 {
     uint32_t layerFlags = 0;
@@ -231,12 +219,11 @@
     return flags;
 }
 
-void LayerBase::validateVisibility(const Transform& planeTransform)
+void LayerBase::validateVisibility(const Transform& planeTransform, const DisplayHardware& hw)
 {
     const Layer::State& s(drawingState());
     const Transform tr(planeTransform * s.transform);
     const bool transformed = tr.transformed();
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     const uint32_t hw_h = hw.getHeight();
     const Rect& crop(s.active.crop);
 
@@ -322,24 +309,21 @@
     return mFiltering;
 }
 
-void LayerBase::draw(const Region& clip) const
+void LayerBase::draw(const DisplayHardware& hw, const Region& clip) const
 {
-    onDraw(clip);
+    onDraw(hw, clip);
 }
 
-void LayerBase::drawForSreenShot()
+void LayerBase::drawForSreenShot(const DisplayHardware& hw)
 {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     setFiltering(true);
-    onDraw( Region(hw.bounds()) );
+    onDraw( hw, Region(hw.bounds()) );
     setFiltering(false);
 }
 
-void LayerBase::clearWithOpenGL(const Region& clip, GLclampf red,
-                                GLclampf green, GLclampf blue,
-                                GLclampf alpha) const
+void LayerBase::clearWithOpenGL(const DisplayHardware& hw, const Region& clip,
+        GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) const
 {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     const uint32_t fbHeight = hw.getHeight();
     glColor4f(red,green,blue,alpha);
 
@@ -351,14 +335,13 @@
     glDrawArrays(GL_TRIANGLE_FAN, 0, mNumVertices);
 }
 
-void LayerBase::clearWithOpenGL(const Region& clip) const
+void LayerBase::clearWithOpenGL(const DisplayHardware& hw, const Region& clip) const
 {
-    clearWithOpenGL(clip,0,0,0,0);
+    clearWithOpenGL(hw, clip, 0,0,0,0);
 }
 
-void LayerBase::drawWithOpenGL(const Region& clip) const
+void LayerBase::drawWithOpenGL(const DisplayHardware& hw, const Region& clip) const
 {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     const uint32_t fbHeight = hw.getHeight();
     const State& s(drawingState());
 
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index 698cdb8..fb2e9bd 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -32,7 +32,7 @@
 
 #include <private/gui/LayerState.h>
 
-#include "DisplayHardware/DisplayHardware.h"
+#include "DisplayHardware.h"
 #include "Transform.h"
 
 namespace android {
@@ -42,7 +42,6 @@
 class Client;
 class DisplayHardware;
 class GraphicBuffer;
-class GraphicPlane;
 class Layer;
 class LayerBaseClient;
 class SurfaceFlinger;
@@ -124,13 +123,13 @@
      * Typically this method is not overridden, instead implement onDraw()
      * to perform the actual drawing.  
      */
-    virtual void draw(const Region& clip) const;
-    virtual void drawForSreenShot();
+    virtual void draw(const DisplayHardware& hw, const Region& clip) const;
+    virtual void drawForSreenShot(const DisplayHardware& hw);
     
     /**
      * onDraw - draws the surface.
      */
-    virtual void onDraw(const Region& clip) const = 0;
+    virtual void onDraw(const DisplayHardware& hw, const Region& clip) const = 0;
     
     /**
      * initStates - called just after construction
@@ -159,7 +158,7 @@
     /**
      * validateVisibility - cache a bunch of things
      */
-    virtual void validateVisibility(const Transform& globalTransform);
+    virtual void validateVisibility(const Transform& globalTransform, const DisplayHardware& hw);
 
     /**
      * lockPageFlip - called each time the screen is redrawn and returns whether
@@ -237,21 +236,17 @@
     int32_t  getOrientation() const { return mOrientation; }
     int32_t  getPlaneOrientation() const { return mPlaneOrientation; }
 
-    void clearWithOpenGL(const Region& clip) const;
+    void clearWithOpenGL(const DisplayHardware& hw, const Region& clip) const;
 
 protected:
-    const GraphicPlane& graphicPlane(int dpy) const;
-          GraphicPlane& graphicPlane(int dpy);
-
-          void clearWithOpenGL(const Region& clip, GLclampf r, GLclampf g,
-                               GLclampf b, GLclampf alpha) const;
-          void drawWithOpenGL(const Region& clip) const;
+          void clearWithOpenGL(const DisplayHardware& hw, const Region& clip,
+                  GLclampf r, GLclampf g, GLclampf b, GLclampf alpha) const;
+          void drawWithOpenGL(const DisplayHardware& hw, const Region& clip) const;
 
           void setFiltering(bool filtering);
           bool getFiltering() const;
 
                 sp<SurfaceFlinger> mFlinger;
-                uint32_t        mFlags;
 
 private:
                 // accessed only in the main thread
diff --git a/services/surfaceflinger/LayerDim.cpp b/services/surfaceflinger/LayerDim.cpp
index 96a310f..ceead45 100644
--- a/services/surfaceflinger/LayerDim.cpp
+++ b/services/surfaceflinger/LayerDim.cpp
@@ -25,7 +25,7 @@
 
 #include "LayerDim.h"
 #include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
+#include "DisplayHardware.h"
 
 namespace android {
 // ---------------------------------------------------------------------------
@@ -40,11 +40,10 @@
 {
 }
 
-void LayerDim::onDraw(const Region& clip) const
+void LayerDim::onDraw(const DisplayHardware& hw, const Region& clip) const
 {
     const State& s(drawingState());
     if (s.alpha>0) {
-        const DisplayHardware& hw(graphicPlane(0).displayHardware());
         const GLfloat alpha = s.alpha/255.0f;
         const uint32_t fbHeight = hw.getHeight();
         glDisable(GL_TEXTURE_EXTERNAL_OES);
diff --git a/services/surfaceflinger/LayerDim.h b/services/surfaceflinger/LayerDim.h
index 8770e6d..2d9eaef 100644
--- a/services/surfaceflinger/LayerDim.h
+++ b/services/surfaceflinger/LayerDim.h
@@ -36,7 +36,7 @@
                         const sp<Client>& client);
         virtual ~LayerDim();
 
-    virtual void onDraw(const Region& clip) const;
+    virtual void onDraw(const DisplayHardware& hw, const Region& clip) const;
     virtual bool isOpaque() const         { return false; }
     virtual bool isSecure() const         { return false; }
     virtual bool isProtectedByApp() const { return false; }
diff --git a/services/surfaceflinger/LayerScreenshot.cpp b/services/surfaceflinger/LayerScreenshot.cpp
index b42353c..d046879 100644
--- a/services/surfaceflinger/LayerScreenshot.cpp
+++ b/services/surfaceflinger/LayerScreenshot.cpp
@@ -25,7 +25,7 @@
 
 #include "LayerScreenshot.h"
 #include "SurfaceFlinger.h"
-#include "DisplayHardware/DisplayHardware.h"
+#include "DisplayHardware.h"
 
 
 namespace android {
@@ -106,11 +106,10 @@
     return LayerBaseClient::doTransaction(flags);
 }
 
-void LayerScreenshot::onDraw(const Region& clip) const
+void LayerScreenshot::onDraw(const DisplayHardware& hw, const Region& clip) const
 {
     const State& s(drawingState());
     if (s.alpha>0) {
-        const DisplayHardware& hw(graphicPlane(0).displayHardware());
         const GLfloat alpha = s.alpha/255.0f;
         const uint32_t fbHeight = hw.getHeight();
 
diff --git a/services/surfaceflinger/LayerScreenshot.h b/services/surfaceflinger/LayerScreenshot.h
index ab90047..0ddb376 100644
--- a/services/surfaceflinger/LayerScreenshot.h
+++ b/services/surfaceflinger/LayerScreenshot.h
@@ -43,7 +43,7 @@
 
     virtual void initStates(uint32_t w, uint32_t h, uint32_t flags);
     virtual uint32_t doTransaction(uint32_t flags);
-    virtual void onDraw(const Region& clip) const;
+    virtual void onDraw(const DisplayHardware& hw, const Region& clip) const;
     virtual bool isOpaque() const         { return false; }
     virtual bool isSecure() const         { return false; }
     virtual bool isProtectedByApp() const { return false; }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 07ea3a0..6dfbe5b 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -50,6 +50,7 @@
 
 #include "clz.h"
 #include "DdmConnection.h"
+#include "DisplayHardware.h"
 #include "Client.h"
 #include "EventThread.h"
 #include "GLExtensions.h"
@@ -58,7 +59,6 @@
 #include "LayerScreenshot.h"
 #include "SurfaceFlinger.h"
 
-#include "DisplayHardware/DisplayHardware.h"
 #include "DisplayHardware/HWComposer.h"
 
 #include <private/android_filesystem_config.h>
@@ -178,19 +178,6 @@
     return gba;
 }
 
-const GraphicPlane& SurfaceFlinger::graphicPlane(int dpy) const
-{
-    ALOGE_IF(uint32_t(dpy) >= DISPLAY_COUNT, "Invalid DisplayID %d", dpy);
-    const GraphicPlane& plane(mGraphicPlanes[dpy]);
-    return plane;
-}
-
-GraphicPlane& SurfaceFlinger::graphicPlane(int dpy)
-{
-    return const_cast<GraphicPlane&>(
-        const_cast<SurfaceFlinger const *>(this)->graphicPlane(dpy));
-}
-
 void SurfaceFlinger::bootFinished()
 {
     const nsecs_t now = systemTime();
@@ -217,7 +204,7 @@
 
 status_t SurfaceFlinger::readyToRun()
 {
-    ALOGI(   "SurfaceFlinger's main thread ready to run. "
+    ALOGI(  "SurfaceFlinger's main thread ready to run. "
             "Initializing graphics H/W...");
 
     // we only support one display currently
@@ -225,9 +212,9 @@
 
     {
         // initialize the main display
-        GraphicPlane& plane(graphicPlane(dpy));
+        // TODO: initialize all displays
         DisplayHardware* const hw = new DisplayHardware(this, dpy);
-        plane.setDisplayHardware(hw);
+        mDisplayHardwares[0] = hw;
     }
 
     // create the shared control-block
@@ -244,8 +231,7 @@
     // (other display should be initialized in the same manner, but
     // asynchronously, as they could come and go. None of this is supported
     // yet).
-    const GraphicPlane& plane(graphicPlane(dpy));
-    const DisplayHardware& hw = plane.displayHardware();
+    const DisplayHardware& hw(getDefaultDisplayHardware());
     const uint32_t w = hw.getWidth();
     const uint32_t h = hw.getHeight();
     const uint32_t f = hw.getFormat();
@@ -255,8 +241,8 @@
     mServerCblk->connected |= 1<<dpy;
     display_cblk_t* dcblk = mServerCblk->displays + dpy;
     memset(dcblk, 0, sizeof(display_cblk_t));
-    dcblk->w            = plane.getWidth();
-    dcblk->h            = plane.getHeight();
+    dcblk->w            = w; // XXX: plane.getWidth();
+    dcblk->h            = h; // XXX: plane.getHeight();
     dcblk->format       = f;
     dcblk->orientation  = ISurfaceComposer::eOrientationDefault;
     dcblk->xdpi         = hw.getDpiX();
@@ -373,7 +359,7 @@
 }
 
 void SurfaceFlinger::connectDisplay(const sp<ISurfaceTexture> display) {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware());
     EGLSurface result = EGL_NO_SURFACE;
     EGLSurface old_surface = EGL_NO_SURFACE;
     sp<SurfaceTextureClient> stc;
@@ -469,7 +455,8 @@
 
             handleRefresh();
 
-            const DisplayHardware& hw(graphicPlane(0).displayHardware());
+            // TODO: iterate through all displays
+            const DisplayHardware& hw(getDisplayHardware(0));
 
 //            if (mDirtyRegion.isEmpty()) {
 //                return;
@@ -477,12 +464,12 @@
 
             if (CC_UNLIKELY(mHwWorkListDirty)) {
                 // build the h/w work list
-                handleWorkList();
+                handleWorkList(hw);
             }
 
             if (CC_LIKELY(hw.canDraw())) {
                 // repaint the framebuffer (if needed)
-                handleRepaint();
+                handleRepaint(hw);
                 // inform the h/w that we're done compositing
                 hw.compositionComplete();
                 postFramebuffer();
@@ -513,7 +500,7 @@
                     const size_t count = layers.size();
                     for (size_t i=0 ; i<count ; ++i) {
                         const sp<LayerBase>& layer(layers[i]);
-                        layer->drawForSreenShot();
+                        layer->drawForSreenShot(hw);
                     }
 
                     success = eglSwapBuffers(eglGetCurrentDisplay(), externalDisplaySurface);
@@ -540,13 +527,13 @@
     // in that case, we need to flip anyways to not risk a deadlock with
     // h/w composer.
 
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware());
     const nsecs_t now = systemTime();
     mDebugInSwapBuffers = now;
     hw.flip(mSwapRegion);
 
     size_t numLayers = mVisibleLayersSortedByZ.size();
-    HWComposer& hwc(graphicPlane(0).displayHardware().getHwComposer());
+    HWComposer& hwc(hw.getHwComposer());
     if (hwc.initCheck() == NO_ERROR) {
         HWComposer::LayerListIterator cur = hwc.begin();
         const HWComposer::LayerListIterator end = hwc.end();
@@ -620,19 +607,18 @@
             // the orientation has changed, recompute all visible regions
             // and invalidate everything.
 
-            const int dpy = 0;
+            const int dpy = 0; // TODO: should be a parameter
+            DisplayHardware& hw(const_cast<DisplayHardware&>(getDisplayHardware(dpy)));
             const int orientation = mCurrentState.orientation;
-            // Currently unused: const uint32_t flags = mCurrentState.orientationFlags;
-            GraphicPlane& plane(graphicPlane(dpy));
-            plane.setOrientation(orientation);
+            hw.setOrientation(orientation);
 
             // update the shared control block
-            const DisplayHardware& hw(plane.displayHardware());
             volatile display_cblk_t* dcblk = mServerCblk->displays + dpy;
             dcblk->orientation = orientation;
-            dcblk->w = plane.getWidth();
-            dcblk->h = plane.getHeight();
+            dcblk->w = hw.getUserWidth();
+            dcblk->h = hw.getUserHeight();
 
+            // FIXME: mVisibleRegionsDirty & mDirtyRegion should this be per DisplayHardware?
             mVisibleRegionsDirty = true;
             mDirtyRegion.set(hw.bounds());
         }
@@ -667,9 +653,8 @@
 {
     ATRACE_CALL();
 
-    const GraphicPlane& plane(graphicPlane(0));
-    const Transform& planeTransform(plane.transform());
-    const DisplayHardware& hw(plane.displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware()); // FIXME: we shouldn't rely on DisplayHardware here
+    const Transform& planeTransform(hw.getTransform());
     const Region screenRegion(hw.bounds());
 
     Region aboveOpaqueLayers;
@@ -681,7 +666,7 @@
     size_t i = currentLayers.size();
     while (i--) {
         const sp<LayerBase>& layer = currentLayers[i];
-        layer->validateVisibility(planeTransform);
+        layer->validateVisibility(planeTransform, hw);
 
         // start with the whole surface at its current location
         const Layer::State& s(layer->drawingState());
@@ -808,7 +793,7 @@
 void SurfaceFlinger::handlePageFlip()
 {
     ATRACE_CALL();
-    const DisplayHardware& hw = graphicPlane(0).displayHardware();
+    const DisplayHardware& hw(getDefaultDisplayHardware()); // FIXME: it's a problem we need DisplayHardware here
     const Region screenRegion(hw.bounds());
 
     const LayerVector& currentLayers(mDrawingState.layersSortedByZ);
@@ -859,8 +844,8 @@
 
 void SurfaceFlinger::unlockPageFlip(const LayerVector& currentLayers)
 {
-    const GraphicPlane& plane(graphicPlane(0));
-    const Transform& planeTransform(plane.transform());
+    const DisplayHardware& hw(getDefaultDisplayHardware()); // FIXME: it's a problem we need DisplayHardware here
+    const Transform& planeTransform(hw.getTransform());
     const size_t count = currentLayers.size();
     sp<LayerBase> const* layers = currentLayers.array();
     for (size_t i=0 ; i<count ; i++) {
@@ -886,10 +871,10 @@
 }
 
 
-void SurfaceFlinger::handleWorkList()
+void SurfaceFlinger::handleWorkList(const DisplayHardware& hw)
 {
     mHwWorkListDirty = false;
-    HWComposer& hwc(graphicPlane(0).displayHardware().getHwComposer());
+    HWComposer& hwc(hw.getHwComposer());
     if (hwc.initCheck() == NO_ERROR) {
         const Vector< sp<LayerBase> >& currentLayers(mVisibleLayersSortedByZ);
         const size_t count = currentLayers.size();
@@ -906,7 +891,7 @@
     }
 }
 
-void SurfaceFlinger::handleRepaint()
+void SurfaceFlinger::handleRepaint(const DisplayHardware& hw)
 {
     ATRACE_CALL();
 
@@ -914,11 +899,10 @@
     mSwapRegion.orSelf(mDirtyRegion);
 
     if (CC_UNLIKELY(mDebugRegion)) {
-        debugFlashRegions();
+        debugFlashRegions(hw);
     }
 
     // set the frame buffer
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
 
@@ -942,19 +926,17 @@
         }
     }
 
-    setupHardwareComposer();
-    composeSurfaces(mDirtyRegion);
+    setupHardwareComposer(hw);
+    composeSurfaces(hw, mDirtyRegion);
 
     // update the swap region and clear the dirty region
     mSwapRegion.orSelf(mDirtyRegion);
     mDirtyRegion.clear();
 }
 
-void SurfaceFlinger::setupHardwareComposer()
+void SurfaceFlinger::setupHardwareComposer(const DisplayHardware& hw)
 {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     HWComposer& hwc(hw.getHwComposer());
-
     HWComposer::LayerListIterator cur = hwc.begin();
     const HWComposer::LayerListIterator end = hwc.end();
     if (cur == end) {
@@ -985,9 +967,8 @@
     ALOGE_IF(err, "HWComposer::prepare failed (%s)", strerror(-err));
 }
 
-void SurfaceFlinger::composeSurfaces(const Region& dirty)
+void SurfaceFlinger::composeSurfaces(const DisplayHardware& hw, const Region& dirty)
 {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     HWComposer& hwc(hw.getHwComposer());
     HWComposer::LayerListIterator cur = hwc.begin();
     const HWComposer::LayerListIterator end = hwc.end();
@@ -1027,20 +1008,19 @@
                             && layer->isOpaque()) {
                         // never clear the very first layer since we're
                         // guaranteed the FB is already cleared
-                        layer->clearWithOpenGL(clip);
+                        layer->clearWithOpenGL(hw, clip);
                     }
                     continue;
                 }
                 // render the layer
-                layer->draw(clip);
+                layer->draw(hw, clip);
             }
         }
     }
 }
 
-void SurfaceFlinger::debugFlashRegions()
+void SurfaceFlinger::debugFlashRegions(const DisplayHardware& hw)
 {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     const uint32_t flags = hw.getFlags();
     const int32_t height = hw.getHeight();
     if (mSwapRegion.isEmpty()) {
@@ -1050,7 +1030,7 @@
     if (!(flags & DisplayHardware::SWAP_RECTANGLE)) {
         const Region repaint((flags & DisplayHardware::PARTIAL_UPDATES) ?
                 mDirtyRegion.bounds() : hw.bounds());
-        composeSurfaces(repaint);
+        composeSurfaces(hw, repaint);
     }
 
     glDisable(GL_TEXTURE_EXTERNAL_OES);
@@ -1460,7 +1440,7 @@
 
 void SurfaceFlinger::onScreenAcquired() {
     ALOGD("Screen about to return, flinger = %p", this);
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware()); // XXX: this should be per DisplayHardware
     hw.acquireScreen();
     mEventThread->onScreenAcquired();
     // this is a temporary work-around, eventually this should be called
@@ -1472,7 +1452,7 @@
 
 void SurfaceFlinger::onScreenReleased() {
     ALOGD("About to give-up screen, flinger = %p", this);
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware()); // XXX: this should be per DisplayHardware
     if (hw.isScreenAcquired()) {
         mEventThread->onScreenReleased();
         hw.releaseScreen();
@@ -1671,6 +1651,7 @@
     snprintf(buffer, SIZE, "SurfaceFlinger global state:\n");
     result.append(buffer);
 
+    const DisplayHardware& hw(getDefaultDisplayHardware());
     const GLExtensions& extensions(GLExtensions::getInstance());
     snprintf(buffer, SIZE, "GLES: %s, %s, %s\n",
             extensions.getVendor(),
@@ -1679,7 +1660,7 @@
     result.append(buffer);
 
     snprintf(buffer, SIZE, "EGL : %s\n",
-            eglQueryString(graphicPlane(0).getEGLDisplay(),
+            eglQueryString(hw.getEGLDisplay(),
                     EGL_VERSION_HW_ANDROID));
     result.append(buffer);
 
@@ -1687,7 +1668,6 @@
     result.append(buffer);
 
     mWormholeRegion.dump(result, "WormholeRegion");
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
     snprintf(buffer, SIZE,
             "  orientation=%d, canDraw=%d\n",
             mCurrentState.orientation, hw.canDraw());
@@ -1838,7 +1818,7 @@
                 return NO_ERROR;
             case 1013: {
                 Mutex::Autolock _l(mStateLock);
-                const DisplayHardware& hw(graphicPlane(0).displayHardware());
+                const DisplayHardware& hw(getDefaultDisplayHardware());
                 reply->writeInt32(hw.getPageFlipCount());
             }
             return NO_ERROR;
@@ -1848,7 +1828,7 @@
 }
 
 void SurfaceFlinger::repaintEverything() {
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware()); // FIXME: this cannot be bound the default display
     const Rect bounds(hw.getBounds());
     setInvalidateRegion(Region(bounds));
     signalTransaction();
@@ -1884,7 +1864,7 @@
         return INVALID_OPERATION;
 
     // get screen geometry
-    const DisplayHardware& hw(graphicPlane(dpy).displayHardware());
+    const DisplayHardware& hw(getDisplayHardware(dpy));
     const uint32_t hw_w = hw.getWidth();
     const uint32_t hw_h = hw.getHeight();
     GLfloat u = 1;
@@ -1926,7 +1906,7 @@
     const size_t count = layers.size();
     for (size_t i=0 ; i<count ; ++i) {
         const sp<LayerBase>& layer(layers[i]);
-        layer->drawForSreenShot();
+        layer->drawForSreenShot(hw);
     }
 
     hw.compositionComplete();
@@ -1975,7 +1955,7 @@
 status_t SurfaceFlinger::electronBeamOffAnimationImplLocked()
 {
     // get screen geometry
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware());
     const uint32_t hw_w = hw.getWidth();
     const uint32_t hw_h = hw.getHeight();
     const Region screenBounds(hw.getBounds());
@@ -2157,7 +2137,7 @@
 
 
     // get screen geometry
-    const DisplayHardware& hw(graphicPlane(0).displayHardware());
+    const DisplayHardware& hw(getDefaultDisplayHardware());
     const uint32_t hw_w = hw.getWidth();
     const uint32_t hw_h = hw.getHeight();
     const Region screenBounds(hw.bounds());
@@ -2306,7 +2286,7 @@
 {
     ATRACE_CALL();
 
-    DisplayHardware& hw(graphicPlane(0).editDisplayHardware());
+    DisplayHardware& hw(const_cast<DisplayHardware&>(getDefaultDisplayHardware()));
     if (!hw.canDraw()) {
         // we're already off
         return NO_ERROR;
@@ -2366,7 +2346,7 @@
 
 status_t SurfaceFlinger::turnElectronBeamOnImplLocked(int32_t mode)
 {
-    DisplayHardware& hw(graphicPlane(0).editDisplayHardware());
+    DisplayHardware& hw(const_cast<DisplayHardware&>(getDefaultDisplayHardware()));
     if (hw.canDraw()) {
         // we're already on
         return NO_ERROR;
@@ -2426,7 +2406,7 @@
         return INVALID_OPERATION;
 
     // get screen geometry
-    const DisplayHardware& hw(graphicPlane(dpy).displayHardware());
+    const DisplayHardware& hw(getDisplayHardware(dpy));
     const uint32_t hw_w = hw.getWidth();
     const uint32_t hw_h = hw.getHeight();
 
@@ -2478,7 +2458,7 @@
             if (!(flags & ISurfaceComposer::eLayerHidden)) {
                 const uint32_t z = layer->drawingState().z;
                 if (z >= minLayerZ && z <= maxLayerZ) {
-                    layer->drawForSreenShot();
+                    layer->drawForSreenShot(hw);
                 }
             }
         }
@@ -2626,126 +2606,4 @@
 
 // ---------------------------------------------------------------------------
 
-GraphicPlane::GraphicPlane()
-    : mHw(0)
-{
-}
-
-GraphicPlane::~GraphicPlane() {
-    delete mHw;
-}
-
-bool GraphicPlane::initialized() const {
-    return mHw ? true : false;
-}
-
-int GraphicPlane::getWidth() const {
-    return mWidth;
-}
-
-int GraphicPlane::getHeight() const {
-    return mHeight;
-}
-
-void GraphicPlane::setDisplayHardware(DisplayHardware *hw)
-{
-    mHw = hw;
-
-    // initialize the display orientation transform.
-    // it's a constant that should come from the display driver.
-    int displayOrientation = ISurfaceComposer::eOrientationDefault;
-    char property[PROPERTY_VALUE_MAX];
-    if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
-        //displayOrientation
-        switch (atoi(property)) {
-        case 90:
-            displayOrientation = ISurfaceComposer::eOrientation90;
-            break;
-        case 270:
-            displayOrientation = ISurfaceComposer::eOrientation270;
-            break;
-        }
-    }
-
-    const float w = hw->getWidth();
-    const float h = hw->getHeight();
-    GraphicPlane::orientationToTransfrom(displayOrientation, w, h,
-            &mDisplayTransform);
-    if (displayOrientation & ISurfaceComposer::eOrientationSwapMask) {
-        mDisplayWidth = h;
-        mDisplayHeight = w;
-    } else {
-        mDisplayWidth = w;
-        mDisplayHeight = h;
-    }
-
-    setOrientation(ISurfaceComposer::eOrientationDefault);
-}
-
-status_t GraphicPlane::orientationToTransfrom(
-        int orientation, int w, int h, Transform* tr)
-{
-    uint32_t flags = 0;
-    switch (orientation) {
-    case ISurfaceComposer::eOrientationDefault:
-        flags = Transform::ROT_0;
-        break;
-    case ISurfaceComposer::eOrientation90:
-        flags = Transform::ROT_90;
-        break;
-    case ISurfaceComposer::eOrientation180:
-        flags = Transform::ROT_180;
-        break;
-    case ISurfaceComposer::eOrientation270:
-        flags = Transform::ROT_270;
-        break;
-    default:
-        return BAD_VALUE;
-    }
-    tr->set(flags, w, h);
-    return NO_ERROR;
-}
-
-status_t GraphicPlane::setOrientation(int orientation)
-{
-    // If the rotation can be handled in hardware, this is where
-    // the magic should happen.
-
-    const DisplayHardware& hw(displayHardware());
-    const float w = mDisplayWidth;
-    const float h = mDisplayHeight;
-    mWidth = int(w);
-    mHeight = int(h);
-
-    Transform orientationTransform;
-    GraphicPlane::orientationToTransfrom(orientation, w, h,
-            &orientationTransform);
-    if (orientation & ISurfaceComposer::eOrientationSwapMask) {
-        mWidth = int(h);
-        mHeight = int(w);
-    }
-
-    mOrientation = orientation;
-    mGlobalTransform = mDisplayTransform * orientationTransform;
-    return NO_ERROR;
-}
-
-const DisplayHardware& GraphicPlane::displayHardware() const {
-    return *mHw;
-}
-
-DisplayHardware& GraphicPlane::editDisplayHardware() {
-    return *mHw;
-}
-
-const Transform& GraphicPlane::transform() const {
-    return mGlobalTransform;
-}
-
-EGLDisplay GraphicPlane::getEGLDisplay() const {
-    return mHw->getEGLDisplay();
-}
-
-// ---------------------------------------------------------------------------
-
 }; // namespace android
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 8256fef..3e27564 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -68,44 +68,6 @@
 
 // ---------------------------------------------------------------------------
 
-class GraphicPlane
-{
-public:
-    static status_t orientationToTransfrom(int orientation, int w, int h,
-            Transform* tr);
-
-                                GraphicPlane();
-                                ~GraphicPlane();
-
-        bool                    initialized() const;
-
-        void                    setDisplayHardware(DisplayHardware *);
-        status_t                setOrientation(int orientation);
-        int                     getOrientation() const { return mOrientation; }
-        int                     getWidth() const;
-        int                     getHeight() const;
-
-        const DisplayHardware&  displayHardware() const;
-        DisplayHardware&        editDisplayHardware();
-        const Transform&        transform() const;
-        EGLDisplay              getEGLDisplay() const;
-        
-private:
-                                GraphicPlane(const GraphicPlane&);
-        GraphicPlane            operator = (const GraphicPlane&);
-
-        DisplayHardware*        mHw;
-        Transform               mGlobalTransform;
-        Transform               mDisplayTransform;
-        int                     mOrientation;
-        float                   mDisplayWidth;
-        float                   mDisplayHeight;
-        int                     mWidth;
-        int                     mHeight;
-};
-
-// ---------------------------------------------------------------------------
-
 enum {
     eTransactionNeeded      = 0x01,
     eTraversalNeeded        = 0x02
@@ -260,8 +222,13 @@
     virtual void        onFirstRef();
 
 public:     // hack to work around gcc 4.0.3 bug
-    const GraphicPlane&     graphicPlane(int dpy) const;
-          GraphicPlane&     graphicPlane(int dpy);
+
+          const DisplayHardware& getDisplayHardware(DisplayID dpy) const {
+              return *mDisplayHardwares[dpy];
+          }
+          const DisplayHardware& getDefaultDisplayHardware() const {
+              return getDisplayHardware(0);
+          }
 
           void              signalTransaction();
           void              signalLayerUpdate();
@@ -282,11 +249,11 @@
             bool        lockPageFlip(const LayerVector& currentLayers);
             void        unlockPageFlip(const LayerVector& currentLayers);
             void        handleRefresh();
-            void        handleWorkList();
-            void        handleRepaint();
+            void        handleWorkList(const DisplayHardware& hw);
+            void        handleRepaint(const DisplayHardware& hw);
             void        postFramebuffer();
-            void        setupHardwareComposer();
-            void        composeSurfaces(const Region& dirty);
+            void        setupHardwareComposer(const DisplayHardware& hw);
+            void        composeSurfaces(const DisplayHardware& hw, const Region& dirty);
 
 
             void        setInvalidateRegion(const Region& reg);
@@ -315,7 +282,7 @@
             status_t electronBeamOffAnimationImplLocked();
             status_t electronBeamOnAnimationImplLocked();
 
-            void        debugFlashRegions();
+            void        debugFlashRegions(const DisplayHardware& hw);
             void        drawWormhole() const;
 
             void        startBootAnim();
@@ -340,7 +307,7 @@
                 Vector< sp<LayerBase> > mLayersPendingRemoval;
 
                 // protected by mStateLock (but we could use another lock)
-                GraphicPlane                mGraphicPlanes[1];
+                DisplayHardware*            mDisplayHardwares[1];
                 bool                        mLayersRemoved;
                 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayerMap;