LayerState.h revision 2c5f6d2257075c8b5ced78b07ed8b2c2323f0df2
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_SF_LAYER_STATE_H 18#define ANDROID_SF_LAYER_STATE_H 19 20#include <stdint.h> 21#include <sys/types.h> 22 23#include <utils/Errors.h> 24 25#include <ui/Region.h> 26#include <ui/Rect.h> 27#include <gui/IGraphicBufferProducer.h> 28#include <math/vec3.h> 29 30namespace android { 31 32class Parcel; 33class ISurfaceComposerClient; 34 35/* 36 * Used to communicate layer information between SurfaceFlinger and its clients. 37 */ 38struct layer_state_t { 39 40 41 enum { 42 eLayerHidden = 0x01, // SURFACE_HIDDEN in SurfaceControl.java 43 eLayerOpaque = 0x02, // SURFACE_OPAQUE 44 eLayerSecure = 0x80, // SECURE 45 }; 46 47 enum { 48 ePositionChanged = 0x00000001, 49 eLayerChanged = 0x00000002, 50 eSizeChanged = 0x00000004, 51 eAlphaChanged = 0x00000008, 52 eMatrixChanged = 0x00000010, 53 eTransparentRegionChanged = 0x00000020, 54 eFlagsChanged = 0x00000040, 55 eLayerStackChanged = 0x00000080, 56 eCropChanged = 0x00000100, 57 eDeferTransaction = 0x00000200, 58 eFinalCropChanged = 0x00000400, 59 eOverrideScalingModeChanged = 0x00000800, 60 eGeometryAppliesWithResize = 0x00001000, 61 eReparentChildren = 0x00002000, 62 eDetachChildren = 0x00004000, 63 eRelativeLayerChanged = 0x00008000, 64 eReparent = 0x00010000, 65 eColorChanged = 0x00020000 66 }; 67 68 layer_state_t() 69 : what(0), 70 x(0), y(0), z(0), w(0), h(0), layerStack(0), 71 alpha(0), flags(0), mask(0), 72 reserved(0), crop(Rect::INVALID_RECT), 73 finalCrop(Rect::INVALID_RECT), frameNumber(0), 74 overrideScalingMode(-1) 75 { 76 matrix.dsdx = matrix.dtdy = 1.0f; 77 matrix.dsdy = matrix.dtdx = 0.0f; 78 } 79 80 void merge(const layer_state_t& other); 81 status_t write(Parcel& output) const; 82 status_t read(const Parcel& input); 83 84 struct matrix22_t { 85 float dsdx{0}; 86 float dtdx{0}; 87 float dtdy{0}; 88 float dsdy{0}; 89 }; 90 sp<IBinder> surface; 91 uint32_t what; 92 float x; 93 float y; 94 int32_t z; 95 uint32_t w; 96 uint32_t h; 97 uint32_t layerStack; 98 float alpha; 99 uint8_t flags; 100 uint8_t mask; 101 uint8_t reserved; 102 matrix22_t matrix; 103 Rect crop; 104 Rect finalCrop; 105 sp<IBinder> barrierHandle; 106 sp<IBinder> reparentHandle; 107 uint64_t frameNumber; 108 int32_t overrideScalingMode; 109 110 sp<IGraphicBufferProducer> barrierGbp; 111 112 sp<IBinder> relativeLayerHandle; 113 114 sp<IBinder> parentHandleForChild; 115 116 half3 color; 117 118 // non POD must be last. see write/read 119 Region transparentRegion; 120}; 121 122struct ComposerState { 123 sp<ISurfaceComposerClient> client; 124 layer_state_t state; 125 status_t write(Parcel& output) const; 126 status_t read(const Parcel& input); 127}; 128 129struct DisplayState { 130 131 enum { 132 eOrientationDefault = 0, 133 eOrientation90 = 1, 134 eOrientation180 = 2, 135 eOrientation270 = 3, 136 eOrientationUnchanged = 4, 137 eOrientationSwapMask = 0x01 138 }; 139 140 enum { 141 eSurfaceChanged = 0x01, 142 eLayerStackChanged = 0x02, 143 eDisplayProjectionChanged = 0x04, 144 eDisplaySizeChanged = 0x08 145 }; 146 147 DisplayState(); 148 void merge(const DisplayState& other); 149 150 uint32_t what; 151 sp<IBinder> token; 152 sp<IGraphicBufferProducer> surface; 153 uint32_t layerStack; 154 uint32_t orientation; 155 Rect viewport; 156 Rect frame; 157 uint32_t width, height; 158 status_t write(Parcel& output) const; 159 status_t read(const Parcel& input); 160}; 161 162static inline 163int compare_type(const ComposerState& lhs, const ComposerState& rhs) { 164 if (lhs.client < rhs.client) return -1; 165 if (lhs.client > rhs.client) return 1; 166 if (lhs.state.surface < rhs.state.surface) return -1; 167 if (lhs.state.surface > rhs.state.surface) return 1; 168 return 0; 169} 170 171static inline 172int compare_type(const DisplayState& lhs, const DisplayState& rhs) { 173 return compare_type(lhs.token, rhs.token); 174} 175 176}; // namespace android 177 178#endif // ANDROID_SF_LAYER_STATE_H 179 180