1edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/*
2edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
3edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
4edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * you may not use this file except in compliance with the License.
6edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * You may obtain a copy of the License at
7edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
8edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
10edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * See the License for the specific language governing permissions and
14edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * limitations under the License.
15edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project */
16edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
179cce325fae8adcf7560a28eef394489f09bad74dMathias Agopian#ifndef ANDROID_SF_LAYER_STATE_H
189cce325fae8adcf7560a28eef394489f09bad74dMathias Agopian#define ANDROID_SF_LAYER_STATE_H
19edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
20edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <stdint.h>
21edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <sys/types.h>
22edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
23edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <utils/Errors.h>
24edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
25edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <ui/Region.h>
26f15a83f5814219c167f87cb8aaea622fc8493499Jamie Gennis#include <ui/Rect.h>
279cce325fae8adcf7560a28eef394489f09bad74dMathias Agopian
28edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectnamespace android {
29edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
30edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectclass Parcel;
31698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopianclass ISurfaceComposerClient;
32edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
334125a4ffaf374ca9c0773f256998557d3325343eAndy McFadden/*
344125a4ffaf374ca9c0773f256998557d3325343eAndy McFadden * Used to communicate layer information between SurfaceFlinger and its clients.
354125a4ffaf374ca9c0773f256998557d3325343eAndy McFadden */
36edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectstruct layer_state_t {
37edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
383165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian
393165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian    enum {
404125a4ffaf374ca9c0773f256998557d3325343eAndy McFadden        eLayerHidden        = 0x01,     // SURFACE_HIDDEN in SurfaceControl.java
414125a4ffaf374ca9c0773f256998557d3325343eAndy McFadden        eLayerOpaque        = 0x02,     // SURFACE_OPAQUE
423165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian    };
433165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian
443165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian    enum {
453165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        ePositionChanged            = 0x00000001,
463165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eLayerChanged               = 0x00000002,
473165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eSizeChanged                = 0x00000004,
483165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eAlphaChanged               = 0x00000008,
493165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eMatrixChanged              = 0x00000010,
503165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eTransparentRegionChanged   = 0x00000020,
513165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eVisibilityChanged          = 0x00000040,
523165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eLayerStackChanged          = 0x00000080,
533165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eCropChanged                = 0x00000100,
544125a4ffaf374ca9c0773f256998557d3325343eAndy McFadden        eOpacityChanged             = 0x00000200,
553165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian    };
563165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian
57edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    layer_state_t()
58ac9fa427d4a86745e60a5f7fd8e3ea340c4db907Mathias Agopian        :   what(0),
598785578391eacd4192333d7b0ce3afedd7d163e6Mathias Agopian            x(0), y(0), z(0), w(0), h(0), layerStack(0),
606501e9944df131b3b7e293007084735dfa217f24Jeff Brown            alpha(0), flags(0), mask(0),
61edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            reserved(0)
62edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    {
63edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project        matrix.dsdx = matrix.dtdy = 1.0f;
64edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project        matrix.dsdy = matrix.dtdx = 0.0f;
65f15a83f5814219c167f87cb8aaea622fc8493499Jamie Gennis        crop.makeInvalid();
66edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    }
67edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
68edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    status_t    write(Parcel& output) const;
69edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    status_t    read(const Parcel& input);
70edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
71edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            struct matrix22_t {
72edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                float   dsdx;
73edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                float   dtdx;
74edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                float   dsdy;
75edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                float   dtdy;
76edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            };
77ac9fa427d4a86745e60a5f7fd8e3ea340c4db907Mathias Agopian            sp<IBinder>     surface;
78edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            uint32_t        what;
7941b6aabf356d8a505da37b1d046bc9010028fe8bMathias Agopian            float           x;
8041b6aabf356d8a505da37b1d046bc9010028fe8bMathias Agopian            float           y;
81edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            uint32_t        z;
82edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            uint32_t        w;
83edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            uint32_t        h;
848785578391eacd4192333d7b0ce3afedd7d163e6Mathias Agopian            uint32_t        layerStack;
85edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            float           alpha;
86edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            uint8_t         flags;
87edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            uint8_t         mask;
88edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            uint8_t         reserved;
89edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            matrix22_t      matrix;
90f15a83f5814219c167f87cb8aaea622fc8493499Jamie Gennis            Rect            crop;
91edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            // non POD must be last. see write/read
92edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            Region          transparentRegion;
93edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
94edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
95698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopianstruct ComposerState {
96698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopian    sp<ISurfaceComposerClient> client;
97698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopian    layer_state_t state;
98698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopian    status_t    write(Parcel& output) const;
99698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopian    status_t    read(const Parcel& input);
100698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopian};
101698c0873cf2e07bdc7fd1e72169aee2a19fa40d7Mathias Agopian
1028b33f032327f8de0dcc0e6d0d43ed80f834b51f6Mathias Agopianstruct DisplayState {
1033165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian
1043165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian    enum {
1053165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eOrientationDefault     = 0,
1063165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eOrientation90          = 1,
1073165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eOrientation180         = 2,
1083165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eOrientation270         = 3,
1093165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eOrientationUnchanged   = 4,
1103165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian        eOrientationSwapMask    = 0x01
1113165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian    };
1123165cc21cfea781988407b19bd83292b19f05f55Mathias Agopian
113e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    enum {
11400e8c7a88a5b9c4104a71013a713acd3e4d3b77bMathias Agopian        eSurfaceChanged             = 0x01,
11500e8c7a88a5b9c4104a71013a713acd3e4d3b77bMathias Agopian        eLayerStackChanged          = 0x02,
1161f6078aef71b1d3f080cd565adbec350c71088ddMichael Wright        eDisplayProjectionChanged   = 0x04,
1171f6078aef71b1d3f080cd565adbec350c71088ddMichael Wright        eDisplaySizeChanged         = 0x08
118e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    };
119e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian
120e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    uint32_t what;
121e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    sp<IBinder> token;
1222adaf04fab35cf47c824d74d901b54094e01ccd3Andy McFadden    sp<IGraphicBufferProducer> surface;
123e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    uint32_t layerStack;
124e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    uint32_t orientation;
125e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    Rect viewport;
126e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    Rect frame;
1271f6078aef71b1d3f080cd565adbec350c71088ddMichael Wright    uint32_t width, height;
128e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    status_t write(Parcel& output) const;
129e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    status_t read(const Parcel& input);
1308b33f032327f8de0dcc0e6d0d43ed80f834b51f6Mathias Agopian};
1318b33f032327f8de0dcc0e6d0d43ed80f834b51f6Mathias Agopian
132edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project}; // namespace android
133edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
1349cce325fae8adcf7560a28eef394489f09bad74dMathias Agopian#endif // ANDROID_SF_LAYER_STATE_H
135edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
136