The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | #include <stdlib.h> |
| 18 | #include <stdint.h> |
| 19 | #include <math.h> |
| 20 | #include <sys/types.h> |
| 21 | |
| 22 | #include <utils/Errors.h> |
| 23 | #include <utils/Log.h> |
| 24 | #include <utils/StopWatch.h> |
| 25 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <ui/PixelFormat.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
| 28 | #include "LayerBuffer.h" |
| 29 | #include "SurfaceFlinger.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | #include "DisplayHardware/DisplayHardware.h" |
| 31 | |
| 32 | |
| 33 | namespace android { |
| 34 | |
| 35 | // --------------------------------------------------------------------------- |
| 36 | |
| 37 | const uint32_t LayerBuffer::typeInfo = LayerBaseClient::typeInfo | 0x20; |
| 38 | const char* const LayerBuffer::typeID = "LayerBuffer"; |
| 39 | |
| 40 | // --------------------------------------------------------------------------- |
| 41 | |
| 42 | LayerBuffer::LayerBuffer(SurfaceFlinger* flinger, DisplayID display, |
| 43 | Client* client, int32_t i) |
| 44 | : LayerBaseClient(flinger, display, client, i), |
| 45 | mNeedsBlending(false) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | LayerBuffer::~LayerBuffer() |
| 50 | { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 53 | sp<LayerBaseClient::Surface> LayerBuffer::createSurface() const |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 55 | return new SurfaceBuffer(clientIndex(), |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | const_cast<LayerBuffer *>(this)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | bool LayerBuffer::needsBlending() const { |
| 60 | return mNeedsBlending; |
| 61 | } |
| 62 | |
| 63 | void LayerBuffer::setNeedsBlending(bool blending) { |
| 64 | mNeedsBlending = blending; |
| 65 | } |
| 66 | |
| 67 | void LayerBuffer::postBuffer(ssize_t offset) |
| 68 | { |
| 69 | sp<Source> source(getSource()); |
| 70 | if (source != 0) |
| 71 | source->postBuffer(offset); |
| 72 | } |
| 73 | |
| 74 | void LayerBuffer::unregisterBuffers() |
| 75 | { |
| 76 | sp<Source> source(clearSource()); |
| 77 | if (source != 0) |
| 78 | source->unregisterBuffers(); |
| 79 | } |
| 80 | |
| 81 | uint32_t LayerBuffer::doTransaction(uint32_t flags) |
| 82 | { |
| 83 | sp<Source> source(getSource()); |
| 84 | if (source != 0) |
| 85 | source->onTransaction(flags); |
| 86 | return LayerBase::doTransaction(flags); |
| 87 | } |
| 88 | |
| 89 | void LayerBuffer::unlockPageFlip(const Transform& planeTransform, |
| 90 | Region& outDirtyRegion) |
| 91 | { |
| 92 | // this code-path must be as tight as possible, it's called each time |
| 93 | // the screen is composited. |
| 94 | sp<Source> source(getSource()); |
| 95 | if (source != 0) |
| 96 | source->onVisibilityResolved(planeTransform); |
| 97 | LayerBase::unlockPageFlip(planeTransform, outDirtyRegion); |
| 98 | } |
| 99 | |
| 100 | void LayerBuffer::onDraw(const Region& clip) const |
| 101 | { |
| 102 | sp<Source> source(getSource()); |
| 103 | if (LIKELY(source != 0)) { |
| 104 | source->onDraw(clip); |
| 105 | } else { |
| 106 | clearWithOpenGL(clip); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | bool LayerBuffer::transformed() const |
| 111 | { |
| 112 | sp<Source> source(getSource()); |
| 113 | if (LIKELY(source != 0)) |
| 114 | return source->transformed(); |
| 115 | return false; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * This creates a "buffer" source for this surface |
| 120 | */ |
| 121 | status_t LayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers) |
| 122 | { |
| 123 | Mutex::Autolock _l(mLock); |
| 124 | if (mSource != 0) |
| 125 | return INVALID_OPERATION; |
| 126 | |
| 127 | sp<BufferSource> source = new BufferSource(*this, buffers); |
| 128 | |
| 129 | status_t result = source->getStatus(); |
| 130 | if (result == NO_ERROR) { |
| 131 | mSource = source; |
| 132 | } |
| 133 | return result; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * This creates an "overlay" source for this surface |
| 138 | */ |
| 139 | sp<OverlayRef> LayerBuffer::createOverlay(uint32_t w, uint32_t h, int32_t f) |
| 140 | { |
| 141 | sp<OverlayRef> result; |
| 142 | Mutex::Autolock _l(mLock); |
| 143 | if (mSource != 0) |
| 144 | return result; |
| 145 | |
| 146 | sp<OverlaySource> source = new OverlaySource(*this, &result, w, h, f); |
| 147 | if (result != 0) { |
| 148 | mSource = source; |
| 149 | } |
| 150 | return result; |
| 151 | } |
| 152 | |
| 153 | sp<LayerBuffer::Source> LayerBuffer::getSource() const { |
| 154 | Mutex::Autolock _l(mLock); |
| 155 | return mSource; |
| 156 | } |
| 157 | |
| 158 | sp<LayerBuffer::Source> LayerBuffer::clearSource() { |
| 159 | sp<Source> source; |
| 160 | Mutex::Autolock _l(mLock); |
| 161 | source = mSource; |
| 162 | mSource.clear(); |
| 163 | return source; |
| 164 | } |
| 165 | |
| 166 | // ============================================================================ |
| 167 | // LayerBuffer::SurfaceBuffer |
| 168 | // ============================================================================ |
| 169 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 170 | LayerBuffer::SurfaceBuffer::SurfaceBuffer(SurfaceID id, |
| 171 | const sp<LayerBuffer>& owner) |
| 172 | : LayerBaseClient::Surface(id, owner->getIdentity(), owner) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | { |
| 174 | } |
| 175 | |
| 176 | LayerBuffer::SurfaceBuffer::~SurfaceBuffer() |
| 177 | { |
| 178 | unregisterBuffers(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | } |
| 180 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 181 | status_t LayerBuffer::SurfaceBuffer::registerBuffers( |
| 182 | const ISurface::BufferHeap& buffers) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 183 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 184 | sp<LayerBuffer> owner(getOwner()); |
| 185 | if (owner != 0) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 186 | return owner->registerBuffers(buffers); |
| 187 | return NO_INIT; |
| 188 | } |
| 189 | |
| 190 | void LayerBuffer::SurfaceBuffer::postBuffer(ssize_t offset) |
| 191 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 192 | sp<LayerBuffer> owner(getOwner()); |
| 193 | if (owner != 0) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | owner->postBuffer(offset); |
| 195 | } |
| 196 | |
| 197 | void LayerBuffer::SurfaceBuffer::unregisterBuffers() |
| 198 | { |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 199 | sp<LayerBuffer> owner(getOwner()); |
| 200 | if (owner != 0) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | owner->unregisterBuffers(); |
| 202 | } |
| 203 | |
| 204 | sp<OverlayRef> LayerBuffer::SurfaceBuffer::createOverlay( |
| 205 | uint32_t w, uint32_t h, int32_t format) { |
| 206 | sp<OverlayRef> result; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 207 | sp<LayerBuffer> owner(getOwner()); |
| 208 | if (owner != 0) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | result = owner->createOverlay(w, h, format); |
| 210 | return result; |
| 211 | } |
| 212 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 213 | // ============================================================================ |
| 214 | // LayerBuffer::Buffer |
| 215 | // ============================================================================ |
| 216 | |
| 217 | LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset) |
| 218 | : mBufferHeap(buffers) |
| 219 | { |
| 220 | NativeBuffer& src(mNativeBuffer); |
| 221 | src.crop.l = 0; |
| 222 | src.crop.t = 0; |
| 223 | src.crop.r = buffers.w; |
| 224 | src.crop.b = buffers.h; |
| 225 | src.img.w = buffers.hor_stride ?: buffers.w; |
| 226 | src.img.h = buffers.ver_stride ?: buffers.h; |
| 227 | src.img.format = buffers.format; |
| 228 | src.img.offset = offset; |
| 229 | src.img.base = buffers.heap->base(); |
| 230 | src.img.fd = buffers.heap->heapID(); |
| 231 | } |
| 232 | |
| 233 | LayerBuffer::Buffer::~Buffer() |
| 234 | { |
| 235 | } |
| 236 | |
| 237 | // ============================================================================ |
| 238 | // LayerBuffer::Source |
| 239 | // LayerBuffer::BufferSource |
| 240 | // LayerBuffer::OverlaySource |
| 241 | // ============================================================================ |
| 242 | |
| 243 | LayerBuffer::Source::Source(LayerBuffer& layer) |
| 244 | : mLayer(layer) |
| 245 | { |
| 246 | } |
| 247 | LayerBuffer::Source::~Source() { |
| 248 | } |
| 249 | void LayerBuffer::Source::onDraw(const Region& clip) const { |
| 250 | } |
| 251 | void LayerBuffer::Source::onTransaction(uint32_t flags) { |
| 252 | } |
| 253 | void LayerBuffer::Source::onVisibilityResolved( |
| 254 | const Transform& planeTransform) { |
| 255 | } |
| 256 | void LayerBuffer::Source::postBuffer(ssize_t offset) { |
| 257 | } |
| 258 | void LayerBuffer::Source::unregisterBuffers() { |
| 259 | } |
| 260 | bool LayerBuffer::Source::transformed() const { |
| 261 | return mLayer.mTransformed; |
| 262 | } |
| 263 | |
| 264 | // --------------------------------------------------------------------------- |
| 265 | |
| 266 | LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer, |
| 267 | const ISurface::BufferHeap& buffers) |
| 268 | : Source(layer), mStatus(NO_ERROR), |
| 269 | mBufferSize(0), mTextureName(-1U) |
| 270 | { |
| 271 | if (buffers.heap == NULL) { |
| 272 | // this is allowed, but in this case, it is illegal to receive |
| 273 | // postBuffer(). The surface just erases the framebuffer with |
| 274 | // fully transparent pixels. |
| 275 | mBufferHeap = buffers; |
| 276 | mLayer.setNeedsBlending(false); |
| 277 | return; |
| 278 | } |
| 279 | |
| 280 | status_t err = (buffers.heap->heapID() >= 0) ? NO_ERROR : NO_INIT; |
| 281 | if (err != NO_ERROR) { |
| 282 | LOGE("LayerBuffer::BufferSource: invalid heap (%s)", strerror(err)); |
| 283 | mStatus = err; |
| 284 | return; |
| 285 | } |
| 286 | |
| 287 | PixelFormatInfo info; |
| 288 | err = getPixelFormatInfo(buffers.format, &info); |
| 289 | if (err != NO_ERROR) { |
| 290 | LOGE("LayerBuffer::BufferSource: invalid format %d (%s)", |
| 291 | buffers.format, strerror(err)); |
| 292 | mStatus = err; |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | if (buffers.hor_stride<0 || buffers.ver_stride<0) { |
| 297 | LOGE("LayerBuffer::BufferSource: invalid parameters " |
| 298 | "(w=%d, h=%d, xs=%d, ys=%d)", |
| 299 | buffers.w, buffers.h, buffers.hor_stride, buffers.ver_stride); |
| 300 | mStatus = BAD_VALUE; |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | mBufferHeap = buffers; |
| 305 | mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0); |
| 306 | mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride; |
| 307 | mLayer.forceVisibilityTransaction(); |
| 308 | |
| 309 | } |
| 310 | |
| 311 | LayerBuffer::BufferSource::~BufferSource() |
| 312 | { |
| 313 | if (mTextureName != -1U) { |
| 314 | LayerBase::deletedTextures.add(mTextureName); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | void LayerBuffer::BufferSource::postBuffer(ssize_t offset) |
| 319 | { |
| 320 | ISurface::BufferHeap buffers; |
| 321 | { // scope for the lock |
| 322 | Mutex::Autolock _l(mLock); |
| 323 | buffers = mBufferHeap; |
| 324 | if (buffers.heap != 0) { |
| 325 | const size_t memorySize = buffers.heap->getSize(); |
| 326 | if ((size_t(offset) + mBufferSize) > memorySize) { |
| 327 | LOGE("LayerBuffer::BufferSource::postBuffer() " |
| 328 | "invalid buffer (offset=%d, size=%d, heap-size=%d", |
| 329 | int(offset), int(mBufferSize), int(memorySize)); |
| 330 | return; |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | sp<Buffer> buffer; |
| 336 | if (buffers.heap != 0) { |
| 337 | buffer = new LayerBuffer::Buffer(buffers, offset); |
| 338 | if (buffer->getStatus() != NO_ERROR) |
| 339 | buffer.clear(); |
| 340 | setBuffer(buffer); |
| 341 | mLayer.invalidate(); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | void LayerBuffer::BufferSource::unregisterBuffers() |
| 346 | { |
| 347 | Mutex::Autolock _l(mLock); |
| 348 | mBufferHeap.heap.clear(); |
| 349 | mBuffer.clear(); |
| 350 | mLayer.invalidate(); |
| 351 | } |
| 352 | |
| 353 | sp<LayerBuffer::Buffer> LayerBuffer::BufferSource::getBuffer() const |
| 354 | { |
| 355 | Mutex::Autolock _l(mLock); |
| 356 | return mBuffer; |
| 357 | } |
| 358 | |
| 359 | void LayerBuffer::BufferSource::setBuffer(const sp<LayerBuffer::Buffer>& buffer) |
| 360 | { |
| 361 | Mutex::Autolock _l(mLock); |
| 362 | mBuffer = buffer; |
| 363 | } |
| 364 | |
| 365 | bool LayerBuffer::BufferSource::transformed() const |
| 366 | { |
| 367 | return mBufferHeap.transform ? true : Source::transformed(); |
| 368 | } |
| 369 | |
| 370 | void LayerBuffer::BufferSource::onDraw(const Region& clip) const |
| 371 | { |
| 372 | sp<Buffer> buffer(getBuffer()); |
| 373 | if (UNLIKELY(buffer == 0)) { |
| 374 | // nothing to do, we don't have a buffer |
| 375 | mLayer.clearWithOpenGL(clip); |
| 376 | return; |
| 377 | } |
| 378 | |
| 379 | status_t err = NO_ERROR; |
| 380 | NativeBuffer src(buffer->getBuffer()); |
| 381 | const Rect& transformedBounds = mLayer.getTransformedBounds(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 382 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 383 | // FIXME: We should model this after the overlay stuff |
| 384 | |
| 385 | if (UNLIKELY(mTextureName == -1LU)) { |
| 386 | mTextureName = mLayer.createTexture(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 387 | } |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 388 | GLuint w = 0; |
| 389 | GLuint h = 0; |
| 390 | GGLSurface t; |
| 391 | t.version = sizeof(GGLSurface); |
| 392 | t.width = src.crop.r; |
| 393 | t.height = src.crop.b; |
| 394 | t.stride = src.img.w; |
| 395 | t.vstride= src.img.h; |
| 396 | t.format = src.img.format; |
| 397 | t.data = (GGLubyte*)(intptr_t(src.img.base) + src.img.offset); |
| 398 | const Region dirty(Rect(t.width, t.height)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame^] | 400 | // FIXME: Use EGLImage extension for this |
| 401 | mLayer.loadTexture(dirty, mTextureName, t, w, h); |
| 402 | mLayer.drawWithOpenGL(clip, mTextureName, t, mBufferHeap.transform); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | |
| 406 | // --------------------------------------------------------------------------- |
| 407 | |
| 408 | LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer, |
| 409 | sp<OverlayRef>* overlayRef, |
| 410 | uint32_t w, uint32_t h, int32_t format) |
| 411 | : Source(layer), mVisibilityChanged(false), |
| 412 | mOverlay(0), mOverlayHandle(0), mOverlayDevice(0) |
| 413 | { |
| 414 | overlay_control_device_t* overlay_dev = mLayer.mFlinger->getOverlayEngine(); |
| 415 | if (overlay_dev == NULL) { |
| 416 | // overlays not supported |
| 417 | return; |
| 418 | } |
| 419 | |
| 420 | mOverlayDevice = overlay_dev; |
| 421 | overlay_t* overlay = overlay_dev->createOverlay(overlay_dev, w, h, format); |
| 422 | if (overlay == NULL) { |
| 423 | // couldn't create the overlay (no memory? no more overlays?) |
| 424 | return; |
| 425 | } |
| 426 | |
| 427 | // enable dithering... |
| 428 | overlay_dev->setParameter(overlay_dev, overlay, |
| 429 | OVERLAY_DITHER, OVERLAY_ENABLE); |
| 430 | |
| 431 | mOverlay = overlay; |
| 432 | mWidth = overlay->w; |
| 433 | mHeight = overlay->h; |
| 434 | mFormat = overlay->format; |
| 435 | mWidthStride = overlay->w_stride; |
| 436 | mHeightStride = overlay->h_stride; |
| 437 | |
| 438 | mOverlayHandle = overlay->getHandleRef(overlay); |
| 439 | |
| 440 | // NOTE: here it's okay to acquire a reference to "this"m as long as |
| 441 | // the reference is not released before we leave the ctor. |
| 442 | sp<OverlayChannel> channel = new OverlayChannel(this); |
| 443 | |
| 444 | *overlayRef = new OverlayRef(mOverlayHandle, channel, |
| 445 | mWidth, mHeight, mFormat, mWidthStride, mHeightStride); |
| 446 | } |
| 447 | |
| 448 | LayerBuffer::OverlaySource::~OverlaySource() |
| 449 | { |
| 450 | if (mOverlay && mOverlayDevice) { |
| 451 | overlay_control_device_t* overlay_dev = mOverlayDevice; |
| 452 | overlay_dev->destroyOverlay(overlay_dev, mOverlay); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | void LayerBuffer::OverlaySource::onTransaction(uint32_t flags) |
| 457 | { |
| 458 | const Layer::State& front(mLayer.drawingState()); |
| 459 | const Layer::State& temp(mLayer.currentState()); |
| 460 | if (temp.sequence != front.sequence) { |
| 461 | mVisibilityChanged = true; |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | void LayerBuffer::OverlaySource::onVisibilityResolved( |
| 466 | const Transform& planeTransform) |
| 467 | { |
| 468 | // this code-path must be as tight as possible, it's called each time |
| 469 | // the screen is composited. |
| 470 | if (UNLIKELY(mOverlay != 0)) { |
| 471 | if (mVisibilityChanged) { |
| 472 | mVisibilityChanged = false; |
| 473 | const Rect& bounds = mLayer.getTransformedBounds(); |
| 474 | int x = bounds.left; |
| 475 | int y = bounds.top; |
| 476 | int w = bounds.width(); |
| 477 | int h = bounds.height(); |
| 478 | |
| 479 | // we need a lock here to protect "destroy" |
| 480 | Mutex::Autolock _l(mLock); |
| 481 | if (mOverlay) { |
| 482 | overlay_control_device_t* overlay_dev = mOverlayDevice; |
| 483 | overlay_dev->setPosition(overlay_dev, mOverlay, x,y,w,h); |
| 484 | overlay_dev->setParameter(overlay_dev, mOverlay, |
| 485 | OVERLAY_TRANSFORM, mLayer.getOrientation()); |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | void LayerBuffer::OverlaySource::serverDestroy() |
| 492 | { |
| 493 | mLayer.clearSource(); |
| 494 | destroyOverlay(); |
| 495 | } |
| 496 | |
| 497 | void LayerBuffer::OverlaySource::destroyOverlay() |
| 498 | { |
| 499 | // we need a lock here to protect "onVisibilityResolved" |
| 500 | Mutex::Autolock _l(mLock); |
| 501 | if (mOverlay) { |
| 502 | overlay_control_device_t* overlay_dev = mOverlayDevice; |
| 503 | overlay_dev->destroyOverlay(overlay_dev, mOverlay); |
| 504 | mOverlay = 0; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | // --------------------------------------------------------------------------- |
| 509 | }; // namespace android |