blob: 3720e166992b35c0f5aba10aae2c1a20faf086bd [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
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080017#include <stdlib.h>
18#include <stdint.h>
19#include <sys/types.h>
20
21#include <cutils/properties.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070022#include <cutils/native_handle.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023
24#include <utils/Errors.h>
25#include <utils/Log.h>
26#include <utils/StopWatch.h>
27
Mathias Agopian3330b202009-10-05 17:07:12 -070028#include <ui/GraphicBuffer.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080029#include <ui/PixelFormat.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080030
31#include <surfaceflinger/Surface.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032
33#include "clz.h"
Mathias Agopian1f7bec62010-06-25 18:02:21 -070034#include "GLExtensions.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035#include "Layer.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080036#include "SurfaceFlinger.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037#include "DisplayHardware/DisplayHardware.h"
Mathias Agopiana350ff92010-08-10 17:14:02 -070038#include "DisplayHardware/HWComposer.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039
40
41#define DEBUG_RESIZE 0
42
43
44namespace android {
45
Mathias Agopianca99fb82010-04-14 16:43:44 -070046template <typename T> inline T min(T a, T b) {
47 return a<b ? a : b;
48}
49
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080050// ---------------------------------------------------------------------------
51
Mathias Agopian96f08192010-06-02 23:28:45 -070052Layer::Layer(SurfaceFlinger* flinger,
53 DisplayID display, const sp<Client>& client)
54 : LayerBaseClient(flinger, display, client),
Mathias Agopian1f7bec62010-06-25 18:02:21 -070055 mGLExtensions(GLExtensions::getInstance()),
Mathias Agopian401c2572009-09-23 19:16:27 -070056 mNeedsBlending(true),
Mathias Agopiand606de62010-05-10 20:06:11 -070057 mNeedsDithering(false),
Mathias Agopianb7e930d2010-06-01 15:12:58 -070058 mSecure(false),
Mathias Agopian1f7bec62010-06-25 18:02:21 -070059 mTextureManager(),
Mathias Agopiana138f892010-05-21 17:24:35 -070060 mBufferManager(mTextureManager),
61 mWidth(0), mHeight(0), mFixedSize(false)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080062{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063}
64
65Layer::~Layer()
66{
Mathias Agopianbb641242010-05-18 17:06:55 -070067 // FIXME: must be called from the main UI thread
68 EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
69 mBufferManager.destroy(dpy);
70
Mathias Agopianb7e930d2010-06-01 15:12:58 -070071 // we can use getUserClientUnsafe here because we know we're
72 // single-threaded at that point.
73 sp<UserClient> ourClient(mUserClientRef.getUserClientUnsafe());
74 if (ourClient != 0) {
75 ourClient->detachLayer(this);
76 }
Mathias Agopiand606de62010-05-10 20:06:11 -070077}
78
Mathias Agopianb7e930d2010-06-01 15:12:58 -070079status_t Layer::setToken(const sp<UserClient>& userClient,
80 SharedClient* sharedClient, int32_t token)
Mathias Agopian96f08192010-06-02 23:28:45 -070081{
Mathias Agopian579b3f82010-06-08 19:54:15 -070082 sp<SharedBufferServer> lcblk = new SharedBufferServer(
Mathias Agopianb7e930d2010-06-01 15:12:58 -070083 sharedClient, token, mBufferManager.getDefaultBufferCount(),
Mathias Agopian96f08192010-06-02 23:28:45 -070084 getIdentity());
85
Mathias Agopianb7e930d2010-06-01 15:12:58 -070086 status_t err = mUserClientRef.setToken(userClient, lcblk, token);
Mathias Agopian579b3f82010-06-08 19:54:15 -070087
88 LOGE_IF(err != NO_ERROR,
89 "ClientRef::setToken(%p, %p, %u) failed",
90 userClient.get(), lcblk.get(), token);
91
92 if (err == NO_ERROR) {
93 // we need to free the buffers associated with this surface
Mathias Agopianb7e930d2010-06-01 15:12:58 -070094 }
95
96 return err;
97}
98
99int32_t Layer::getToken() const
100{
101 return mUserClientRef.getToken();
Mathias Agopian96f08192010-06-02 23:28:45 -0700102}
103
Mathias Agopian579b3f82010-06-08 19:54:15 -0700104sp<UserClient> Layer::getClient() const
105{
106 return mUserClientRef.getClient();
107}
108
Mathias Agopiand606de62010-05-10 20:06:11 -0700109// called with SurfaceFlinger::mStateLock as soon as the layer is entered
110// in the purgatory list
111void Layer::onRemoved()
112{
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700113 ClientRef::Access sharedClient(mUserClientRef);
114 SharedBufferServer* lcblk(sharedClient.get());
115 if (lcblk) {
Mathias Agopian96f08192010-06-02 23:28:45 -0700116 // wake up the condition
117 lcblk->setStatus(NO_INIT);
118 }
Mathias Agopian48d819a2009-09-10 19:41:18 -0700119}
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700120
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700121sp<LayerBaseClient::Surface> Layer::createSurface() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800122{
123 return mSurface;
124}
125
Mathias Agopian9a112062009-04-17 19:36:26 -0700126status_t Layer::ditch()
127{
Mathias Agopianbb641242010-05-18 17:06:55 -0700128 // NOTE: Called from the main UI thread
129
Mathias Agopian0aa758d2009-04-22 15:23:34 -0700130 // the layer is not on screen anymore. free as much resources as possible
Mathias Agopianf5430db2009-12-11 00:56:10 -0800131 mFreezeLock.clear();
Mathias Agopianbb641242010-05-18 17:06:55 -0700132
133 EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
134 mBufferManager.destroy(dpy);
135 mSurface.clear();
136
137 Mutex::Autolock _l(mLock);
138 mWidth = mHeight = 0;
Mathias Agopian9a112062009-04-17 19:36:26 -0700139 return NO_ERROR;
140}
141
Mathias Agopianf9d93272009-06-19 17:00:27 -0700142status_t Layer::setBuffers( uint32_t w, uint32_t h,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800143 PixelFormat format, uint32_t flags)
144{
Mathias Agopian401c2572009-09-23 19:16:27 -0700145 // this surfaces pixel format
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800146 PixelFormatInfo info;
147 status_t err = getPixelFormatInfo(format, &info);
148 if (err) return err;
149
Mathias Agopian401c2572009-09-23 19:16:27 -0700150 // the display's pixel format
151 const DisplayHardware& hw(graphicPlane(0).displayHardware());
Mathias Agopianca99fb82010-04-14 16:43:44 -0700152 uint32_t const maxSurfaceDims = min(
153 hw.getMaxTextureSize(), hw.getMaxViewportDims());
154
155 // never allow a surface larger than what our underlying GL implementation
156 // can handle.
157 if ((uint32_t(w)>maxSurfaceDims) || (uint32_t(h)>maxSurfaceDims)) {
158 return BAD_VALUE;
159 }
160
Mathias Agopian401c2572009-09-23 19:16:27 -0700161 PixelFormatInfo displayInfo;
162 getPixelFormatInfo(hw.getFormat(), &displayInfo);
Mathias Agopiana4b740e2009-10-05 18:20:39 -0700163 const uint32_t hwFlags = hw.getFlags();
164
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700165 mFormat = format;
Mathias Agopianf955be92010-06-21 15:19:26 -0700166 mReqFormat = format;
Mathias Agopianca99fb82010-04-14 16:43:44 -0700167 mWidth = w;
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700168 mHeight = h;
Mathias Agopian3330b202009-10-05 17:07:12 -0700169 mSecure = (flags & ISurfaceComposer::eSecure) ? true : false;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800170 mNeedsBlending = (info.h_alpha - info.l_alpha) > 0;
Mathias Agopianca99fb82010-04-14 16:43:44 -0700171
Mathias Agopian401c2572009-09-23 19:16:27 -0700172 // we use the red index
173 int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED);
174 int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED);
175 mNeedsDithering = layerRedsize > displayRedSize;
176
Mathias Agopian96f08192010-06-02 23:28:45 -0700177 mSurface = new SurfaceLayer(mFlinger, this);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800178 return NO_ERROR;
179}
180
Mathias Agopiana350ff92010-08-10 17:14:02 -0700181void Layer::setGeometry(hwc_layer_t* hwcl)
182{
183 hwcl->compositionType = HWC_FRAMEBUFFER;
184 hwcl->hints = 0;
185 hwcl->flags = 0;
186 hwcl->transform = 0;
187 hwcl->blending = HWC_BLENDING_NONE;
188
189 // we can't do alpha-fade with the hwc HAL
190 const State& s(drawingState());
191 if (s.alpha < 0xFF) {
192 hwcl->flags = HWC_SKIP_LAYER;
193 return;
194 }
195
196 // we can only handle simple transformation
197 if (mOrientation & Transform::ROT_INVALID) {
198 hwcl->flags = HWC_SKIP_LAYER;
199 return;
200 }
201
202 hwcl->transform = mOrientation;
203
204 if (needsBlending()) {
205 hwcl->blending = mPremultipliedAlpha ?
206 HWC_BLENDING_PREMULT : HWC_BLENDING_COVERAGE;
207 }
208
209 hwcl->displayFrame.left = mTransformedBounds.left;
210 hwcl->displayFrame.top = mTransformedBounds.top;
211 hwcl->displayFrame.right = mTransformedBounds.right;
212 hwcl->displayFrame.bottom = mTransformedBounds.bottom;
213
214 hwcl->visibleRegionScreen.rects =
215 reinterpret_cast<hwc_rect_t const *>(
216 visibleRegionScreen.getArray(
217 &hwcl->visibleRegionScreen.numRects));
218}
219
220void Layer::setPerFrameData(hwc_layer_t* hwcl) {
221 sp<GraphicBuffer> buffer(mBufferManager.getActiveBuffer());
222 if (buffer == NULL) {
223 // this situation can happen if we ran out of memory for instance.
224 // not much we can do. continue to use whatever texture was bound
225 // to this context.
226 hwcl->handle = NULL;
227 return;
228 }
229 hwcl->handle = const_cast<native_handle_t*>(buffer->handle);
230 // TODO: set the crop value properly
231 hwcl->sourceCrop.left = 0;
232 hwcl->sourceCrop.top = 0;
233 hwcl->sourceCrop.right = buffer->width;
234 hwcl->sourceCrop.bottom = buffer->height;
235}
236
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800237void Layer::reloadTexture(const Region& dirty)
238{
Mathias Agopiand606de62010-05-10 20:06:11 -0700239 sp<GraphicBuffer> buffer(mBufferManager.getActiveBuffer());
Mathias Agopian8f03b472009-12-10 15:52:29 -0800240 if (buffer == NULL) {
241 // this situation can happen if we ran out of memory for instance.
242 // not much we can do. continue to use whatever texture was bound
243 // to this context.
244 return;
245 }
246
Mathias Agopian1f7bec62010-06-25 18:02:21 -0700247 if (mGLExtensions.haveDirectTexture()) {
Mathias Agopiand606de62010-05-10 20:06:11 -0700248 EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
249 if (mBufferManager.initEglImage(dpy, buffer) != NO_ERROR) {
250 // not sure what we can do here...
Mathias Agopiand606de62010-05-10 20:06:11 -0700251 goto slowpath;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700252 }
Mathias Agopian1f7bec62010-06-25 18:02:21 -0700253 } else {
Mathias Agopianfcfeb4b2010-03-08 11:14:20 -0800254slowpath:
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700255 GGLSurface t;
Mathias Agopian3330b202009-10-05 17:07:12 -0700256 status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_OFTEN);
Mathias Agopian0926f502009-05-04 14:17:04 -0700257 LOGE_IF(res, "error %d (%s) locking buffer %p",
258 res, strerror(res), buffer.get());
259 if (res == NO_ERROR) {
Mathias Agopiand606de62010-05-10 20:06:11 -0700260 mBufferManager.loadTexture(dirty, t);
Mathias Agopian0926f502009-05-04 14:17:04 -0700261 buffer->unlock();
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700262 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800263 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800264}
265
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800266void Layer::onDraw(const Region& clip) const
267{
Mathias Agopiand606de62010-05-10 20:06:11 -0700268 Texture tex(mBufferManager.getActiveTexture());
269 if (tex.name == -1LU) {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800270 // the texture has not been created yet, this Layer has
Mathias Agopian179169e2010-05-06 20:21:45 -0700271 // in fact never been drawn into. This happens frequently with
272 // SurfaceView because the WindowManager can't know when the client
273 // has drawn the first time.
274
275 // If there is nothing under us, we paint the screen in black, otherwise
276 // we just skip this update.
277
278 // figure out if there is something below us
279 Region under;
280 const SurfaceFlinger::LayerVector& drawingLayers(mFlinger->mDrawingState.layersSortedByZ);
281 const size_t count = drawingLayers.size();
282 for (size_t i=0 ; i<count ; ++i) {
283 const sp<LayerBase>& layer(drawingLayers[i]);
284 if (layer.get() == static_cast<LayerBase const*>(this))
285 break;
286 under.orSelf(layer->visibleRegionScreen);
287 }
288 // if not everything below us is covered, we plug the holes!
289 Region holes(clip.subtract(under));
290 if (!holes.isEmpty()) {
Mathias Agopian0a917752010-06-14 21:20:00 -0700291 clearWithOpenGL(holes, 0, 0, 0, 1);
Mathias Agopian179169e2010-05-06 20:21:45 -0700292 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800293 return;
294 }
Mathias Agopiand606de62010-05-10 20:06:11 -0700295 drawWithOpenGL(clip, tex);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800296}
297
Mathias Agopiana7f66922010-05-26 22:08:52 -0700298bool Layer::needsFiltering() const
299{
300 if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
301 // NOTE: there is a race here, because mFixedSize is updated in a
302 // binder transaction. however, it doesn't really matter since it is
303 // evaluated each time we draw. To be perfectly correct, this flag
304 // would have to be associated with a buffer.
305 if (mFixedSize)
306 return true;
307 }
308 return LayerBase::needsFiltering();
309}
310
Mathias Agopianb5b7f262010-05-07 15:58:44 -0700311
312status_t Layer::setBufferCount(int bufferCount)
313{
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700314 ClientRef::Access sharedClient(mUserClientRef);
315 SharedBufferServer* lcblk(sharedClient.get());
316 if (!lcblk) {
Mathias Agopianb5b7f262010-05-07 15:58:44 -0700317 // oops, the client is already gone
318 return DEAD_OBJECT;
319 }
320
Mathias Agopianbb641242010-05-18 17:06:55 -0700321 // NOTE: lcblk->resize() is protected by an internal lock
322 status_t err = lcblk->resize(bufferCount);
323 if (err == NO_ERROR)
324 mBufferManager.resize(bufferCount);
Mathias Agopianb5b7f262010-05-07 15:58:44 -0700325
326 return err;
327}
328
Mathias Agopiana138f892010-05-21 17:24:35 -0700329sp<GraphicBuffer> Layer::requestBuffer(int index,
330 uint32_t reqWidth, uint32_t reqHeight, uint32_t reqFormat,
331 uint32_t usage)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800332{
Mathias Agopian3330b202009-10-05 17:07:12 -0700333 sp<GraphicBuffer> buffer;
Mathias Agopian48d819a2009-09-10 19:41:18 -0700334
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700335 if (int32_t(reqWidth | reqHeight | reqFormat) < 0)
Mathias Agopiana138f892010-05-21 17:24:35 -0700336 return buffer;
337
338 if ((!reqWidth && reqHeight) || (reqWidth && !reqHeight))
339 return buffer;
340
Mathias Agopian48d819a2009-09-10 19:41:18 -0700341 // this ensures our client doesn't go away while we're accessing
342 // the shared area.
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700343 ClientRef::Access sharedClient(mUserClientRef);
344 SharedBufferServer* lcblk(sharedClient.get());
345 if (!lcblk) {
Mathias Agopian48d819a2009-09-10 19:41:18 -0700346 // oops, the client is already gone
347 return buffer;
348 }
349
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700350 /*
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700351 * This is called from the client's Surface::dequeue(). This can happen
352 * at any time, especially while we're in the middle of using the
353 * buffer 'index' as our front buffer.
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700354 */
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800355
Mathias Agopian208cb072010-07-27 20:11:35 -0700356 status_t err = NO_ERROR;
Mathias Agopiana138f892010-05-21 17:24:35 -0700357 uint32_t w, h, f;
Mathias Agopian48d819a2009-09-10 19:41:18 -0700358 { // scope for the lock
359 Mutex::Autolock _l(mLock);
Mathias Agopiana138f892010-05-21 17:24:35 -0700360 const bool fixedSizeChanged = mFixedSize != (reqWidth && reqHeight);
361 const bool formatChanged = mReqFormat != reqFormat;
362 mReqWidth = reqWidth;
363 mReqHeight = reqHeight;
364 mReqFormat = reqFormat;
365 mFixedSize = reqWidth && reqHeight;
366 w = reqWidth ? reqWidth : mWidth;
367 h = reqHeight ? reqHeight : mHeight;
368 f = reqFormat ? reqFormat : mFormat;
Mathias Agopiana138f892010-05-21 17:24:35 -0700369 if (fixedSizeChanged || formatChanged) {
370 lcblk->reallocateAllExcept(index);
371 }
Mathias Agopian48d819a2009-09-10 19:41:18 -0700372 }
373
Mathias Agopian208cb072010-07-27 20:11:35 -0700374 // here we have to reallocate a new buffer because the buffer could be
375 // used as the front buffer, or by a client in our process
376 // (eg: status bar), and we can't release the handle under its feet.
Mathias Agopian3330b202009-10-05 17:07:12 -0700377 const uint32_t effectiveUsage = getEffectiveUsage(usage);
Mathias Agopian208cb072010-07-27 20:11:35 -0700378 buffer = new GraphicBuffer(w, h, f, effectiveUsage);
379 err = buffer->initCheck();
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700380
381 if (err || buffer->handle == 0) {
382 LOGE_IF(err || buffer->handle == 0,
383 "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d failed (%s)",
384 this, index, w, h, strerror(-err));
385 } else {
386 LOGD_IF(DEBUG_RESIZE,
Mathias Agopian7e4a5872009-09-29 22:39:22 -0700387 "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d, handle=%p",
388 this, index, w, h, buffer->handle);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700389 }
390
391 if (err == NO_ERROR && buffer->handle != 0) {
Mathias Agopian48d819a2009-09-10 19:41:18 -0700392 Mutex::Autolock _l(mLock);
Mathias Agopiana138f892010-05-21 17:24:35 -0700393 mBufferManager.attachBuffer(index, buffer);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700394 }
395 return buffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800396}
397
Mathias Agopian3330b202009-10-05 17:07:12 -0700398uint32_t Layer::getEffectiveUsage(uint32_t usage) const
399{
400 /*
401 * buffers used for software rendering, but h/w composition
402 * are allocated with SW_READ_OFTEN | SW_WRITE_OFTEN | HW_TEXTURE
403 *
404 * buffers used for h/w rendering and h/w composition
405 * are allocated with HW_RENDER | HW_TEXTURE
406 *
407 * buffers used with h/w rendering and either NPOT or no egl_image_ext
408 * are allocated with SW_READ_RARELY | HW_RENDER
409 *
410 */
411
412 if (mSecure) {
413 // secure buffer, don't store it into the GPU
414 usage = GraphicBuffer::USAGE_SW_READ_OFTEN |
415 GraphicBuffer::USAGE_SW_WRITE_OFTEN;
416 } else {
417 // it's allowed to modify the usage flags here, but generally
418 // the requested flags should be honored.
Mathias Agopian89141f92010-05-10 20:10:10 -0700419 // request EGLImage for all buffers
420 usage |= GraphicBuffer::USAGE_HW_TEXTURE;
Mathias Agopian3330b202009-10-05 17:07:12 -0700421 }
422 return usage;
423}
424
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800425uint32_t Layer::doTransaction(uint32_t flags)
426{
427 const Layer::State& front(drawingState());
428 const Layer::State& temp(currentState());
429
Mathias Agopiana138f892010-05-21 17:24:35 -0700430 const bool sizeChanged = (front.requested_w != temp.requested_w) ||
431 (front.requested_h != temp.requested_h);
432
433 if (sizeChanged) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700434 // the size changed, we need to ask our client to request a new buffer
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800435 LOGD_IF(DEBUG_RESIZE,
Mathias Agopiana138f892010-05-21 17:24:35 -0700436 "resize (layer=%p), requested (%dx%d), drawing (%d,%d)",
437 this,
438 int(temp.requested_w), int(temp.requested_h),
439 int(front.requested_w), int(front.requested_h));
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800440
Mathias Agopiana138f892010-05-21 17:24:35 -0700441 if (!isFixedSize()) {
442 // we're being resized and there is a freeze display request,
443 // acquire a freeze lock, so that the screen stays put
444 // until we've redrawn at the new size; this is to avoid
445 // glitches upon orientation changes.
446 if (mFlinger->hasFreezeRequest()) {
447 // if the surface is hidden, don't try to acquire the
448 // freeze lock, since hidden surfaces may never redraw
449 if (!(front.flags & ISurfaceComposer::eLayerHidden)) {
450 mFreezeLock = mFlinger->getFreezeLock();
451 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800452 }
Mathias Agopiana138f892010-05-21 17:24:35 -0700453
454 // this will make sure LayerBase::doTransaction doesn't update
455 // the drawing state's size
456 Layer::State& editDraw(mDrawingState);
457 editDraw.requested_w = temp.requested_w;
458 editDraw.requested_h = temp.requested_h;
459
460 // record the new size, form this point on, when the client request
461 // a buffer, it'll get the new size.
462 setBufferSize(temp.requested_w, temp.requested_h);
463
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700464 ClientRef::Access sharedClient(mUserClientRef);
465 SharedBufferServer* lcblk(sharedClient.get());
466 if (lcblk) {
Mathias Agopian96f08192010-06-02 23:28:45 -0700467 // all buffers need reallocation
468 lcblk->reallocateAll();
469 }
Mathias Agopiana138f892010-05-21 17:24:35 -0700470 } else {
471 // record the new size
472 setBufferSize(temp.requested_w, temp.requested_h);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800473 }
474 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700475
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800476 if (temp.sequence != front.sequence) {
477 if (temp.flags & ISurfaceComposer::eLayerHidden || temp.alpha == 0) {
478 // this surface is now hidden, so it shouldn't hold a freeze lock
479 // (it may never redraw, which is fine if it is hidden)
480 mFreezeLock.clear();
481 }
482 }
483
484 return LayerBase::doTransaction(flags);
485}
486
Mathias Agopiana138f892010-05-21 17:24:35 -0700487void Layer::setBufferSize(uint32_t w, uint32_t h) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700488 Mutex::Autolock _l(mLock);
489 mWidth = w;
490 mHeight = h;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800491}
492
Mathias Agopiana138f892010-05-21 17:24:35 -0700493bool Layer::isFixedSize() const {
494 Mutex::Autolock _l(mLock);
495 return mFixedSize;
496}
497
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800498// ----------------------------------------------------------------------------
499// pageflip handling...
500// ----------------------------------------------------------------------------
501
502void Layer::lockPageFlip(bool& recomputeVisibleRegions)
503{
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700504 ClientRef::Access sharedClient(mUserClientRef);
505 SharedBufferServer* lcblk(sharedClient.get());
506 if (!lcblk) {
Mathias Agopian96f08192010-06-02 23:28:45 -0700507 // client died
508 recomputeVisibleRegions = true;
509 return;
510 }
511
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700512 ssize_t buf = lcblk->retireAndLock();
Mathias Agopiand606de62010-05-10 20:06:11 -0700513 if (buf == NOT_ENOUGH_DATA) {
514 // NOTE: This is not an error, it simply means there is nothing to
515 // retire. The buffer is locked because we will use it
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700516 // for composition later in the loop
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800517 return;
518 }
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700519
Mathias Agopiand606de62010-05-10 20:06:11 -0700520 if (buf < NO_ERROR) {
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700521 LOGE("retireAndLock() buffer index (%d) out of range", int(buf));
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700522 mPostedDirtyRegion.clear();
523 return;
524 }
525
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700526 // we retired a buffer, which becomes the new front buffer
Mathias Agopiand606de62010-05-10 20:06:11 -0700527 if (mBufferManager.setActiveBufferIndex(buf) < NO_ERROR) {
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700528 LOGE("retireAndLock() buffer index (%d) out of range", int(buf));
Mathias Agopiand606de62010-05-10 20:06:11 -0700529 mPostedDirtyRegion.clear();
530 return;
531 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800532
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700533 // get the dirty region
Mathias Agopian3330b202009-10-05 17:07:12 -0700534 sp<GraphicBuffer> newFrontBuffer(getBuffer(buf));
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700535 if (newFrontBuffer != NULL) {
536 // compute the posted region
537 const Region dirty(lcblk->getDirtyRegion(buf));
538 mPostedDirtyRegion = dirty.intersect( newFrontBuffer->getBounds() );
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700539
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700540 // update the layer size and release freeze-lock
541 const Layer::State& front(drawingState());
542 if (newFrontBuffer->getWidth() == front.requested_w &&
543 newFrontBuffer->getHeight() == front.requested_h)
Mathias Agopiandf3e0b92009-09-30 14:07:22 -0700544 {
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700545 if ((front.w != front.requested_w) ||
546 (front.h != front.requested_h))
547 {
548 // Here we pretend the transaction happened by updating the
549 // current and drawing states. Drawing state is only accessed
550 // in this thread, no need to have it locked
551 Layer::State& editDraw(mDrawingState);
552 editDraw.w = editDraw.requested_w;
553 editDraw.h = editDraw.requested_h;
Mathias Agopiandf3e0b92009-09-30 14:07:22 -0700554
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700555 // We also need to update the current state so that we don't
556 // end-up doing too much work during the next transaction.
557 // NOTE: We actually don't need hold the transaction lock here
558 // because State::w and State::h are only accessed from
559 // this thread
560 Layer::State& editTemp(currentState());
561 editTemp.w = editDraw.w;
562 editTemp.h = editDraw.h;
Mathias Agopiandf3e0b92009-09-30 14:07:22 -0700563
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700564 // recompute visible region
565 recomputeVisibleRegions = true;
566 }
567
568 // we now have the correct size, unfreeze the screen
569 mFreezeLock.clear();
Mathias Agopiandf3e0b92009-09-30 14:07:22 -0700570 }
Mathias Agopiand343e3d2010-03-15 18:15:20 -0700571 } else {
572 // this should not happen unless we ran out of memory while
573 // allocating the buffer. we're hoping that things will get back
574 // to normal the next time the app tries to draw into this buffer.
575 // meanwhile, pretend the screen didn't update.
576 mPostedDirtyRegion.clear();
Mathias Agopiancaa600c2009-09-16 18:27:24 -0700577 }
578
Mathias Agopiane7005012009-10-07 16:44:10 -0700579 if (lcblk->getQueuedCount()) {
580 // signal an event if we have more buffers waiting
581 mFlinger->signalEvent();
582 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800583
Mathias Agopian245e4d72010-04-21 15:24:11 -0700584 /* a buffer was posted, so we need to call reloadTexture(), which
585 * will update our internal data structures (eg: EGLImageKHR or
586 * texture names). we need to do this even if mPostedDirtyRegion is
587 * empty -- it's orthogonal to the fact that a new buffer was posted,
588 * for instance, a degenerate case could be that the user did an empty
589 * update but repainted the buffer with appropriate content (after a
590 * resize for instance).
591 */
592 reloadTexture( mPostedDirtyRegion );
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800593}
594
595void Layer::unlockPageFlip(
596 const Transform& planeTransform, Region& outDirtyRegion)
597{
598 Region dirtyRegion(mPostedDirtyRegion);
599 if (!dirtyRegion.isEmpty()) {
600 mPostedDirtyRegion.clear();
601 // The dirty region is given in the layer's coordinate space
602 // transform the dirty region by the surface's transformation
603 // and the global transformation.
604 const Layer::State& s(drawingState());
605 const Transform tr(planeTransform * s.transform);
606 dirtyRegion = tr.transform(dirtyRegion);
607
608 // At this point, the dirty region is in screen space.
609 // Make sure it's constrained by the visible region (which
610 // is in screen space as well).
611 dirtyRegion.andSelf(visibleRegionScreen);
612 outDirtyRegion.orSelf(dirtyRegion);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800613 }
Mathias Agopianc61de172009-11-30 11:15:41 -0800614 if (visibleRegionScreen.isEmpty()) {
615 // an invisible layer should not hold a freeze-lock
Mathias Agopian1b5e1022010-04-20 17:55:49 -0700616 // (because it may never be updated and therefore never release it)
Mathias Agopianc61de172009-11-30 11:15:41 -0800617 mFreezeLock.clear();
618 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800619}
620
621void Layer::finishPageFlip()
622{
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700623 ClientRef::Access sharedClient(mUserClientRef);
624 SharedBufferServer* lcblk(sharedClient.get());
625 if (lcblk) {
Mathias Agopian96f08192010-06-02 23:28:45 -0700626 int buf = mBufferManager.getActiveBufferIndex();
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700627 if (buf >= 0) {
628 status_t err = lcblk->unlock( buf );
629 LOGE_IF(err!=NO_ERROR,
630 "layer %p, buffer=%d wasn't locked!",
631 this, buf);
632 }
Mathias Agopian96f08192010-06-02 23:28:45 -0700633 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800634}
635
Mathias Agopian1b5e1022010-04-20 17:55:49 -0700636
637void Layer::dump(String8& result, char* buffer, size_t SIZE) const
638{
639 LayerBaseClient::dump(result, buffer, SIZE);
640
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700641 ClientRef::Access sharedClient(mUserClientRef);
642 SharedBufferServer* lcblk(sharedClient.get());
643 uint32_t totalTime = 0;
644 if (lcblk) {
645 SharedBufferStack::Statistics stats = lcblk->getStats();
646 totalTime= stats.totalTime;
647 result.append( lcblk->dump(" ") );
648 }
649
Mathias Agopian1b5e1022010-04-20 17:55:49 -0700650 sp<const GraphicBuffer> buf0(getBuffer(0));
651 sp<const GraphicBuffer> buf1(getBuffer(1));
652 uint32_t w0=0, h0=0, s0=0;
653 uint32_t w1=0, h1=0, s1=0;
654 if (buf0 != 0) {
655 w0 = buf0->getWidth();
656 h0 = buf0->getHeight();
657 s0 = buf0->getStride();
658 }
659 if (buf1 != 0) {
660 w1 = buf1->getWidth();
661 h1 = buf1->getHeight();
662 s1 = buf1->getStride();
663 }
664 snprintf(buffer, SIZE,
665 " "
666 "format=%2d, [%3ux%3u:%3u] [%3ux%3u:%3u],"
667 " freezeLock=%p, dq-q-time=%u us\n",
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700668 mFormat, w0, h0, s0, w1, h1, s1,
669 getFreezeLock().get(), totalTime);
Mathias Agopian1b5e1022010-04-20 17:55:49 -0700670
671 result.append(buffer);
672}
673
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700674// ---------------------------------------------------------------------------
675
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700676Layer::ClientRef::ClientRef()
Mathias Agopian579b3f82010-06-08 19:54:15 -0700677 : mControlBlock(0), mToken(-1) {
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700678}
679
680Layer::ClientRef::~ClientRef() {
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700681}
682
683int32_t Layer::ClientRef::getToken() const {
684 Mutex::Autolock _l(mLock);
685 return mToken;
686}
687
Mathias Agopian579b3f82010-06-08 19:54:15 -0700688sp<UserClient> Layer::ClientRef::getClient() const {
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700689 Mutex::Autolock _l(mLock);
Mathias Agopian579b3f82010-06-08 19:54:15 -0700690 return mUserClient.promote();
691}
692
693status_t Layer::ClientRef::setToken(const sp<UserClient>& uc,
694 const sp<SharedBufferServer>& sharedClient, int32_t token) {
695 Mutex::Autolock _l(mLock);
696
697 { // scope for strong mUserClient reference
698 sp<UserClient> userClient(mUserClient.promote());
699 if (mUserClient != 0 && mControlBlock != 0) {
700 mControlBlock->setStatus(NO_INIT);
701 }
702 }
703
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700704 mUserClient = uc;
705 mToken = token;
Mathias Agopian579b3f82010-06-08 19:54:15 -0700706 mControlBlock = sharedClient;
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700707 return NO_ERROR;
708}
709
710sp<UserClient> Layer::ClientRef::getUserClientUnsafe() const {
711 return mUserClient.promote();
712}
713
714// this class gives us access to SharedBufferServer safely
715// it makes sure the UserClient (and its associated shared memory)
716// won't go away while we're accessing it.
717Layer::ClientRef::Access::Access(const ClientRef& ref)
Mathias Agopian579b3f82010-06-08 19:54:15 -0700718 : mControlBlock(0)
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700719{
720 Mutex::Autolock _l(ref.mLock);
721 mUserClientStrongRef = ref.mUserClient.promote();
722 if (mUserClientStrongRef != 0)
Mathias Agopian579b3f82010-06-08 19:54:15 -0700723 mControlBlock = ref.mControlBlock;
724}
725
726Layer::ClientRef::Access::~Access()
727{
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700728}
729
730// ---------------------------------------------------------------------------
731
Mathias Agopiand606de62010-05-10 20:06:11 -0700732Layer::BufferManager::BufferManager(TextureManager& tm)
Mathias Agopianbb641242010-05-18 17:06:55 -0700733 : mNumBuffers(NUM_BUFFERS), mTextureManager(tm),
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700734 mActiveBuffer(-1), mFailover(false)
Mathias Agopiand606de62010-05-10 20:06:11 -0700735{
736}
737
Mathias Agopianbb641242010-05-18 17:06:55 -0700738Layer::BufferManager::~BufferManager()
739{
740}
741
742status_t Layer::BufferManager::resize(size_t size)
743{
744 Mutex::Autolock _l(mLock);
745 mNumBuffers = size;
746 return NO_ERROR;
Mathias Agopiand606de62010-05-10 20:06:11 -0700747}
748
749// only for debugging
750sp<GraphicBuffer> Layer::BufferManager::getBuffer(size_t index) const {
751 return mBufferData[index].buffer;
752}
753
754status_t Layer::BufferManager::setActiveBufferIndex(size_t index) {
Mathias Agopiand606de62010-05-10 20:06:11 -0700755 mActiveBuffer = index;
756 return NO_ERROR;
757}
758
759size_t Layer::BufferManager::getActiveBufferIndex() const {
760 return mActiveBuffer;
761}
762
763Texture Layer::BufferManager::getActiveTexture() const {
Mathias Agopianbb641242010-05-18 17:06:55 -0700764 Texture res;
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700765 if (mFailover || mActiveBuffer<0) {
Mathias Agopianbb641242010-05-18 17:06:55 -0700766 res = mFailoverTexture;
767 } else {
768 static_cast<Image&>(res) = mBufferData[mActiveBuffer].texture;
769 }
770 return res;
Mathias Agopiand606de62010-05-10 20:06:11 -0700771}
772
773sp<GraphicBuffer> Layer::BufferManager::getActiveBuffer() const {
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700774 sp<GraphicBuffer> result;
775 const ssize_t activeBuffer = mActiveBuffer;
776 if (activeBuffer >= 0) {
777 BufferData const * const buffers = mBufferData;
778 Mutex::Autolock _l(mLock);
779 result = buffers[activeBuffer].buffer;
780 }
781 return result;
Mathias Agopiand606de62010-05-10 20:06:11 -0700782}
783
784sp<GraphicBuffer> Layer::BufferManager::detachBuffer(size_t index)
785{
Mathias Agopianbb641242010-05-18 17:06:55 -0700786 BufferData* const buffers = mBufferData;
Mathias Agopiand606de62010-05-10 20:06:11 -0700787 sp<GraphicBuffer> buffer;
788 Mutex::Autolock _l(mLock);
Mathias Agopianbb641242010-05-18 17:06:55 -0700789 buffer = buffers[index].buffer;
790 buffers[index].buffer = 0;
Mathias Agopiand606de62010-05-10 20:06:11 -0700791 return buffer;
792}
793
794status_t Layer::BufferManager::attachBuffer(size_t index,
795 const sp<GraphicBuffer>& buffer)
796{
Mathias Agopianbb641242010-05-18 17:06:55 -0700797 BufferData* const buffers = mBufferData;
Mathias Agopiand606de62010-05-10 20:06:11 -0700798 Mutex::Autolock _l(mLock);
Mathias Agopianbb641242010-05-18 17:06:55 -0700799 buffers[index].buffer = buffer;
800 buffers[index].texture.dirty = true;
Mathias Agopiand606de62010-05-10 20:06:11 -0700801 return NO_ERROR;
802}
803
804status_t Layer::BufferManager::destroy(EGLDisplay dpy)
805{
Mathias Agopianbb641242010-05-18 17:06:55 -0700806 BufferData* const buffers = mBufferData;
807 size_t num;
808 { // scope for the lock
809 Mutex::Autolock _l(mLock);
810 num = mNumBuffers;
811 for (size_t i=0 ; i<num ; i++) {
812 buffers[i].buffer = 0;
813 }
814 }
815 for (size_t i=0 ; i<num ; i++) {
816 destroyTexture(&buffers[i].texture, dpy);
Mathias Agopiand606de62010-05-10 20:06:11 -0700817 }
818 destroyTexture(&mFailoverTexture, dpy);
819 return NO_ERROR;
820}
821
822status_t Layer::BufferManager::initEglImage(EGLDisplay dpy,
823 const sp<GraphicBuffer>& buffer)
824{
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700825 status_t err = NO_INIT;
826 ssize_t index = mActiveBuffer;
827 if (index >= 0) {
Mathias Agopian1f7bec62010-06-25 18:02:21 -0700828 if (!mFailover) {
829 Image& texture(mBufferData[index].texture);
830 err = mTextureManager.initEglImage(&texture, dpy, buffer);
831 // if EGLImage fails, we switch to regular texture mode, and we
832 // free all resources associated with using EGLImages.
833 if (err == NO_ERROR) {
834 mFailover = false;
835 destroyTexture(&mFailoverTexture, dpy);
836 } else {
837 mFailover = true;
838 const size_t num = mNumBuffers;
839 for (size_t i=0 ; i<num ; i++) {
840 destroyTexture(&mBufferData[i].texture, dpy);
841 }
Andreas Hubere049a952010-06-25 09:25:19 -0700842 }
Mathias Agopian1f7bec62010-06-25 18:02:21 -0700843 } else {
844 // we failed once, don't try again
845 err = BAD_VALUE;
Mathias Agopiand606de62010-05-10 20:06:11 -0700846 }
847 }
848 return err;
849}
850
851status_t Layer::BufferManager::loadTexture(
852 const Region& dirty, const GGLSurface& t)
853{
854 return mTextureManager.loadTexture(&mFailoverTexture, dirty, t);
855}
856
Mathias Agopianbb641242010-05-18 17:06:55 -0700857status_t Layer::BufferManager::destroyTexture(Image* tex, EGLDisplay dpy)
858{
859 if (tex->name != -1U) {
860 glDeleteTextures(1, &tex->name);
861 tex->name = -1U;
862 }
863 if (tex->image != EGL_NO_IMAGE_KHR) {
864 eglDestroyImageKHR(dpy, tex->image);
865 tex->image = EGL_NO_IMAGE_KHR;
866 }
867 return NO_ERROR;
868}
869
Mathias Agopiand606de62010-05-10 20:06:11 -0700870// ---------------------------------------------------------------------------
871
Mathias Agopian9a112062009-04-17 19:36:26 -0700872Layer::SurfaceLayer::SurfaceLayer(const sp<SurfaceFlinger>& flinger,
Mathias Agopian96f08192010-06-02 23:28:45 -0700873 const sp<Layer>& owner)
874 : Surface(flinger, owner->getIdentity(), owner)
Mathias Agopian9a112062009-04-17 19:36:26 -0700875{
876}
877
878Layer::SurfaceLayer::~SurfaceLayer()
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700879{
880}
881
Mathias Agopiana138f892010-05-21 17:24:35 -0700882sp<GraphicBuffer> Layer::SurfaceLayer::requestBuffer(int index,
883 uint32_t w, uint32_t h, uint32_t format, uint32_t usage)
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700884{
Mathias Agopian3330b202009-10-05 17:07:12 -0700885 sp<GraphicBuffer> buffer;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700886 sp<Layer> owner(getOwner());
887 if (owner != 0) {
Mathias Agopianbb641242010-05-18 17:06:55 -0700888 /*
889 * requestBuffer() cannot be called from the main thread
890 * as it could cause a dead-lock, since it may have to wait
891 * on conditions updated my the main thread.
892 */
Mathias Agopiana138f892010-05-21 17:24:35 -0700893 buffer = owner->requestBuffer(index, w, h, format, usage);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700894 }
895 return buffer;
896}
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800897
Mathias Agopianb5b7f262010-05-07 15:58:44 -0700898status_t Layer::SurfaceLayer::setBufferCount(int bufferCount)
899{
900 status_t err = DEAD_OBJECT;
901 sp<Layer> owner(getOwner());
902 if (owner != 0) {
Mathias Agopianbb641242010-05-18 17:06:55 -0700903 /*
904 * setBufferCount() cannot be called from the main thread
905 * as it could cause a dead-lock, since it may have to wait
906 * on conditions updated my the main thread.
907 */
Mathias Agopianb5b7f262010-05-07 15:58:44 -0700908 err = owner->setBufferCount(bufferCount);
909 }
910 return err;
911}
912
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800913// ---------------------------------------------------------------------------
914
915
916}; // namespace android