LayerState.h 中定义了结构体 layer_state_t,它是客户端和 SurfaceFlinger 交互时传递的数据。还有结构体 ComposerState 封装了 layer_state_t,同时定义了 write()read() 函数。

struct layer_state_t {
   enum Permission {
       ACCESS_SURFACE_FLINGER = 0x1,
       ROTATE_SURFACE_FLINGER = 0x2,
       INTERNAL_SYSTEM_WINDOW = 0x4,
   };
    enum {
        eLayerHidden = 0x01,// SURFACE_HIDDEN in SurfaceControl.java
        eLayerOpaque = 0x02,// SURFACE_OPAQUE
        eLayerSkipScreenshot = 0x40,// SKIP_SCREENSHOT
        eLayerSecure = 0x80,// SECURE// Queue up BufferStateLayer buffers instead of dropping the oldest buffer when this flag is// set. This blocks the client until all the buffers have been presented. If the buffers// have presentation timestamps, then we may drop buffers.
        eEnableBackpressure = 0x100,// ENABLE_BACKPRESSURE
    };
    enum {
        ePositionChanged = 0x00000001,
        eLayerChanged = 0x00000002,
        eSizeChanged = 0x00000004,
        eAlphaChanged = 0x00000008,
        ...
        eFlagsChanged = 0x00000040,
        eLayerStackChanged = 0x00000080,
        ...
    };

    void merge(const layer_state_t& other);
    status_t write(Parcel& output) const;
    status_t read(const Parcel& input);
    void sanitize(int32_t permissions);
    sp<IBinder> surface;
    int32_t layerId;