blob: 3c7a4d2f343184794086b33b47907c4acdf2d51c [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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
17#define LOG_TAG "Surface"
18
19#include <stdint.h>
20#include <unistd.h>
21#include <fcntl.h>
22#include <errno.h>
23#include <sys/types.h>
24#include <sys/stat.h>
25
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026#include <utils/Errors.h>
27#include <utils/threads.h>
Mathias Agopiancbb288b2009-09-07 16:32:45 -070028#include <utils/CallStack.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080029#include <utils/Log.h>
30
31#include <pixelflinger/pixelflinger.h>
32
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070033#include <binder/IPCThreadState.h>
34#include <binder/IMemory.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035
Mathias Agopian076b1cc2009-04-10 14:24:30 -070036#include <ui/DisplayInfo.h>
Mathias Agopian3330b202009-10-05 17:07:12 -070037#include <ui/GraphicBuffer.h>
38#include <ui/GraphicBufferMapper.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039#include <ui/Rect.h>
40
Mathias Agopian9cce3252010-02-09 17:46:37 -080041#include <surfaceflinger/Surface.h>
42#include <surfaceflinger/ISurface.h>
43#include <surfaceflinger/ISurfaceComposer.h>
44#include <surfaceflinger/SurfaceComposerClient.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070045
Mathias Agopian9cce3252010-02-09 17:46:37 -080046#include <private/surfaceflinger/SharedBufferStack.h>
47#include <private/surfaceflinger/LayerState.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070048
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049namespace android {
50
Mathias Agopian076b1cc2009-04-10 14:24:30 -070051// ----------------------------------------------------------------------
52
Mathias Agopian14998592009-07-13 18:29:59 -070053static status_t copyBlt(
Mathias Agopian3330b202009-10-05 17:07:12 -070054 const sp<GraphicBuffer>& dst,
55 const sp<GraphicBuffer>& src,
Mathias Agopian0926f502009-05-04 14:17:04 -070056 const Region& reg)
Mathias Agopian076b1cc2009-04-10 14:24:30 -070057{
Mathias Agopian14998592009-07-13 18:29:59 -070058 status_t err;
59 uint8_t const * src_bits = NULL;
60 err = src->lock(GRALLOC_USAGE_SW_READ_OFTEN, reg.bounds(), (void**)&src_bits);
61 LOGE_IF(err, "error locking src buffer %s", strerror(-err));
Mathias Agopian0926f502009-05-04 14:17:04 -070062
Mathias Agopian14998592009-07-13 18:29:59 -070063 uint8_t* dst_bits = NULL;
64 err = dst->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, reg.bounds(), (void**)&dst_bits);
65 LOGE_IF(err, "error locking dst buffer %s", strerror(-err));
66
67 Region::const_iterator head(reg.begin());
68 Region::const_iterator tail(reg.end());
69 if (head != tail && src_bits && dst_bits) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -070070 // NOTE: dst and src must be the same format
Mathias Agopian076b1cc2009-04-10 14:24:30 -070071 const size_t bpp = bytesPerPixel(src->format);
72 const size_t dbpr = dst->stride * bpp;
73 const size_t sbpr = src->stride * bpp;
Mathias Agopian0926f502009-05-04 14:17:04 -070074
Mathias Agopian14998592009-07-13 18:29:59 -070075 while (head != tail) {
76 const Rect& r(*head++);
Mathias Agopian0926f502009-05-04 14:17:04 -070077 ssize_t h = r.height();
78 if (h <= 0) continue;
79 size_t size = r.width() * bpp;
80 uint8_t const * s = src_bits + (r.left + src->stride * r.top) * bpp;
81 uint8_t * d = dst_bits + (r.left + dst->stride * r.top) * bpp;
82 if (dbpr==sbpr && size==sbpr) {
83 size *= h;
84 h = 1;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070085 }
Mathias Agopian0926f502009-05-04 14:17:04 -070086 do {
87 memcpy(d, s, size);
88 d += dbpr;
89 s += sbpr;
90 } while (--h > 0);
Mathias Agopian076b1cc2009-04-10 14:24:30 -070091 }
92 }
Mathias Agopian0926f502009-05-04 14:17:04 -070093
Mathias Agopian14998592009-07-13 18:29:59 -070094 if (src_bits)
95 src->unlock();
96
97 if (dst_bits)
98 dst->unlock();
99
100 return err;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700101}
102
Mathias Agopian62185b72009-04-16 16:19:50 -0700103// ============================================================================
104// SurfaceControl
105// ============================================================================
106
Mathias Agopian01b76682009-04-16 20:04:08 -0700107SurfaceControl::SurfaceControl(
108 const sp<SurfaceComposerClient>& client,
Mathias Agopian62185b72009-04-16 16:19:50 -0700109 const sp<ISurface>& surface,
110 const ISurfaceFlingerClient::surface_data_t& data,
Mathias Agopian18d84462009-04-16 20:30:22 -0700111 uint32_t w, uint32_t h, PixelFormat format, uint32_t flags)
Mathias Agopian62185b72009-04-16 16:19:50 -0700112 : mClient(client), mSurface(surface),
113 mToken(data.token), mIdentity(data.identity),
Mathias Agopian1c97d2e2009-08-19 17:46:26 -0700114 mWidth(data.width), mHeight(data.height), mFormat(data.format),
115 mFlags(flags)
Mathias Agopian62185b72009-04-16 16:19:50 -0700116{
117}
Mathias Agopian18d84462009-04-16 20:30:22 -0700118
Mathias Agopian62185b72009-04-16 16:19:50 -0700119SurfaceControl::~SurfaceControl()
120{
121 destroy();
122}
123
124void SurfaceControl::destroy()
125{
Mathias Agopian18d84462009-04-16 20:30:22 -0700126 if (isValid()) {
Mathias Agopian62185b72009-04-16 16:19:50 -0700127 mClient->destroySurface(mToken);
128 }
129
130 // clear all references and trigger an IPC now, to make sure things
131 // happen without delay, since these resources are quite heavy.
132 mClient.clear();
133 mSurface.clear();
134 IPCThreadState::self()->flushCommands();
135}
136
137void SurfaceControl::clear()
138{
139 // here, the window manager tells us explicitly that we should destroy
140 // the surface's resource. Soon after this call, it will also release
141 // its last reference (which will call the dtor); however, it is possible
142 // that a client living in the same process still holds references which
143 // would delay the call to the dtor -- that is why we need this explicit
144 // "clear()" call.
145 destroy();
146}
147
Mathias Agopian62185b72009-04-16 16:19:50 -0700148bool SurfaceControl::isSameSurface(
149 const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs)
150{
151 if (lhs == 0 || rhs == 0)
152 return false;
153 return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
154}
155
Mathias Agopian01b76682009-04-16 20:04:08 -0700156status_t SurfaceControl::setLayer(int32_t layer) {
157 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800158 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700159 if (err < 0) return err;
160 return client->setLayer(mToken, layer);
161}
162status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
163 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800164 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700165 if (err < 0) return err;
166 return client->setPosition(mToken, x, y);
167}
168status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
169 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800170 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700171 if (err < 0) return err;
172 return client->setSize(mToken, w, h);
173}
174status_t SurfaceControl::hide() {
175 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800176 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700177 if (err < 0) return err;
178 return client->hide(mToken);
179}
180status_t SurfaceControl::show(int32_t layer) {
181 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800182 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700183 if (err < 0) return err;
184 return client->show(mToken, layer);
185}
186status_t SurfaceControl::freeze() {
187 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800188 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700189 if (err < 0) return err;
190 return client->freeze(mToken);
191}
192status_t SurfaceControl::unfreeze() {
193 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800194 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700195 if (err < 0) return err;
196 return client->unfreeze(mToken);
197}
198status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
199 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800200 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700201 if (err < 0) return err;
202 return client->setFlags(mToken, flags, mask);
203}
204status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
205 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800206 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700207 if (err < 0) return err;
208 return client->setTransparentRegionHint(mToken, transparent);
209}
210status_t SurfaceControl::setAlpha(float alpha) {
211 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800212 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700213 if (err < 0) return err;
214 return client->setAlpha(mToken, alpha);
215}
216status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
217 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800218 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700219 if (err < 0) return err;
220 return client->setMatrix(mToken, dsdx, dtdx, dsdy, dtdy);
221}
222status_t SurfaceControl::setFreezeTint(uint32_t tint) {
223 const sp<SurfaceComposerClient>& client(mClient);
Mathias Agopian963abad2009-11-13 15:26:29 -0800224 status_t err = validate();
Mathias Agopian01b76682009-04-16 20:04:08 -0700225 if (err < 0) return err;
226 return client->setFreezeTint(mToken, tint);
227}
Mathias Agopian62185b72009-04-16 16:19:50 -0700228
Mathias Agopian963abad2009-11-13 15:26:29 -0800229status_t SurfaceControl::validate() const
Mathias Agopian62185b72009-04-16 16:19:50 -0700230{
231 if (mToken<0 || mClient==0) {
232 LOGE("invalid token (%d, identity=%u) or client (%p)",
233 mToken, mIdentity, mClient.get());
234 return NO_INIT;
235 }
Mathias Agopian963abad2009-11-13 15:26:29 -0800236 SharedClient const* cblk = mClient->mControl;
Mathias Agopian62185b72009-04-16 16:19:50 -0700237 if (cblk == 0) {
238 LOGE("cblk is null (surface id=%d, identity=%u)", mToken, mIdentity);
239 return NO_INIT;
240 }
241 status_t err = cblk->validate(mToken);
242 if (err != NO_ERROR) {
243 LOGE("surface (id=%d, identity=%u) is invalid, err=%d (%s)",
244 mToken, mIdentity, err, strerror(-err));
245 return err;
246 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700247 uint32_t identity = cblk->getIdentity(mToken);
248 if (mIdentity != identity) {
Mathias Agopian62185b72009-04-16 16:19:50 -0700249 LOGE("using an invalid surface id=%d, identity=%u should be %d",
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700250 mToken, mIdentity, identity);
Mathias Agopian62185b72009-04-16 16:19:50 -0700251 return NO_INIT;
252 }
253 return NO_ERROR;
254}
255
Mathias Agopian01b76682009-04-16 20:04:08 -0700256status_t SurfaceControl::writeSurfaceToParcel(
257 const sp<SurfaceControl>& control, Parcel* parcel)
258{
259 uint32_t flags = 0;
260 uint32_t format = 0;
261 SurfaceID token = -1;
262 uint32_t identity = 0;
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700263 uint32_t width = 0;
264 uint32_t height = 0;
Mathias Agopian01b76682009-04-16 20:04:08 -0700265 sp<SurfaceComposerClient> client;
266 sp<ISurface> sur;
267 if (SurfaceControl::isValid(control)) {
268 token = control->mToken;
269 identity = control->mIdentity;
270 client = control->mClient;
271 sur = control->mSurface;
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700272 width = control->mWidth;
273 height = control->mHeight;
Mathias Agopian01b76682009-04-16 20:04:08 -0700274 format = control->mFormat;
275 flags = control->mFlags;
276 }
277 parcel->writeStrongBinder(client!=0 ? client->connection() : NULL);
278 parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL);
279 parcel->writeInt32(token);
280 parcel->writeInt32(identity);
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700281 parcel->writeInt32(width);
282 parcel->writeInt32(height);
Mathias Agopian01b76682009-04-16 20:04:08 -0700283 parcel->writeInt32(format);
284 parcel->writeInt32(flags);
285 return NO_ERROR;
286}
287
288sp<Surface> SurfaceControl::getSurface() const
289{
290 Mutex::Autolock _l(mLock);
291 if (mSurfaceData == 0) {
292 mSurfaceData = new Surface(const_cast<SurfaceControl*>(this));
293 }
294 return mSurfaceData;
295}
296
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700297// ============================================================================
298// Surface
299// ============================================================================
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800300
Mathias Agopian01b76682009-04-16 20:04:08 -0700301Surface::Surface(const sp<SurfaceControl>& surface)
302 : mClient(surface->mClient), mSurface(surface->mSurface),
303 mToken(surface->mToken), mIdentity(surface->mIdentity),
Mathias Agopian0926f502009-05-04 14:17:04 -0700304 mFormat(surface->mFormat), mFlags(surface->mFlags),
Mathias Agopian3330b202009-10-05 17:07:12 -0700305 mBufferMapper(GraphicBufferMapper::get()), mSharedBufferClient(NULL),
Mathias Agopianba5972f2009-08-14 18:52:17 -0700306 mWidth(surface->mWidth), mHeight(surface->mHeight)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800307{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700308 mSharedBufferClient = new SharedBufferClient(
Mathias Agopian9ec430a2009-10-06 19:00:57 -0700309 mClient->mControl, mToken, 2, mIdentity);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700310
Mathias Agopian01b76682009-04-16 20:04:08 -0700311 init();
312}
Mathias Agopian62185b72009-04-16 16:19:50 -0700313
Mathias Agopian01b76682009-04-16 20:04:08 -0700314Surface::Surface(const Parcel& parcel)
Mathias Agopian3330b202009-10-05 17:07:12 -0700315 : mBufferMapper(GraphicBufferMapper::get()), mSharedBufferClient(NULL)
Mathias Agopian01b76682009-04-16 20:04:08 -0700316{
317 sp<IBinder> clientBinder = parcel.readStrongBinder();
318 mSurface = interface_cast<ISurface>(parcel.readStrongBinder());
319 mToken = parcel.readInt32();
320 mIdentity = parcel.readInt32();
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700321 mWidth = parcel.readInt32();
322 mHeight = parcel.readInt32();
Mathias Agopian01b76682009-04-16 20:04:08 -0700323 mFormat = parcel.readInt32();
324 mFlags = parcel.readInt32();
325
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700326 // FIXME: what does that mean if clientBinder is NULL here?
327 if (clientBinder != NULL) {
Mathias Agopian01b76682009-04-16 20:04:08 -0700328 mClient = SurfaceComposerClient::clientForConnection(clientBinder);
329
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700330 mSharedBufferClient = new SharedBufferClient(
Mathias Agopian9ec430a2009-10-06 19:00:57 -0700331 mClient->mControl, mToken, 2, mIdentity);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700332 }
333
Mathias Agopian01b76682009-04-16 20:04:08 -0700334 init();
335}
336
337void Surface::init()
338{
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700339 android_native_window_t::setSwapInterval = setSwapInterval;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700340 android_native_window_t::dequeueBuffer = dequeueBuffer;
341 android_native_window_t::lockBuffer = lockBuffer;
342 android_native_window_t::queueBuffer = queueBuffer;
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700343 android_native_window_t::query = query;
Mathias Agopian52212712009-08-11 22:34:02 -0700344 android_native_window_t::perform = perform;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800345 mSwapRectangle.makeInvalid();
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700346 DisplayInfo dinfo;
347 SurfaceComposerClient::getDisplayInfo(0, &dinfo);
348 const_cast<float&>(android_native_window_t::xdpi) = dinfo.xdpi;
349 const_cast<float&>(android_native_window_t::ydpi) = dinfo.ydpi;
350 // FIXME: set real values here
351 const_cast<int&>(android_native_window_t::minSwapInterval) = 1;
352 const_cast<int&>(android_native_window_t::maxSwapInterval) = 1;
353 const_cast<uint32_t&>(android_native_window_t::flags) = 0;
Mathias Agopian52212712009-08-11 22:34:02 -0700354 // be default we request a hardware surface
355 mUsage = GRALLOC_USAGE_HW_RENDER;
Mathias Agopian55fa2512010-03-11 15:06:54 -0800356 mConnected = 0;
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700357 mNeedFullUpdate = false;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800358}
359
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800360Surface::~Surface()
361{
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700362 // this is a client-side operation, the surface is destroyed, unmap
363 // its buffers in this process.
364 for (int i=0 ; i<2 ; i++) {
Mathias Agopian50517542009-08-19 17:10:18 -0700365 if (mBuffers[i] != 0 && mBuffers[i]->handle != 0) {
Mathias Agopian21c59d02009-05-05 00:59:23 -0700366 getBufferMapper().unregisterBuffer(mBuffers[i]->handle);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700367 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800368 }
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700369
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700370 // clear all references and trigger an IPC now, to make sure things
371 // happen without delay, since these resources are quite heavy.
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800372 mClient.clear();
373 mSurface.clear();
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700374 delete mSharedBufferClient;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800375 IPCThreadState::self()->flushCommands();
376}
377
Mathias Agopianba5972f2009-08-14 18:52:17 -0700378sp<SurfaceComposerClient> Surface::getClient() const {
379 return mClient;
380}
381
382sp<ISurface> Surface::getISurface() const {
383 return mSurface;
384}
385
386bool Surface::isValid() {
387 return mToken>=0 && mClient!=0;
388}
389
Mathias Agopian963abad2009-11-13 15:26:29 -0800390status_t Surface::validate() const
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700391{
Mathias Agopianba5972f2009-08-14 18:52:17 -0700392 sp<SurfaceComposerClient> client(getClient());
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700393 if (mToken<0 || mClient==0) {
394 LOGE("invalid token (%d, identity=%u) or client (%p)",
Mathias Agopianba5972f2009-08-14 18:52:17 -0700395 mToken, mIdentity, client.get());
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700396 return NO_INIT;
397 }
Mathias Agopian963abad2009-11-13 15:26:29 -0800398 SharedClient const* cblk = mClient->mControl;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700399 if (cblk == 0) {
400 LOGE("cblk is null (surface id=%d, identity=%u)", mToken, mIdentity);
401 return NO_INIT;
402 }
403 status_t err = cblk->validate(mToken);
404 if (err != NO_ERROR) {
405 LOGE("surface (id=%d, identity=%u) is invalid, err=%d (%s)",
406 mToken, mIdentity, err, strerror(-err));
407 return err;
408 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700409 uint32_t identity = cblk->getIdentity(mToken);
410 if (mIdentity != identity) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700411 LOGE("using an invalid surface id=%d, identity=%u should be %d",
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700412 mToken, mIdentity, identity);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700413 return NO_INIT;
414 }
415 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800416}
417
Mathias Agopian01b76682009-04-16 20:04:08 -0700418
419bool Surface::isSameSurface(
420 const sp<Surface>& lhs, const sp<Surface>& rhs)
421{
422 if (lhs == 0 || rhs == 0)
423 return false;
Mathias Agopianba5972f2009-08-14 18:52:17 -0700424
Mathias Agopian01b76682009-04-16 20:04:08 -0700425 return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
426}
427
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700428// ----------------------------------------------------------------------------
429
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700430int Surface::setSwapInterval(android_native_window_t* window, int interval) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700431 return 0;
432}
433
434int Surface::dequeueBuffer(android_native_window_t* window,
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700435 android_native_buffer_t** buffer) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700436 Surface* self = getSelf(window);
437 return self->dequeueBuffer(buffer);
438}
439
440int Surface::lockBuffer(android_native_window_t* window,
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700441 android_native_buffer_t* buffer) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700442 Surface* self = getSelf(window);
443 return self->lockBuffer(buffer);
444}
445
446int Surface::queueBuffer(android_native_window_t* window,
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700447 android_native_buffer_t* buffer) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700448 Surface* self = getSelf(window);
449 return self->queueBuffer(buffer);
450}
451
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700452int Surface::query(android_native_window_t* window,
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700453 int what, int* value) {
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700454 Surface* self = getSelf(window);
455 return self->query(what, value);
456}
457
Mathias Agopian52212712009-08-11 22:34:02 -0700458int Surface::perform(android_native_window_t* window,
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700459 int operation, ...) {
Mathias Agopian52212712009-08-11 22:34:02 -0700460 va_list args;
461 va_start(args, operation);
462 Surface* self = getSelf(window);
463 int res = self->perform(operation, args);
464 va_end(args);
465 return res;
466}
467
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700468// ----------------------------------------------------------------------------
469
Mathias Agopian3330b202009-10-05 17:07:12 -0700470status_t Surface::dequeueBuffer(sp<GraphicBuffer>* buffer) {
Mathias Agopian0926f502009-05-04 14:17:04 -0700471 android_native_buffer_t* out;
472 status_t err = dequeueBuffer(&out);
Mathias Agopianba5972f2009-08-14 18:52:17 -0700473 if (err == NO_ERROR) {
Mathias Agopian3330b202009-10-05 17:07:12 -0700474 *buffer = GraphicBuffer::getSelf(out);
Mathias Agopianba5972f2009-08-14 18:52:17 -0700475 }
Mathias Agopian0926f502009-05-04 14:17:04 -0700476 return err;
477}
478
Mathias Agopian0926f502009-05-04 14:17:04 -0700479// ----------------------------------------------------------------------------
480
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700481
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700482int Surface::dequeueBuffer(android_native_buffer_t** buffer)
483{
Mathias Agopianba5972f2009-08-14 18:52:17 -0700484 sp<SurfaceComposerClient> client(getClient());
Mathias Agopian963abad2009-11-13 15:26:29 -0800485 status_t err = validate();
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700486 if (err != NO_ERROR)
487 return err;
488
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700489 ssize_t bufIdx = mSharedBufferClient->dequeue();
490 if (bufIdx < 0) {
491 LOGE("error dequeuing a buffer (%s)", strerror(bufIdx));
492 return bufIdx;
Mathias Agopian04bc12b2009-08-21 15:44:17 -0700493 }
Mathias Agopian68a6afe2009-09-15 19:10:47 -0700494
495 // below we make sure we AT LEAST have the usage flags we want
496 const uint32_t usage(getUsage());
Mathias Agopian3330b202009-10-05 17:07:12 -0700497 const sp<GraphicBuffer>& backBuffer(mBuffers[bufIdx]);
Mathias Agopian3a806952010-04-08 18:34:07 -0700498
499 // Always call needNewBuffer(), since it clears the needed buffers flags
500 bool needNewBuffer = mSharedBufferClient->needNewBuffer(bufIdx);
Mathias Agopian68a6afe2009-09-15 19:10:47 -0700501 if (backBuffer == 0 ||
502 ((uint32_t(backBuffer->usage) & usage) != usage) ||
Mathias Agopian3a806952010-04-08 18:34:07 -0700503 needNewBuffer)
Mathias Agopian68a6afe2009-09-15 19:10:47 -0700504 {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700505 err = getBufferLocked(bufIdx, usage);
506 LOGE_IF(err, "getBufferLocked(%ld, %08x) failed (%s)",
507 bufIdx, usage, strerror(-err));
Mathias Agopian50517542009-08-19 17:10:18 -0700508 if (err == NO_ERROR) {
509 // reset the width/height with the what we get from the buffer
Mathias Agopian50517542009-08-19 17:10:18 -0700510 mWidth = uint32_t(backBuffer->width);
511 mHeight = uint32_t(backBuffer->height);
512 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700513 }
514
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700515 // if we still don't have a buffer here, we probably ran out of memory
516 if (!err && backBuffer==0) {
517 err = NO_MEMORY;
518 }
519
Mathias Agopiancf81c842009-07-31 14:47:00 -0700520 if (err == NO_ERROR) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700521 mDirtyRegion.set(backBuffer->width, backBuffer->height);
522 *buffer = backBuffer.get();
523 } else {
524 mSharedBufferClient->undoDequeue(bufIdx);
Mathias Agopiancf81c842009-07-31 14:47:00 -0700525 }
Mathias Agopian50517542009-08-19 17:10:18 -0700526
Mathias Agopiancf81c842009-07-31 14:47:00 -0700527 return err;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700528}
529
530int Surface::lockBuffer(android_native_buffer_t* buffer)
531{
Mathias Agopianba5972f2009-08-14 18:52:17 -0700532 sp<SurfaceComposerClient> client(getClient());
Mathias Agopian963abad2009-11-13 15:26:29 -0800533 status_t err = validate();
Mathias Agopian40b7f6e2009-04-14 18:21:47 -0700534 if (err != NO_ERROR)
535 return err;
536
Mathias Agopian3330b202009-10-05 17:07:12 -0700537 int32_t bufIdx = GraphicBuffer::getSelf(buffer)->getIndex();
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700538 err = mSharedBufferClient->lock(bufIdx);
539 LOGE_IF(err, "error locking buffer %d (%s)", bufIdx, strerror(-err));
540 return err;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700541}
542
543int Surface::queueBuffer(android_native_buffer_t* buffer)
544{
Mathias Agopianba5972f2009-08-14 18:52:17 -0700545 sp<SurfaceComposerClient> client(getClient());
Mathias Agopian963abad2009-11-13 15:26:29 -0800546 status_t err = validate();
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700547 if (err != NO_ERROR)
548 return err;
549
Mathias Agopian0926f502009-05-04 14:17:04 -0700550 if (mSwapRectangle.isValid()) {
551 mDirtyRegion.set(mSwapRectangle);
552 }
553
Mathias Agopian3330b202009-10-05 17:07:12 -0700554 int32_t bufIdx = GraphicBuffer::getSelf(buffer)->getIndex();
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700555 mSharedBufferClient->setDirtyRegion(bufIdx, mDirtyRegion);
556 err = mSharedBufferClient->queue(bufIdx);
557 LOGE_IF(err, "error queuing buffer %d (%s)", bufIdx, strerror(-err));
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700558
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700559 if (err == NO_ERROR) {
560 // FIXME: can we avoid this IPC if we know there is one pending?
Mathias Agopianba5972f2009-08-14 18:52:17 -0700561 client->signalServer();
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700562 }
563 return err;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700564}
565
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700566int Surface::query(int what, int* value)
567{
568 switch (what) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700569 case NATIVE_WINDOW_WIDTH:
570 *value = int(mWidth);
571 return NO_ERROR;
572 case NATIVE_WINDOW_HEIGHT:
573 *value = int(mHeight);
574 return NO_ERROR;
575 case NATIVE_WINDOW_FORMAT:
576 *value = int(mFormat);
577 return NO_ERROR;
Mathias Agopiancb6b9042009-07-30 18:14:56 -0700578 }
579 return BAD_VALUE;
580}
581
Mathias Agopian52212712009-08-11 22:34:02 -0700582int Surface::perform(int operation, va_list args)
583{
584 int res = NO_ERROR;
585 switch (operation) {
Mathias Agopian55fa2512010-03-11 15:06:54 -0800586 case NATIVE_WINDOW_SET_USAGE:
587 dispatch_setUsage( args );
588 break;
589 case NATIVE_WINDOW_CONNECT:
590 res = dispatch_connect( args );
591 break;
592 case NATIVE_WINDOW_DISCONNECT:
593 res = dispatch_disconnect( args );
594 break;
595 default:
596 res = NAME_NOT_FOUND;
597 break;
Mathias Agopian52212712009-08-11 22:34:02 -0700598 }
599 return res;
600}
601
Mathias Agopian55fa2512010-03-11 15:06:54 -0800602void Surface::dispatch_setUsage(va_list args) {
603 int usage = va_arg(args, int);
604 setUsage( usage );
605}
606int Surface::dispatch_connect(va_list args) {
607 int api = va_arg(args, int);
608 return connect( api );
609}
610int Surface::dispatch_disconnect(va_list args) {
611 int api = va_arg(args, int);
612 return disconnect( api );
613}
614
615
Mathias Agopianba5972f2009-08-14 18:52:17 -0700616void Surface::setUsage(uint32_t reqUsage)
617{
618 Mutex::Autolock _l(mSurfaceLock);
Mathias Agopian68a6afe2009-09-15 19:10:47 -0700619 mUsage = reqUsage;
Mathias Agopianba5972f2009-08-14 18:52:17 -0700620}
621
Mathias Agopian55fa2512010-03-11 15:06:54 -0800622int Surface::connect(int api)
623{
624 Mutex::Autolock _l(mSurfaceLock);
625 int err = NO_ERROR;
626 switch (api) {
627 case NATIVE_WINDOW_API_EGL:
628 if (mConnected) {
629 err = -EINVAL;
630 } else {
631 mConnected = api;
632 }
633 break;
634 default:
635 err = -EINVAL;
636 break;
637 }
638 return err;
639}
640
641int Surface::disconnect(int api)
642{
643 Mutex::Autolock _l(mSurfaceLock);
644 int err = NO_ERROR;
645 switch (api) {
646 case NATIVE_WINDOW_API_EGL:
647 if (mConnected == api) {
648 mConnected = 0;
649 } else {
650 err = -EINVAL;
651 }
652 break;
653 default:
654 err = -EINVAL;
655 break;
656 }
657 return err;
658}
659
Mathias Agopian68a6afe2009-09-15 19:10:47 -0700660uint32_t Surface::getUsage() const
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700661{
662 Mutex::Autolock _l(mSurfaceLock);
Mathias Agopian68a6afe2009-09-15 19:10:47 -0700663 return mUsage;
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700664}
665
Mathias Agopian55fa2512010-03-11 15:06:54 -0800666int Surface::getConnectedApi() const
667{
668 Mutex::Autolock _l(mSurfaceLock);
669 return mConnected;
670}
671
672
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700673// ----------------------------------------------------------------------------
674
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800675status_t Surface::lock(SurfaceInfo* info, bool blocking) {
676 return Surface::lock(info, NULL, blocking);
677}
678
Mathias Agopian0926f502009-05-04 14:17:04 -0700679status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking)
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700680{
Mathias Agopian55fa2512010-03-11 15:06:54 -0800681 if (getConnectedApi()) {
682 LOGE("Surface::lock(%p) failed. Already connected to another API",
683 (android_native_window_t*)this);
684 CallStack stack;
685 stack.update();
686 stack.dump("");
687 return INVALID_OPERATION;
688 }
689
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700690 if (mApiLock.tryLock() != NO_ERROR) {
Mathias Agopian90147262010-01-22 11:47:55 -0800691 LOGE("calling Surface::lock from different threads!");
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700692 CallStack stack;
693 stack.update();
Mathias Agopian55fa2512010-03-11 15:06:54 -0800694 stack.dump("");
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700695 return WOULD_BLOCK;
696 }
Mathias Agopian90147262010-01-22 11:47:55 -0800697
698 /* Here we're holding mApiLock */
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700699
Mathias Agopian90147262010-01-22 11:47:55 -0800700 if (mLockedBuffer != 0) {
701 LOGE("Surface::lock failed, already locked");
702 mApiLock.unlock();
703 return INVALID_OPERATION;
704 }
705
Mathias Agopian52212712009-08-11 22:34:02 -0700706 // we're intending to do software rendering from this point
Mathias Agopianba5972f2009-08-14 18:52:17 -0700707 setUsage(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
708
Mathias Agopian3330b202009-10-05 17:07:12 -0700709 sp<GraphicBuffer> backBuffer;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700710 status_t err = dequeueBuffer(&backBuffer);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700711 LOGE_IF(err, "dequeueBuffer failed (%s)", strerror(-err));
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700712 if (err == NO_ERROR) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700713 err = lockBuffer(backBuffer.get());
714 LOGE_IF(err, "lockBuffer (idx=%d) failed (%s)",
715 backBuffer->getIndex(), strerror(-err));
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700716 if (err == NO_ERROR) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700717 // we handle copy-back here...
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700718
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700719 const Rect bounds(backBuffer->width, backBuffer->height);
Mathias Agopian0926f502009-05-04 14:17:04 -0700720 Region scratch(bounds);
721 Region& newDirtyRegion(dirtyIn ? *dirtyIn : scratch);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700722
Mathias Agopian3a806952010-04-08 18:34:07 -0700723 const Region copyback(mOldDirtyRegion.subtract(newDirtyRegion));
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700724 if (mNeedFullUpdate) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700725 mNeedFullUpdate = false;
Mathias Agopian3a806952010-04-08 18:34:07 -0700726 Region uninitialized(bounds);
727 uninitialized.subtractSelf(copyback | newDirtyRegion);
728 // reset newDirtyRegion to bounds when a buffer is reallocated
729 // and we have nothing to copy back to it
730 if (!uninitialized.isEmpty())
731 newDirtyRegion.set(bounds);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700732 }
Mathias Agopian3a806952010-04-08 18:34:07 -0700733 newDirtyRegion.andSelf(bounds);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700734
Mathias Agopian3330b202009-10-05 17:07:12 -0700735 const sp<GraphicBuffer>& frontBuffer(mPostedBuffer);
Mathias Agopian3a806952010-04-08 18:34:07 -0700736 if (frontBuffer != 0 &&
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700737 backBuffer->width == frontBuffer->width &&
738 backBuffer->height == frontBuffer->height &&
739 !(mFlags & ISurfaceComposer::eDestroyBackbuffer))
740 {
Mathias Agopian3a806952010-04-08 18:34:07 -0700741 if (!copyback.isEmpty()) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700742 // copy front to back
743 copyBlt(backBuffer, frontBuffer, copyback);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700744 }
745 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700746
Mathias Agopian0926f502009-05-04 14:17:04 -0700747 mDirtyRegion = newDirtyRegion;
748 mOldDirtyRegion = newDirtyRegion;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700749
Mathias Agopiane71212b2009-05-05 00:37:46 -0700750 void* vaddr;
Mathias Agopian0926f502009-05-04 14:17:04 -0700751 status_t res = backBuffer->lock(
752 GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
Mathias Agopiane71212b2009-05-05 00:37:46 -0700753 newDirtyRegion.bounds(), &vaddr);
Mathias Agopian0926f502009-05-04 14:17:04 -0700754
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700755 LOGW_IF(res, "failed locking buffer (handle = %p)",
756 backBuffer->handle);
Mathias Agopian0926f502009-05-04 14:17:04 -0700757
758 mLockedBuffer = backBuffer;
759 other->w = backBuffer->width;
760 other->h = backBuffer->height;
761 other->s = backBuffer->stride;
762 other->usage = backBuffer->usage;
763 other->format = backBuffer->format;
Mathias Agopiane71212b2009-05-05 00:37:46 -0700764 other->bits = vaddr;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700765 }
766 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700767 mApiLock.unlock();
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700768 return err;
769}
770
771status_t Surface::unlockAndPost()
772{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700773 if (mLockedBuffer == 0) {
Mathias Agopian90147262010-01-22 11:47:55 -0800774 LOGE("Surface::unlockAndPost failed, no locked buffer");
775 return INVALID_OPERATION;
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700776 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700777
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700778 status_t err = mLockedBuffer->unlock();
779 LOGE_IF(err, "failed unlocking buffer (%p)", mLockedBuffer->handle);
Mathias Agopian0926f502009-05-04 14:17:04 -0700780
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700781 err = queueBuffer(mLockedBuffer.get());
782 LOGE_IF(err, "queueBuffer (idx=%d) failed (%s)",
783 mLockedBuffer->getIndex(), strerror(-err));
784
785 mPostedBuffer = mLockedBuffer;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700786 mLockedBuffer = 0;
787 return err;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800788}
789
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800790void Surface::setSwapRectangle(const Rect& r) {
Mathias Agopianba5972f2009-08-14 18:52:17 -0700791 Mutex::Autolock _l(mSurfaceLock);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800792 mSwapRectangle = r;
793}
794
Mathias Agopian52212712009-08-11 22:34:02 -0700795status_t Surface::getBufferLocked(int index, int usage)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800796{
Mathias Agopianba5972f2009-08-14 18:52:17 -0700797 sp<ISurface> s(mSurface);
798 if (s == 0) return NO_INIT;
799
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700800 status_t err = NO_MEMORY;
Mathias Agopian50517542009-08-19 17:10:18 -0700801
802 // free the current buffer
Mathias Agopian3330b202009-10-05 17:07:12 -0700803 sp<GraphicBuffer>& currentBuffer(mBuffers[index]);
Mathias Agopian50517542009-08-19 17:10:18 -0700804 if (currentBuffer != 0) {
805 getBufferMapper().unregisterBuffer(currentBuffer->handle);
806 currentBuffer.clear();
807 }
808
Mathias Agopian3330b202009-10-05 17:07:12 -0700809 sp<GraphicBuffer> buffer = s->requestBuffer(index, usage);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700810 LOGE_IF(buffer==0,
811 "ISurface::getBuffer(%d, %08x) returned NULL",
812 index, usage);
Mathias Agopian50517542009-08-19 17:10:18 -0700813 if (buffer != 0) { // this should never happen by construction
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700814 LOGE_IF(buffer->handle == NULL,
Mathias Agopian0b3ad462009-10-02 18:12:30 -0700815 "Surface (identity=%d) requestBuffer(%d, %08x) returned"
816 "a buffer with a null handle", mIdentity, index, usage);
817 err = mSharedBufferClient->getStatus();
818 LOGE_IF(err, "Surface (identity=%d) state = %d", mIdentity, err);
819 if (!err && buffer->handle != NULL) {
Mathias Agopian50517542009-08-19 17:10:18 -0700820 err = getBufferMapper().registerBuffer(buffer->handle);
821 LOGW_IF(err, "registerBuffer(...) failed %d (%s)",
822 err, strerror(-err));
823 if (err == NO_ERROR) {
824 currentBuffer = buffer;
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700825 currentBuffer->setIndex(index);
826 mNeedFullUpdate = true;
Mathias Agopian50517542009-08-19 17:10:18 -0700827 }
Mathias Agopiand3144be2009-10-06 15:58:44 -0700828 } else {
829 err = err<0 ? err : NO_MEMORY;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800830 }
831 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700832 return err;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800833}
834
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800835}; // namespace android
836