blob: 8dfc2cf766b9d7cac896313e98a21edcf4b4eb8a [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 Agopian6d9f6982009-09-17 19:19:08 -0700179 LOGD("layer=%p, glEGLImageTargetTexture2DOES(%p) "
Mathias Agopian816d7d02009-09-14 18:10:30 -0700180 "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];
Mathias Agopian6d9f6982009-09-17 19:19:08 -0700259
260 // destroy() could have been called before we get here, we log it
261 // because it's uncommon, and the code below should handle it
262 LOGW_IF(buffer==0,
263 "mBuffers[%d] is null (mWidth=%d, mHeight=%d)",
264 index, w, h);
265
Mathias Agopian48d819a2009-09-10 19:41:18 -0700266 mBuffers[index].clear();
267 }
268
Mathias Agopian6d9f6982009-09-17 19:19:08 -0700269 if (buffer!=0 && buffer->getStrongCount() == 1) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700270 err = buffer->reallocate(w, h, mFormat, usage, mBufferFlags);
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700271 } else {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700272 // here we have to reallocate a new buffer because we could have a
273 // client in our process with a reference to it (eg: status bar),
274 // and we can't release the handle under its feet.
275 buffer.clear();
276 buffer = new Buffer(w, h, mFormat, usage, mBufferFlags);
277 err = buffer->initCheck();
278 }
279
280 if (err || buffer->handle == 0) {
281 LOGE_IF(err || buffer->handle == 0,
282 "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d failed (%s)",
283 this, index, w, h, strerror(-err));
284 } else {
285 LOGD_IF(DEBUG_RESIZE,
286 "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d",
287 this, index, w, h);
288 }
289
290 if (err == NO_ERROR && buffer->handle != 0) {
Mathias Agopian48d819a2009-09-10 19:41:18 -0700291 Mutex::Autolock _l(mLock);
292 if (mWidth && mHeight) {
293 // and we have new buffer
294 mBuffers[index] = buffer;
295 // texture is now dirty...
296 mTextures[index].dirty = true;
297 } else {
298 // oops we got killed while we were allocating the buffer
299 buffer.clear();
300 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700301 }
302 return buffer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800303}
304
305uint32_t Layer::doTransaction(uint32_t flags)
306{
307 const Layer::State& front(drawingState());
308 const Layer::State& temp(currentState());
309
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800310 // Index of the back buffer
311 const bool backbufferChanged = (front.w != temp.w) || (front.h != temp.h);
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700312 if (backbufferChanged) {
313 // the size changed, we need to ask our client to request a new buffer
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800314 LOGD_IF(DEBUG_RESIZE,
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700315 "resize (layer=%p), requested (%dx%d), "
316 "drawing (%d,%d), (%dx%d), (%dx%d)",
317 this, int(temp.w), int(temp.h),
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800318 int(drawingState().w), int(drawingState().h),
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700319 int(mBuffers[0]->getWidth()), int(mBuffers[0]->getHeight()),
320 int(mBuffers[1]->getWidth()), int(mBuffers[1]->getHeight()));
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800321
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700322 // record the new size, form this point on, when the client request a
323 // buffer, it'll get the new size.
324 setDrawingSize(temp.w, temp.h);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800325
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700326 // we're being resized and there is a freeze display request,
327 // acquire a freeze lock, so that the screen stays put
328 // until we've redrawn at the new size; this is to avoid
329 // glitches upon orientation changes.
330 if (mFlinger->hasFreezeRequest()) {
331 // if the surface is hidden, don't try to acquire the
332 // freeze lock, since hidden surfaces may never redraw
333 if (!(front.flags & ISurfaceComposer::eLayerHidden)) {
334 mFreezeLock = mFlinger->getFreezeLock();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800335 }
336 }
Mathias Agopiancaa600c2009-09-16 18:27:24 -0700337
338 // recompute the visible region
339 flags |= Layer::eVisibleRegion;
340 this->contentDirty = true;
341 // all buffers need reallocation
342 lcblk->reallocate();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800343 }
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700344
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800345 if (temp.sequence != front.sequence) {
346 if (temp.flags & ISurfaceComposer::eLayerHidden || temp.alpha == 0) {
347 // this surface is now hidden, so it shouldn't hold a freeze lock
348 // (it may never redraw, which is fine if it is hidden)
349 mFreezeLock.clear();
350 }
351 }
352
353 return LayerBase::doTransaction(flags);
354}
355
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700356void Layer::setDrawingSize(uint32_t w, uint32_t h) {
357 Mutex::Autolock _l(mLock);
358 mWidth = w;
359 mHeight = h;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800360}
361
362// ----------------------------------------------------------------------------
363// pageflip handling...
364// ----------------------------------------------------------------------------
365
366void Layer::lockPageFlip(bool& recomputeVisibleRegions)
367{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700368 ssize_t buf = lcblk->retireAndLock();
369 if (buf < NO_ERROR) {
370 //LOGW("nothing to retire (%s)", strerror(-buf));
371 // NOTE: here the buffer is locked because we will used
372 // for composition later in the loop
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800373 return;
374 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700375
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700376 // we retired a buffer, which becomes the new front buffer
377 mFrontBufferIndex = buf;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800378
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700379 // get the dirty region
380 sp<Buffer> newFrontBuffer(getBuffer(buf));
381 const Region dirty(lcblk->getDirtyRegion(buf));
382 mPostedDirtyRegion = dirty.intersect( newFrontBuffer->getBounds() );
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700383
Mathias Agopiancaa600c2009-09-16 18:27:24 -0700384
385 const Layer::State& front(drawingState());
386 if (newFrontBuffer->getWidth() == front.w &&
387 newFrontBuffer->getHeight() ==front.h) {
388 mFreezeLock.clear();
389 }
390
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700391 // FIXME: signal an event if we have more buffers waiting
392 // mFlinger->signalEvent();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800393
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700394 reloadTexture( mPostedDirtyRegion );
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800395}
396
397void Layer::unlockPageFlip(
398 const Transform& planeTransform, Region& outDirtyRegion)
399{
400 Region dirtyRegion(mPostedDirtyRegion);
401 if (!dirtyRegion.isEmpty()) {
402 mPostedDirtyRegion.clear();
403 // The dirty region is given in the layer's coordinate space
404 // transform the dirty region by the surface's transformation
405 // and the global transformation.
406 const Layer::State& s(drawingState());
407 const Transform tr(planeTransform * s.transform);
408 dirtyRegion = tr.transform(dirtyRegion);
409
410 // At this point, the dirty region is in screen space.
411 // Make sure it's constrained by the visible region (which
412 // is in screen space as well).
413 dirtyRegion.andSelf(visibleRegionScreen);
414 outDirtyRegion.orSelf(dirtyRegion);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800415 }
416}
417
418void Layer::finishPageFlip()
419{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700420 status_t err = lcblk->unlock( mFrontBufferIndex );
421 LOGE_IF(err!=NO_ERROR,
422 "layer %p, buffer=%d wasn't locked!",
423 this, mFrontBufferIndex);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800424}
425
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700426// ---------------------------------------------------------------------------
427
Mathias Agopian9a112062009-04-17 19:36:26 -0700428Layer::SurfaceLayer::SurfaceLayer(const sp<SurfaceFlinger>& flinger,
429 SurfaceID id, const sp<Layer>& owner)
430 : Surface(flinger, id, owner->getIdentity(), owner)
431{
432}
433
434Layer::SurfaceLayer::~SurfaceLayer()
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700435{
436}
437
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700438sp<SurfaceBuffer> Layer::SurfaceLayer::requestBuffer(int index, int usage)
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700439{
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700440 sp<SurfaceBuffer> buffer;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700441 sp<Layer> owner(getOwner());
442 if (owner != 0) {
Mathias Agopiancbb288b2009-09-07 16:32:45 -0700443 LOGE_IF(uint32_t(index)>=NUM_BUFFERS,
444 "getBuffer() index (%d) out of range", index);
445 if (uint32_t(index) < NUM_BUFFERS) {
446 buffer = owner->requestBuffer(index, usage);
447 }
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700448 }
449 return buffer;
450}
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800451
452// ---------------------------------------------------------------------------
453
454
455}; // namespace android