The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_SF_SURFACE_H |
| 18 | #define ANDROID_SF_SURFACE_H |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Jamie Gennis | 5ee65f0 | 2010-07-15 17:29:15 -0700 | [diff] [blame] | 23 | #include <utils/KeyedVector.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | #include <utils/RefBase.h> |
| 25 | #include <utils/threads.h> |
| 26 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | #include <ui/PixelFormat.h> |
| 28 | #include <ui/Region.h> |
Mathias Agopian | ac2523b | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 29 | #include <ui/egl/android_natives.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 30 | |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 31 | #include <surfaceflinger/ISurface.h> |
Mathias Agopian | 770492c | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 32 | #include <surfaceflinger/ISurfaceComposerClient.h> |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 33 | |
Mathias Agopian | 8b13832 | 2010-04-12 16:22:15 -0700 | [diff] [blame] | 34 | #define ANDROID_VIEW_SURFACE_JNI_ID "mNativeSurface" |
| 35 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | namespace android { |
| 37 | |
| 38 | // --------------------------------------------------------------------------- |
| 39 | |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 40 | class GraphicBuffer; |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 41 | class GraphicBufferMapper; |
Andreas Huber | ccf8b94 | 2009-08-07 12:01:29 -0700 | [diff] [blame] | 42 | class IOMX; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | class Rect; |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 44 | class Surface; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | class SurfaceComposerClient; |
Mathias Agopian | 9779b22 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 46 | class SharedClient; |
| 47 | class SharedBufferClient; |
Mathias Agopian | c7b388c | 2010-05-27 19:41:15 -0700 | [diff] [blame] | 48 | class SurfaceClient; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 50 | // --------------------------------------------------------------------------- |
| 51 | |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 52 | class SurfaceControl : public RefBase |
| 53 | { |
| 54 | public: |
| 55 | static bool isValid(const sp<SurfaceControl>& surface) { |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 56 | return (surface != 0) && surface->isValid(); |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 57 | } |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 58 | bool isValid() { |
| 59 | return mToken>=0 && mClient!=0; |
| 60 | } |
| 61 | static bool isSameSurface( |
| 62 | const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs); |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 63 | |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 64 | uint32_t getFlags() const { return mFlags; } |
| 65 | uint32_t getIdentity() const { return mIdentity; } |
| 66 | |
| 67 | // release surface data from java |
| 68 | void clear(); |
| 69 | |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 70 | status_t setLayer(int32_t layer); |
| 71 | status_t setPosition(int32_t x, int32_t y); |
| 72 | status_t setSize(uint32_t w, uint32_t h); |
| 73 | status_t hide(); |
| 74 | status_t show(int32_t layer = -1); |
| 75 | status_t freeze(); |
| 76 | status_t unfreeze(); |
| 77 | status_t setFlags(uint32_t flags, uint32_t mask); |
| 78 | status_t setTransparentRegionHint(const Region& transparent); |
| 79 | status_t setAlpha(float alpha=1.0f); |
| 80 | status_t setMatrix(float dsdx, float dtdx, float dsdy, float dtdy); |
| 81 | status_t setFreezeTint(uint32_t tint); |
| 82 | |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 83 | static status_t writeSurfaceToParcel( |
| 84 | const sp<SurfaceControl>& control, Parcel* parcel); |
| 85 | |
| 86 | sp<Surface> getSurface() const; |
| 87 | |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 88 | private: |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 89 | // can't be copied |
| 90 | SurfaceControl& operator = (SurfaceControl& rhs); |
| 91 | SurfaceControl(const SurfaceControl& rhs); |
| 92 | |
| 93 | |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 94 | friend class SurfaceComposerClient; |
| 95 | |
| 96 | // camera and camcorder need access to the ISurface binder interface for preview |
Jamie Gennis | 85cfdd0 | 2010-08-10 16:37:53 -0700 | [diff] [blame] | 97 | friend class CameraService; |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 98 | friend class MediaRecorder; |
| 99 | // mediaplayer needs access to ISurface for display |
| 100 | friend class MediaPlayer; |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 101 | // for testing |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 102 | friend class Test; |
| 103 | const sp<ISurface>& getISurface() const { return mSurface; } |
| 104 | |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 105 | |
| 106 | friend class Surface; |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 107 | |
| 108 | SurfaceControl( |
| 109 | const sp<SurfaceComposerClient>& client, |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 110 | const sp<ISurface>& surface, |
Mathias Agopian | 770492c | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 111 | const ISurfaceComposerClient::surface_data_t& data, |
Mathias Agopian | 69d6209 | 2009-04-16 20:30:22 -0700 | [diff] [blame] | 112 | uint32_t w, uint32_t h, PixelFormat format, uint32_t flags); |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 113 | |
| 114 | ~SurfaceControl(); |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 115 | |
Mathias Agopian | 18e0260 | 2009-11-13 15:26:29 -0800 | [diff] [blame] | 116 | status_t validate() const; |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 117 | void destroy(); |
| 118 | |
| 119 | sp<SurfaceComposerClient> mClient; |
| 120 | sp<ISurface> mSurface; |
| 121 | SurfaceID mToken; |
| 122 | uint32_t mIdentity; |
Mathias Agopian | 5b5c914 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 123 | uint32_t mWidth; |
| 124 | uint32_t mHeight; |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 125 | PixelFormat mFormat; |
| 126 | uint32_t mFlags; |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 127 | mutable Mutex mLock; |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 128 | |
| 129 | mutable sp<Surface> mSurfaceData; |
Mathias Agopian | 6d2c0bc | 2009-04-16 16:19:50 -0700 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | // --------------------------------------------------------------------------- |
| 133 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 134 | class Surface |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 135 | : public EGLNativeBase<ANativeWindow, Surface, RefBase> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 136 | { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | public: |
| 138 | struct SurfaceInfo { |
| 139 | uint32_t w; |
| 140 | uint32_t h; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 141 | uint32_t s; |
| 142 | uint32_t usage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 143 | PixelFormat format; |
| 144 | void* bits; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 145 | uint32_t reserved[2]; |
| 146 | }; |
| 147 | |
Mathias Agopian | 5e14010 | 2010-06-08 19:54:15 -0700 | [diff] [blame] | 148 | static status_t writeToParcel( |
| 149 | const sp<Surface>& control, Parcel* parcel); |
| 150 | |
Jamie Gennis | 5ee65f0 | 2010-07-15 17:29:15 -0700 | [diff] [blame] | 151 | static sp<Surface> readFromParcel(const Parcel& data); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 152 | |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 153 | static bool isValid(const sp<Surface>& surface) { |
| 154 | return (surface != 0) && surface->isValid(); |
| 155 | } |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 156 | |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 157 | bool isValid(); |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 158 | uint32_t getFlags() const { return mFlags; } |
Mathias Agopian | 17f638b | 2009-04-16 20:04:08 -0700 | [diff] [blame] | 159 | uint32_t getIdentity() const { return mIdentity; } |
| 160 | |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 161 | // the lock/unlock APIs must be used from the same thread |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | status_t lock(SurfaceInfo* info, bool blocking = true); |
| 163 | status_t lock(SurfaceInfo* info, Region* dirty, bool blocking = true); |
| 164 | status_t unlockAndPost(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 165 | |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 166 | // setSwapRectangle() is intended to be used by GL ES clients |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 167 | void setSwapRectangle(const Rect& r); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 168 | |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 169 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | private: |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 171 | /* |
| 172 | * Android frameworks friends |
| 173 | * (eventually this should go away and be replaced by proper APIs) |
| 174 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | // camera and camcorder need access to the ISurface binder interface for preview |
Jamie Gennis | 85cfdd0 | 2010-08-10 16:37:53 -0700 | [diff] [blame] | 176 | friend class CameraService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | friend class MediaRecorder; |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 178 | // MediaPlayer needs access to ISurface for display |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | friend class MediaPlayer; |
Andreas Huber | ccf8b94 | 2009-08-07 12:01:29 -0700 | [diff] [blame] | 180 | friend class IOMX; |
Andreas Huber | e3c0183 | 2010-08-16 08:49:37 -0700 | [diff] [blame] | 181 | friend class SoftwareRenderer; |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 182 | // this is just to be able to write some unit tests |
| 183 | friend class Test; |
| 184 | |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 185 | private: |
| 186 | friend class SurfaceComposerClient; |
| 187 | friend class SurfaceControl; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 188 | |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 189 | // can't be copied |
| 190 | Surface& operator = (Surface& rhs); |
| 191 | Surface(const Surface& rhs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 193 | Surface(const sp<SurfaceControl>& control); |
Mathias Agopian | fae5cb2 | 2010-06-04 18:26:32 -0700 | [diff] [blame] | 194 | Surface(const Parcel& data, const sp<IBinder>& ref); |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 195 | ~Surface(); |
| 196 | |
| 197 | |
| 198 | /* |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 199 | * ANativeWindow hooks |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 200 | */ |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 201 | static int setSwapInterval(ANativeWindow* window, int interval); |
| 202 | static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer); |
| 203 | static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer); |
| 204 | static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer); |
| 205 | static int query(ANativeWindow* window, int what, int* value); |
| 206 | static int perform(ANativeWindow* window, int operation, ...); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 207 | |
| 208 | int dequeueBuffer(android_native_buffer_t** buffer); |
| 209 | int lockBuffer(android_native_buffer_t* buffer); |
| 210 | int queueBuffer(android_native_buffer_t* buffer); |
Mathias Agopian | 5b5c914 | 2009-07-30 18:14:56 -0700 | [diff] [blame] | 211 | int query(int what, int* value); |
Mathias Agopian | 5cec474 | 2009-08-11 22:34:02 -0700 | [diff] [blame] | 212 | int perform(int operation, va_list args); |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 213 | |
Mathias Agopian | 2f7540e | 2010-03-11 15:06:54 -0800 | [diff] [blame] | 214 | void dispatch_setUsage(va_list args); |
| 215 | int dispatch_connect(va_list args); |
| 216 | int dispatch_disconnect(va_list args); |
Mathias Agopian | 16a86ee | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 217 | int dispatch_crop(va_list args); |
Mathias Agopian | 25f0bda | 2010-05-21 14:19:50 -0700 | [diff] [blame] | 218 | int dispatch_set_buffer_count(va_list args); |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 219 | int dispatch_set_buffers_geometry(va_list args); |
Mathias Agopian | e96aa3e | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 220 | int dispatch_set_buffers_transform(va_list args); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 221 | |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 222 | void setUsage(uint32_t reqUsage); |
Mathias Agopian | 2f7540e | 2010-03-11 15:06:54 -0800 | [diff] [blame] | 223 | int connect(int api); |
| 224 | int disconnect(int api); |
Mathias Agopian | 16a86ee | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 225 | int crop(Rect const* rect); |
Mathias Agopian | 59751db | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 226 | int setBufferCount(int bufferCount); |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 227 | int setBuffersGeometry(int w, int h, int format); |
Mathias Agopian | e96aa3e | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 228 | int setBuffersTransform(int transform); |
Mathias Agopian | 2f7540e | 2010-03-11 15:06:54 -0800 | [diff] [blame] | 229 | |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 230 | /* |
| 231 | * private stuff... |
| 232 | */ |
| 233 | void init(); |
| 234 | status_t validate() const; |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 235 | sp<ISurface> getISurface() const; |
| 236 | |
| 237 | inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; } |
| 238 | inline GraphicBufferMapper& getBufferMapper() { return mBufferMapper; } |
| 239 | |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 240 | status_t getBufferLocked(int index, |
| 241 | uint32_t w, uint32_t h, uint32_t format, uint32_t usage); |
Mathias Agopian | f590f70 | 2010-04-27 16:41:19 -0700 | [diff] [blame] | 242 | int getBufferIndex(const sp<GraphicBuffer>& buffer) const; |
| 243 | |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 244 | int getConnectedApi() const; |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 245 | |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 246 | bool needNewBuffer(int bufIdx, |
| 247 | uint32_t *pWidth, uint32_t *pHeight, |
| 248 | uint32_t *pFormat, uint32_t *pUsage) const; |
| 249 | |
Jamie Gennis | 5ee65f0 | 2010-07-15 17:29:15 -0700 | [diff] [blame] | 250 | static void cleanCachedSurfaces(); |
| 251 | |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 252 | class BufferInfo { |
| 253 | uint32_t mWidth; |
| 254 | uint32_t mHeight; |
| 255 | uint32_t mFormat; |
| 256 | uint32_t mUsage; |
| 257 | mutable uint32_t mDirty; |
| 258 | enum { |
| 259 | GEOMETRY = 0x01 |
| 260 | }; |
| 261 | public: |
| 262 | BufferInfo(); |
| 263 | void set(uint32_t w, uint32_t h, uint32_t format); |
| 264 | void set(uint32_t usage); |
| 265 | void get(uint32_t *pWidth, uint32_t *pHeight, |
| 266 | uint32_t *pFormat, uint32_t *pUsage) const; |
| 267 | bool validateBuffer(const sp<GraphicBuffer>& buffer) const; |
| 268 | }; |
| 269 | |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 270 | // constants |
Mathias Agopian | 7623da4 | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 271 | GraphicBufferMapper& mBufferMapper; |
| 272 | SurfaceClient& mClient; |
| 273 | SharedBufferClient* mSharedBufferClient; |
| 274 | status_t mInitCheck; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 275 | sp<ISurface> mSurface; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | uint32_t mIdentity; |
| 277 | PixelFormat mFormat; |
| 278 | uint32_t mFlags; |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 279 | |
| 280 | // protected by mSurfaceLock |
| 281 | Rect mSwapRectangle; |
Mathias Agopian | 2f7540e | 2010-03-11 15:06:54 -0800 | [diff] [blame] | 282 | int mConnected; |
Mathias Agopian | 16a86ee | 2010-04-15 18:48:26 -0700 | [diff] [blame] | 283 | Rect mNextBufferCrop; |
Mathias Agopian | e96aa3e | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 284 | uint32_t mNextBufferTransform; |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 285 | BufferInfo mBufferInfo; |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 286 | |
| 287 | // protected by mSurfaceLock. These are also used from lock/unlock |
| 288 | // but in that case, they must be called form the same thread. |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 289 | mutable Region mDirtyRegion; |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 290 | |
| 291 | // must be used from the lock/unlock thread |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 292 | sp<GraphicBuffer> mLockedBuffer; |
| 293 | sp<GraphicBuffer> mPostedBuffer; |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 294 | mutable Region mOldDirtyRegion; |
Mathias Agopian | a8a0aa8 | 2010-04-21 15:24:11 -0700 | [diff] [blame] | 295 | bool mReserved; |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 296 | |
Mathias Agopian | 2be352a | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 297 | // only used from dequeueBuffer() |
| 298 | Vector< sp<GraphicBuffer> > mBuffers; |
| 299 | |
Mathias Agopian | 321abdb | 2009-08-14 18:52:17 -0700 | [diff] [blame] | 300 | // query() must be called from dequeueBuffer() thread |
| 301 | uint32_t mWidth; |
| 302 | uint32_t mHeight; |
| 303 | |
| 304 | // Inherently thread-safe |
| 305 | mutable Mutex mSurfaceLock; |
Mathias Agopian | 9779b22 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 306 | mutable Mutex mApiLock; |
Jamie Gennis | 5ee65f0 | 2010-07-15 17:29:15 -0700 | [diff] [blame] | 307 | |
| 308 | // A cache of Surface objects that have been deserialized into this process. |
| 309 | static Mutex sCachedSurfacesLock; |
| 310 | static DefaultKeyedVector<wp<IBinder>, wp<Surface> > sCachedSurfaces; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 311 | }; |
| 312 | |
| 313 | }; // namespace android |
| 314 | |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 315 | #endif // ANDROID_SF_SURFACE_H |