blob: 1e7f1e67c2b1f8d1367057b3ddef9b3b1af75277 [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
28#include <ui/PixelFormat.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070029#include <ui/Surface.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080030
Mathias Agopiancbb288b2009-09-07 16:32:45 -070031#include "Buffer.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032#include "clz.h"
33#include "Layer.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034#include "SurfaceFlinger.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035#include "DisplayHardware/DisplayHardware.h"
36
37
38#define DEBUG_RESIZE 0
39
40
41namespace android {
42
43// ---------------------------------------------------------------------------
44
45const uint32_t Layer::typeInfo = LayerBaseClient::typeInfo | 4;
46const char* const Layer::typeID = "Layer";
47
48// ---------------------------------------------------------------------------
49
Mathias Agopiancbb288b2009-09-07 16:32:45 -070050Layer::Layer(SurfaceFlinger* flinger, DisplayID display,
51 const sp<Client>& c, int32_t i)
Mathias Agopian48d819a2009-09-10 19:41:18 -070052 : LayerBaseClient(flinger, display, c, i),
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053 mSecure(false),
Mathias Agopiancbb288b2009-09-07 16:32:45 -070054 mNeedsBlending(true)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080055{
56 // no OpenGL operation is possible here, since we might not be
57 // in the OpenGL thread.
Mathias Agopiancbb288b2009-09-07 16:32:45 -070058 mFrontBufferIndex = lcblk->getFrontBuffer();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059}
60
61Layer::~Layer()
62{
Mathias Agopian0aa758d2009-04-22 15:23:34 -070063 destroy();
64 // the actual buffers will be destroyed here
Mathias Agopian48d819a2009-09-10 19:41:18 -070065}
Mathias Agopiancbb288b2009-09-07 16:32:45 -070066
Mathias Agopian48d819a2009-09-10 19:41:18 -070067// called with SurfaceFlinger::mStateLock as soon as the layer is entered
68// in the purgatory list
69void Layer::onRemoved()
70{
71 // wake up the condition
72 lcblk->setStatus(NO_INIT);
Mathias Agopian0aa758d2009-04-22 15:23:34 -070073}
74
75void Layer::destroy()
76{
Mathias Agopiancbb288b2009-09-07 16:32:45 -070077 for (size_t i=0 ; i<NUM_BUFFERS ; i++) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -070078 if (mTextures[i].name != -1U) {
Mathias Agopian550b79f2009-04-22 15:49:28 -070079 glDeleteTextures(1, &mTextures[i].name);
Mathias Agopian0aa758d2009-04-22 15:23:34 -070080 mTextures[i].name = -1U;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070081 }
82 if (mTextures[i].image != EGL_NO_IMAGE_KHR) {
83 EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
84 eglDestroyImageKHR(dpy, mTextures[i].image);
Mathias Agopian0aa758d2009-04-22 15:23:34 -070085 mTextures[i].image = EGL_NO_IMAGE_KHR;
Mathias Agopian076b1cc2009-04-10 14:24:30 -070086 }
Mathias Agopian48d819a2009-09-10 19:41:18 -070087 Mutex::Autolock _l(mLock);
Mathias Agopiancbb288b2009-09-07 16:32:45 -070088 mBuffers[i].clear();
Mathias Agopian48d819a2009-09-10 19:41:18 -070089 mWidth = mHeight = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080090 }
Mathias Agopian759fdb22009-07-02 17:33:40 -070091 mSurface.clear();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080092}
93
Mathias Agopian076b1cc2009-04-10 14:24:30 -070094sp<LayerBaseClient::Surface> Layer::createSurface() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080095{
96 return mSurface;
97}
98
Mathias Agopian9a112062009-04-17 19:36:26 -070099status_t Layer::ditch()
100{
Mathias Agopian0aa758d2009-04-22 15:23:34 -0700101 // the layer is not on screen anymore. free as much resources as possible
Mathias Agopian0aa758d2009-04-22 15:23:34 -0700102 destroy();
Mathias Agopian9a112062009-04-17 19:36:26 -0700103 return NO_ERROR;
104}
105
Mathias Agopianf9d93272009-06-19 17:00:27 -0700106status_t Layer::setBuffers( uint32_t w, uint32_t h,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800107 PixelFormat format, uint32_t flags)
108{
109 PixelFormatInfo info;
110 status_t err = getPixelFormatInfo(format, &info);
111 if (err) return err;
112
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700113 uint32_t bufferFlags = 0;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700114 if (flags & ISurfaceComposer::eSecure)
115 bufferFlags |= Buffer::SECURE;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800116
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700117 mFormat = format;
118 mWidth = w;
119 mHeight = h;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700120 mSecure = (bufferFlags & Buffer::SECURE) ? true : false;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800121 mNeedsBlending = (info.h_alpha - info.l_alpha) > 0;
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700122 mBufferFlags = bufferFlags;
123 for (size_t i=0 ; i<NUM_BUFFERS ; i++) {
124 mBuffers[i] = new Buffer();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800125 }
Mathias Agopian9a112062009-04-17 19:36:26 -0700126 mSurface = new SurfaceLayer(mFlinger, clientIndex(), this);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800127 return NO_ERROR;
128}
129
130void Layer::reloadTexture(const Region& dirty)
131{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700132 Mutex::Autolock _l(mLock);
133 sp<Buffer> buffer(getFrontBuffer());
Mathias Agopian0926f502009-05-04 14:17:04 -0700134 if (LIKELY(mFlags & DisplayHardware::DIRECT_TEXTURE)) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700135 int index = mFrontBufferIndex;
136 if (LIKELY(!mTextures[index].dirty)) {
137 glBindTexture(GL_TEXTURE_2D, mTextures[index].name);
138 } else {
139 // we need to recreate the texture
140 EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
141
142 // create the new texture name if needed
143 if (UNLIKELY(mTextures[index].name == -1U)) {
144 mTextures[index].name = createTexture();
145 } else {
146 glBindTexture(GL_TEXTURE_2D, mTextures[index].name);
147 }
148
149 // free the previous image
150 if (mTextures[index].image != EGL_NO_IMAGE_KHR) {
151 eglDestroyImageKHR(dpy, mTextures[index].image);
152 mTextures[index].image = EGL_NO_IMAGE_KHR;
153 }
154
155 // construct an EGL_NATIVE_BUFFER_ANDROID
156 android_native_buffer_t* clientBuf = buffer->getNativeBuffer();
157
158 // create the new EGLImageKHR
159 const EGLint attrs[] = {
160 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
161 EGL_NONE, EGL_NONE
162 };
163 mTextures[index].image = eglCreateImageKHR(
164 dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
165 (EGLClientBuffer)clientBuf, attrs);
166
167 LOGE_IF(mTextures[index].image == EGL_NO_IMAGE_KHR,
168 "eglCreateImageKHR() failed. err=0x%4x",
169 eglGetError());
170
171 if (mTextures[index].image != EGL_NO_IMAGE_KHR) {
172 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D,
173 (GLeglImageOES)mTextures[index].image);
174 GLint error = glGetError();
175 if (UNLIKELY(error != GL_NO_ERROR)) {
176 // this failed, for instance, because we don't support
177 // NPOT.
178 // FIXME: do something!
Mathias Agopian816d7d02009-09-14 18:10:30 -0700179 LOGD("layer=%p, glEGLImageTargetTexture2DOES(%d) "
180 "failed err=0x%04x",
181 this, mTextures[index].image, error);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700182 mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
183 } else {
184 // Everything went okay!
Mathias Agopian1fed11c2009-06-23 18:08:22 -0700185 mTextures[index].dirty = false;
186 mTextures[index].width = clientBuf->width;
187 mTextures[index].height = clientBuf->height;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700188 }
189 }
190 }
191 } else {
192 GGLSurface t;
Mathias Agopian0926f502009-05-04 14:17:04 -0700193 status_t res = buffer->lock(&t, GRALLOC_USAGE_SW_READ_RARELY);
194 LOGE_IF(res, "error %d (%s) locking buffer %p",
195 res, strerror(res), buffer.get());
196 if (res == NO_ERROR) {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700197 if (UNLIKELY(mTextures[0].name == -1U)) {
198 mTextures[0].name = createTexture();
199 }
Mathias Agopian1fed11c2009-06-23 18:08:22 -0700200 loadTexture(&mTextures[0], mTextures[0].name, dirty, t);
Mathias Agopian0926f502009-05-04 14:17:04 -0700201 buffer->unlock();
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700202 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800203 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800204}
205
206
207void Layer::onDraw(const Region& clip) const
208{
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700209 const int index = (mFlags & DisplayHardware::DIRECT_TEXTURE) ?
210 mFrontBufferIndex : 0;
211 GLuint textureName = mTextures[index].name;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700212 if (UNLIKELY(textureName == -1LU)) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700213 //LOGW("Layer %p doesn't have a texture", this);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800214 // the texture has not been created yet, this Layer has
215 // in fact never been drawn into. this happens frequently with
216 // SurfaceView.
217 clearWithOpenGL(clip);
218 return;
219 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700220
Mathias Agopian1fed11c2009-06-23 18:08:22 -0700221 drawWithOpenGL(clip, mTextures[index]);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800222}
223
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700224sp<SurfaceBuffer> Layer::requestBuffer(int index, int usage)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800225{
Mathias Agopian48d819a2009-09-10 19:41:18 -0700226 sp<Buffer> buffer;
227
228 // this ensures our client doesn't go away while we're accessing
229 // the shared area.
230 sp<Client> ourClient(client.promote());
231 if (ourClient == 0) {
232 // oops, the client is already gone
233 return buffer;
234 }
235
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700236 /*
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700237 * This is called from the client's Surface::dequeue(). This can happen
238 * at any time, especially while we're in the middle of using the
239 * buffer 'index' as our front buffer.
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700240 *
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700241 * Make sure the buffer we're resizing is not the front buffer and has been
242 * dequeued. Once this condition is asserted, we are guaranteed that this
243 * buffer cannot become the front buffer under our feet, since we're called
244 * from Surface::dequeue()
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700245 */
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700246 status_t err = lcblk->assertReallocate(index);
247 LOGE_IF(err, "assertReallocate(%d) failed (%s)", index, strerror(-err));
Mathias Agopian48d819a2009-09-10 19:41:18 -0700248 if (err != NO_ERROR) {
249 // the surface may have died
250 return buffer;
251 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800252
Mathias Agopian48d819a2009-09-10 19:41:18 -0700253 uint32_t w, h;
254 { // scope for the lock
255 Mutex::Autolock _l(mLock);
256 w = mWidth;
257 h = mHeight;
258 buffer = mBuffers[index];
259 mBuffers[index].clear();
260 }
261
262
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700263 if (buffer->getStrongCount() == 1) {
264 err = buffer->reallocate(w, h, mFormat, usage, mBufferFlags);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700265 } else {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700266 // here we have to reallocate a new buffer because we could have a
267 // client in our process with a reference to it (eg: status bar),
268 // and we can't release the handle under its feet.
269 buffer.clear();
270 buffer = new Buffer(w, h, mFormat, usage, mBufferFlags);
271 err = buffer->initCheck();
272 }
273
274 if (err || buffer->handle == 0) {
275 LOGE_IF(err || buffer->handle == 0,
276 "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d failed (%s)",
277 this, index, w, h, strerror(-err));
278 } else {
279 LOGD_IF(DEBUG_RESIZE,
280 "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d",
281 this, index, w, h);
282 }
283
284 if (err == NO_ERROR && buffer->handle != 0) {
Mathias Agopian48d819a2009-09-10 19:41:18 -0700285 Mutex::Autolock _l(mLock);
286 if (mWidth && mHeight) {
287 // and we have new buffer
288 mBuffers[index] = buffer;
289 // texture is now dirty...
290 mTextures[index].dirty = true;
291 } else {
292 // oops we got killed while we were allocating the buffer
293 buffer.clear();
294 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700295 }
296 return buffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800297}
298
299uint32_t Layer::doTransaction(uint32_t flags)
300{
301 const Layer::State& front(drawingState());
302 const Layer::State& temp(currentState());
303
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800304 // Index of the back buffer
305 const bool backbufferChanged = (front.w != temp.w) || (front.h != temp.h);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800306
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700307 if (backbufferChanged) {
308 // the size changed, we need to ask our client to request a new buffer
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800309 LOGD_IF(DEBUG_RESIZE,
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700310 "resize (layer=%p), requested (%dx%d), "
311 "drawing (%d,%d), (%dx%d), (%dx%d)",
312 this, int(temp.w), int(temp.h),
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800313 int(drawingState().w), int(drawingState().h),
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700314 int(mBuffers[0]->getWidth()), int(mBuffers[0]->getHeight()),
315 int(mBuffers[1]->getWidth()), int(mBuffers[1]->getHeight()));
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800316
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700317 // record the new size, form this point on, when the client request a
318 // buffer, it'll get the new size.
319 setDrawingSize(temp.w, temp.h);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800320
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700321 // all buffers need reallocation
322 lcblk->reallocate();
323
324 // recompute the visible region
325 // FIXME: ideally we would do that only when we have received
326 // a buffer of the right size
327 flags |= Layer::eVisibleRegion;
328 this->contentDirty = true;
329
330#if 0
331 // FIXME: handle freeze lock
332 // we're being resized and there is a freeze display request,
333 // acquire a freeze lock, so that the screen stays put
334 // until we've redrawn at the new size; this is to avoid
335 // glitches upon orientation changes.
336 if (mFlinger->hasFreezeRequest()) {
337 // if the surface is hidden, don't try to acquire the
338 // freeze lock, since hidden surfaces may never redraw
339 if (!(front.flags & ISurfaceComposer::eLayerHidden)) {
340 mFreezeLock = mFlinger->getFreezeLock();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800341 }
342 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700343#endif
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800344 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700345
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800346 if (temp.sequence != front.sequence) {
347 if (temp.flags & ISurfaceComposer::eLayerHidden || temp.alpha == 0) {
348 // this surface is now hidden, so it shouldn't hold a freeze lock
349 // (it may never redraw, which is fine if it is hidden)
350 mFreezeLock.clear();
351 }
352 }
353
354 return LayerBase::doTransaction(flags);
355}
356
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700357void Layer::setDrawingSize(uint32_t w, uint32_t h) {
358 Mutex::Autolock _l(mLock);
359 mWidth = w;
360 mHeight = h;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800361}
362
363// ----------------------------------------------------------------------------
364// pageflip handling...
365// ----------------------------------------------------------------------------
366
367void Layer::lockPageFlip(bool& recomputeVisibleRegions)
368{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700369 ssize_t buf = lcblk->retireAndLock();
370 if (buf < NO_ERROR) {
371 //LOGW("nothing to retire (%s)", strerror(-buf));
372 // NOTE: here the buffer is locked because we will used
373 // for composition later in the loop
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800374 return;
375 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700376
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700377 // we retired a buffer, which becomes the new front buffer
378 mFrontBufferIndex = buf;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800379
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700380 // get the dirty region
381 sp<Buffer> newFrontBuffer(getBuffer(buf));
382 const Region dirty(lcblk->getDirtyRegion(buf));
383 mPostedDirtyRegion = dirty.intersect( newFrontBuffer->getBounds() );
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700384
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700385 // FIXME: signal an event if we have more buffers waiting
386 // mFlinger->signalEvent();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800387
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700388 reloadTexture( mPostedDirtyRegion );
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800389}
390
391void Layer::unlockPageFlip(
392 const Transform& planeTransform, Region& outDirtyRegion)
393{
394 Region dirtyRegion(mPostedDirtyRegion);
395 if (!dirtyRegion.isEmpty()) {
396 mPostedDirtyRegion.clear();
397 // The dirty region is given in the layer's coordinate space
398 // transform the dirty region by the surface's transformation
399 // and the global transformation.
400 const Layer::State& s(drawingState());
401 const Transform tr(planeTransform * s.transform);
402 dirtyRegion = tr.transform(dirtyRegion);
403
404 // At this point, the dirty region is in screen space.
405 // Make sure it's constrained by the visible region (which
406 // is in screen space as well).
407 dirtyRegion.andSelf(visibleRegionScreen);
408 outDirtyRegion.orSelf(dirtyRegion);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800409 }
410}
411
412void Layer::finishPageFlip()
413{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700414 status_t err = lcblk->unlock( mFrontBufferIndex );
415 LOGE_IF(err!=NO_ERROR,
416 "layer %p, buffer=%d wasn't locked!",
417 this, mFrontBufferIndex);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800418}
419
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700420// ---------------------------------------------------------------------------
421
Mathias Agopian9a112062009-04-17 19:36:26 -0700422Layer::SurfaceLayer::SurfaceLayer(const sp<SurfaceFlinger>& flinger,
423 SurfaceID id, const sp<Layer>& owner)
424 : Surface(flinger, id, owner->getIdentity(), owner)
425{
426}
427
428Layer::SurfaceLayer::~SurfaceLayer()
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700429{
430}
431
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700432sp<SurfaceBuffer> Layer::SurfaceLayer::requestBuffer(int index, int usage)
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700433{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700434 sp<SurfaceBuffer> buffer;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700435 sp<Layer> owner(getOwner());
436 if (owner != 0) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700437 LOGE_IF(uint32_t(index)>=NUM_BUFFERS,
438 "getBuffer() index (%d) out of range", index);
439 if (uint32_t(index) < NUM_BUFFERS) {
440 buffer = owner->requestBuffer(index, usage);
441 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700442 }
443 return buffer;
444}
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800445
446// ---------------------------------------------------------------------------
447
448
449}; // namespace android