OSDN Git Service

Add DisplaySurface abstraction
[android-x86/frameworks-native.git] / services / surfaceflinger / DisplayDevice.h
index 8122b9d..d8f55b4 100644 (file)
@@ -37,9 +37,10 @@ struct ANativeWindow;
 namespace android {
 
 class DisplayInfo;
-class FramebufferSurface;
-class LayerBase;
+class DisplaySurface;
+class Layer;
 class SurfaceFlinger;
+class HWComposer;
 
 class DisplayDevice : public LightRefBase<DisplayDevice>
 {
@@ -64,11 +65,16 @@ public:
         SWAP_RECTANGLE  = 0x00080000,
     };
 
+    enum {
+        NO_LAYER_STACK = 0xFFFFFFFF,
+    };
+
     DisplayDevice(
             const sp<SurfaceFlinger>& flinger,
-            DisplayType type, const wp<IBinder>& displayToken,
-            const sp<ANativeWindow>& nativeWindow,
-            const sp<FramebufferSurface>& framebufferSurface,
+            DisplayType type,
+            bool isSecure,
+            const wp<IBinder>& displayToken,
+            const sp<DisplaySurface>& displaySurface,
             EGLConfig config);
 
     ~DisplayDevice();
@@ -77,6 +83,10 @@ public:
     // when an non existing id is requested
     bool isValid() const;
 
+    // isSecure indicates whether this display can be trusted to display
+    // secure surfaces.
+    bool isSecure() const { return mIsSecure; }
+
     // Flip the front and back buffers if the back buffer is "dirty".  Might
     // be instantaneous, might involve copying the frame buffer around.
     void flip(const Region& dirty) const;
@@ -88,8 +98,8 @@ public:
 
     EGLSurface  getEGLSurface() const;
 
-    void                    setVisibleLayersSortedByZ(const Vector< sp<LayerBase> >& layers);
-    const Vector< sp<LayerBase> >& getVisibleLayersSortedByZ() const;
+    void                    setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
+    const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
     bool                    getSecureLayerVisible() const;
     Region                  getDirtyRegion(bool repaintEverything) const;
 
@@ -98,26 +108,37 @@ public:
 
     int                     getOrientation() const { return mOrientation; }
     const Transform&        getTransform() const { return mGlobalTransform; }
-    const Rect&             getViewport() const { return mViewport; }
-    const Rect&             getFrame() const { return mFrame; }
+    const Rect              getViewport() const { return mViewport; }
+    const Rect              getFrame() const { return mFrame; }
+    const Rect&             getScissor() const { return mScissor; }
+    bool                    needsFiltering() const { return mNeedsFiltering; }
 
     uint32_t                getLayerStack() const { return mLayerStack; }
     int32_t                 getDisplayType() const { return mType; }
     int32_t                 getHwcDisplayId() const { return mHwcDisplayId; }
     const wp<IBinder>&      getDisplayToken() const { return mDisplayToken; }
 
+    void swapBuffers(HWComposer& hwc) const;
     status_t compositionComplete() const;
-    
+
+    // called after h/w composer has completed its set() call
+    void onSwapBuffersCompleted(HWComposer& hwc) const;
+
     Rect getBounds() const {
         return Rect(mDisplayWidth, mDisplayHeight);
     }
     inline Rect bounds() const { return getBounds(); }
 
+    void setDisplayName(const String8& displayName);
+    const String8& getDisplayName() const { return mDisplayName; }
+
     static EGLBoolean makeCurrent(EGLDisplay dpy,
             const sp<const DisplayDevice>& hw, EGLContext ctx);
 
+    static void setViewportAndProjection(const sp<const DisplayDevice>& hw);
+
     /* ------------------------------------------------------------------------
-     * blank / unplank management
+     * blank / unblank management
      */
     void releaseScreen() const;
     void acquireScreen() const;
@@ -128,7 +149,7 @@ public:
      * Debugging
      */
     uint32_t getPageFlipCount() const;
-    void dump(String8& res) const;
+    void dump(String8& result, char* buffer, size_t SIZE) const;
 
 private:
     void init(EGLConfig config);
@@ -143,9 +164,7 @@ private:
 
     // ANativeWindow this display is rendering into
     sp<ANativeWindow> mNativeWindow;
-
-    // set if mNativeWindow is a FramebufferSurface
-    sp<FramebufferSurface> mFramebufferSurface;
+    sp<DisplaySurface> mDisplaySurface;
 
     EGLDisplay      mDisplay;
     EGLSurface      mSurface;
@@ -155,6 +174,8 @@ private:
     PixelFormat     mFormat;
     uint32_t        mFlags;
     mutable uint32_t mPageFlipCount;
+    String8         mDisplayName;
+    bool            mIsSecure;
 
     /*
      * Can only accessed from the main thread, these members
@@ -162,7 +183,7 @@ private:
      */
 
     // list of visible layers on that display
-    Vector< sp<LayerBase> > mVisibleLayersSortedByZ;
+    Vector< sp<Layer> > mVisibleLayersSortedByZ;
 
     // Whether we have a visible secure layer on this display
     bool mSecureLayerVisible;
@@ -177,13 +198,16 @@ private:
     static status_t orientationToTransfrom(int orientation,
             int w, int h, Transform* tr);
 
-    void updateGeometryTransform();
-
     uint32_t mLayerStack;
     int mOrientation;
+    // user-provided visible area of the layer stack
     Rect mViewport;
+    // user-provided rectangle where mViewport gets mapped to
     Rect mFrame;
+    // pre-computed scissor to apply to the display
+    Rect mScissor;
     Transform mGlobalTransform;
+    bool mNeedsFiltering;
 };
 
 }; // namespace android