The Android Open Source Project | 9066cfe | 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 | 9066cfe | 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 | |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 26 | #include <ui/GraphicBuffer.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | #include <ui/PixelFormat.h> |
Mathias Agopian | cbc4c9f | 2009-06-23 21:11:43 -0700 | [diff] [blame] | 28 | #include <ui/FramebufferNativeWindow.h> |
Mathias Agopian | 90daccf | 2009-11-05 23:08:00 -0800 | [diff] [blame] | 29 | #include <ui/Rect.h> |
| 30 | #include <ui/Region.h> |
Mathias Agopian | cbc4c9f | 2009-06-23 21:11:43 -0700 | [diff] [blame] | 31 | |
| 32 | #include <hardware/copybit.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
| 34 | #include "LayerBuffer.h" |
| 35 | #include "SurfaceFlinger.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | #include "DisplayHardware/DisplayHardware.h" |
| 37 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | namespace android { |
| 39 | |
| 40 | // --------------------------------------------------------------------------- |
| 41 | |
Mathias Agopian | 0b0722f | 2009-10-29 18:29:30 -0700 | [diff] [blame] | 42 | gralloc_module_t const* LayerBuffer::sGrallocModule = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | |
| 44 | // --------------------------------------------------------------------------- |
| 45 | |
| 46 | LayerBuffer::LayerBuffer(SurfaceFlinger* flinger, DisplayID display, |
Mathias Agopian | 593c05c | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 47 | const sp<Client>& client) |
| 48 | : LayerBaseClient(flinger, display, client), |
Mathias Agopian | 90daccf | 2009-11-05 23:08:00 -0800 | [diff] [blame] | 49 | mNeedsBlending(false), mBlitEngine(0) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | { |
| 51 | } |
| 52 | |
| 53 | LayerBuffer::~LayerBuffer() |
| 54 | { |
Mathias Agopian | 90daccf | 2009-11-05 23:08:00 -0800 | [diff] [blame] | 55 | if (mBlitEngine) { |
| 56 | copybit_close(mBlitEngine); |
| 57 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | } |
| 59 | |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 60 | void LayerBuffer::onFirstRef() |
| 61 | { |
Mathias Agopian | c660395 | 2009-06-23 20:06:46 -0700 | [diff] [blame] | 62 | LayerBaseClient::onFirstRef(); |
Mathias Agopian | 593c05c | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 63 | mSurface = new SurfaceLayerBuffer(mFlinger, this); |
Mathias Agopian | 0b0722f | 2009-10-29 18:29:30 -0700 | [diff] [blame] | 64 | |
| 65 | hw_module_t const* module = (hw_module_t const*)sGrallocModule; |
| 66 | if (!module) { |
| 67 | // NOTE: technically there is a race here, but it shouldn't |
| 68 | // cause any problem since hw_get_module() always returns |
| 69 | // the same value. |
| 70 | if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { |
| 71 | sGrallocModule = (gralloc_module_t const *)module; |
| 72 | } |
| 73 | } |
Mathias Agopian | 90daccf | 2009-11-05 23:08:00 -0800 | [diff] [blame] | 74 | |
| 75 | if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) { |
| 76 | copybit_open(module, &mBlitEngine); |
| 77 | } |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 80 | sp<LayerBaseClient::Surface> LayerBuffer::createSurface() const |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | { |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 82 | return mSurface; |
| 83 | } |
| 84 | |
| 85 | status_t LayerBuffer::ditch() |
| 86 | { |
| 87 | mSurface.clear(); |
| 88 | return NO_ERROR; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | bool LayerBuffer::needsBlending() const { |
| 92 | return mNeedsBlending; |
| 93 | } |
| 94 | |
| 95 | void LayerBuffer::setNeedsBlending(bool blending) { |
| 96 | mNeedsBlending = blending; |
| 97 | } |
| 98 | |
| 99 | void LayerBuffer::postBuffer(ssize_t offset) |
| 100 | { |
| 101 | sp<Source> source(getSource()); |
| 102 | if (source != 0) |
| 103 | source->postBuffer(offset); |
| 104 | } |
| 105 | |
| 106 | void LayerBuffer::unregisterBuffers() |
| 107 | { |
| 108 | sp<Source> source(clearSource()); |
| 109 | if (source != 0) |
| 110 | source->unregisterBuffers(); |
| 111 | } |
| 112 | |
| 113 | uint32_t LayerBuffer::doTransaction(uint32_t flags) |
| 114 | { |
| 115 | sp<Source> source(getSource()); |
| 116 | if (source != 0) |
| 117 | source->onTransaction(flags); |
Mathias Agopian | 4c29c94 | 2009-11-19 14:46:26 -0800 | [diff] [blame] | 118 | uint32_t res = LayerBase::doTransaction(flags); |
| 119 | // we always want filtering for these surfaces |
Mathias Agopian | 9237703 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 120 | mNeedsFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG); |
Mathias Agopian | 4c29c94 | 2009-11-19 14:46:26 -0800 | [diff] [blame] | 121 | return res; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | void LayerBuffer::unlockPageFlip(const Transform& planeTransform, |
| 125 | Region& outDirtyRegion) |
| 126 | { |
| 127 | // this code-path must be as tight as possible, it's called each time |
| 128 | // the screen is composited. |
| 129 | sp<Source> source(getSource()); |
| 130 | if (source != 0) |
| 131 | source->onVisibilityResolved(planeTransform); |
| 132 | LayerBase::unlockPageFlip(planeTransform, outDirtyRegion); |
| 133 | } |
| 134 | |
| 135 | void LayerBuffer::onDraw(const Region& clip) const |
| 136 | { |
| 137 | sp<Source> source(getSource()); |
| 138 | if (LIKELY(source != 0)) { |
| 139 | source->onDraw(clip); |
| 140 | } else { |
| 141 | clearWithOpenGL(clip); |
| 142 | } |
| 143 | } |
| 144 | |
Mathias Agopian | a280496 | 2009-09-08 23:52:08 -0700 | [diff] [blame] | 145 | void LayerBuffer::serverDestroy() |
| 146 | { |
| 147 | sp<Source> source(clearSource()); |
| 148 | if (source != 0) { |
| 149 | source->destroy(); |
| 150 | } |
| 151 | } |
| 152 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | /** |
| 154 | * This creates a "buffer" source for this surface |
| 155 | */ |
| 156 | status_t LayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers) |
| 157 | { |
| 158 | Mutex::Autolock _l(mLock); |
| 159 | if (mSource != 0) |
| 160 | return INVALID_OPERATION; |
| 161 | |
| 162 | sp<BufferSource> source = new BufferSource(*this, buffers); |
| 163 | |
| 164 | status_t result = source->getStatus(); |
| 165 | if (result == NO_ERROR) { |
| 166 | mSource = source; |
| 167 | } |
| 168 | return result; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * This creates an "overlay" source for this surface |
| 173 | */ |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 174 | sp<OverlayRef> LayerBuffer::createOverlay(uint32_t w, uint32_t h, int32_t f, |
| 175 | int32_t orientation) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | { |
| 177 | sp<OverlayRef> result; |
| 178 | Mutex::Autolock _l(mLock); |
| 179 | if (mSource != 0) |
| 180 | return result; |
| 181 | |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 182 | sp<OverlaySource> source = new OverlaySource(*this, &result, w, h, f, orientation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 183 | if (result != 0) { |
| 184 | mSource = source; |
| 185 | } |
| 186 | return result; |
| 187 | } |
| 188 | |
| 189 | sp<LayerBuffer::Source> LayerBuffer::getSource() const { |
| 190 | Mutex::Autolock _l(mLock); |
| 191 | return mSource; |
| 192 | } |
| 193 | |
| 194 | sp<LayerBuffer::Source> LayerBuffer::clearSource() { |
| 195 | sp<Source> source; |
| 196 | Mutex::Autolock _l(mLock); |
| 197 | source = mSource; |
| 198 | mSource.clear(); |
| 199 | return source; |
| 200 | } |
| 201 | |
| 202 | // ============================================================================ |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 203 | // LayerBuffer::SurfaceLayerBuffer |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | // ============================================================================ |
| 205 | |
Mathias Agopian | 593c05c | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 206 | LayerBuffer::SurfaceLayerBuffer::SurfaceLayerBuffer( |
| 207 | const sp<SurfaceFlinger>& flinger, const sp<LayerBuffer>& owner) |
| 208 | : LayerBaseClient::Surface(flinger, owner->getIdentity(), owner) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | { |
| 210 | } |
| 211 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 212 | LayerBuffer::SurfaceLayerBuffer::~SurfaceLayerBuffer() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 213 | { |
| 214 | unregisterBuffers(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 215 | } |
| 216 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 217 | status_t LayerBuffer::SurfaceLayerBuffer::registerBuffers( |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 218 | const ISurface::BufferHeap& buffers) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 219 | { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 220 | sp<LayerBuffer> owner(getOwner()); |
| 221 | if (owner != 0) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 222 | return owner->registerBuffers(buffers); |
| 223 | return NO_INIT; |
| 224 | } |
| 225 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 226 | void LayerBuffer::SurfaceLayerBuffer::postBuffer(ssize_t offset) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 228 | sp<LayerBuffer> owner(getOwner()); |
| 229 | if (owner != 0) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 230 | owner->postBuffer(offset); |
| 231 | } |
| 232 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 233 | void LayerBuffer::SurfaceLayerBuffer::unregisterBuffers() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 234 | { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 235 | sp<LayerBuffer> owner(getOwner()); |
| 236 | if (owner != 0) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 237 | owner->unregisterBuffers(); |
| 238 | } |
| 239 | |
Mathias Agopian | 9779b221 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 240 | sp<OverlayRef> LayerBuffer::SurfaceLayerBuffer::createOverlay( |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 241 | uint32_t w, uint32_t h, int32_t format, int32_t orientation) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | sp<OverlayRef> result; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 243 | sp<LayerBuffer> owner(getOwner()); |
| 244 | if (owner != 0) |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 245 | result = owner->createOverlay(w, h, format, orientation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | return result; |
| 247 | } |
| 248 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 249 | // ============================================================================ |
| 250 | // LayerBuffer::Buffer |
| 251 | // ============================================================================ |
| 252 | |
Mathias Agopian | 1d211f8 | 2010-03-08 11:14:20 -0800 | [diff] [blame] | 253 | LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, |
| 254 | ssize_t offset, size_t bufferSize) |
Mathias Agopian | 7323e54 | 2010-01-20 13:24:14 -0800 | [diff] [blame] | 255 | : mBufferHeap(buffers), mSupportsCopybit(false) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 256 | { |
| 257 | NativeBuffer& src(mNativeBuffer); |
Mathias Agopian | d86beb9 | 2009-12-02 16:23:11 -0800 | [diff] [blame] | 258 | src.crop.l = 0; |
| 259 | src.crop.t = 0; |
| 260 | src.crop.r = buffers.w; |
| 261 | src.crop.b = buffers.h; |
| 262 | |
| 263 | src.img.w = buffers.hor_stride ?: buffers.w; |
| 264 | src.img.h = buffers.ver_stride ?: buffers.h; |
| 265 | src.img.format = buffers.format; |
| 266 | src.img.base = (void*)(intptr_t(buffers.heap->base()) + offset); |
| 267 | src.img.handle = 0; |
Mathias Agopian | 2eab9d8 | 2009-06-24 16:55:59 -0700 | [diff] [blame] | 268 | |
Mathias Agopian | 0b0722f | 2009-10-29 18:29:30 -0700 | [diff] [blame] | 269 | gralloc_module_t const * module = LayerBuffer::getGrallocModule(); |
| 270 | if (module && module->perform) { |
| 271 | int err = module->perform(module, |
| 272 | GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER, |
Mathias Agopian | 1d211f8 | 2010-03-08 11:14:20 -0800 | [diff] [blame] | 273 | buffers.heap->heapID(), bufferSize, |
Mathias Agopian | 0b0722f | 2009-10-29 18:29:30 -0700 | [diff] [blame] | 274 | offset, buffers.heap->base(), |
| 275 | &src.img.handle); |
| 276 | |
Mathias Agopian | 7323e54 | 2010-01-20 13:24:14 -0800 | [diff] [blame] | 277 | // we can fail here is the passed buffer is purely software |
| 278 | mSupportsCopybit = (err == NO_ERROR); |
Mathias Agopian | 0b0722f | 2009-10-29 18:29:30 -0700 | [diff] [blame] | 279 | } |
Mathias Agopian | d86beb9 | 2009-12-02 16:23:11 -0800 | [diff] [blame] | 280 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | |
| 282 | LayerBuffer::Buffer::~Buffer() |
| 283 | { |
Mathias Agopian | 2eab9d8 | 2009-06-24 16:55:59 -0700 | [diff] [blame] | 284 | NativeBuffer& src(mNativeBuffer); |
Mathias Agopian | 0b0722f | 2009-10-29 18:29:30 -0700 | [diff] [blame] | 285 | if (src.img.handle) { |
| 286 | native_handle_delete(src.img.handle); |
| 287 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | // ============================================================================ |
| 291 | // LayerBuffer::Source |
| 292 | // LayerBuffer::BufferSource |
| 293 | // LayerBuffer::OverlaySource |
| 294 | // ============================================================================ |
| 295 | |
| 296 | LayerBuffer::Source::Source(LayerBuffer& layer) |
| 297 | : mLayer(layer) |
| 298 | { |
| 299 | } |
| 300 | LayerBuffer::Source::~Source() { |
| 301 | } |
| 302 | void LayerBuffer::Source::onDraw(const Region& clip) const { |
| 303 | } |
| 304 | void LayerBuffer::Source::onTransaction(uint32_t flags) { |
| 305 | } |
| 306 | void LayerBuffer::Source::onVisibilityResolved( |
| 307 | const Transform& planeTransform) { |
| 308 | } |
| 309 | void LayerBuffer::Source::postBuffer(ssize_t offset) { |
| 310 | } |
| 311 | void LayerBuffer::Source::unregisterBuffers() { |
| 312 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 313 | |
| 314 | // --------------------------------------------------------------------------- |
| 315 | |
| 316 | LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer, |
| 317 | const ISurface::BufferHeap& buffers) |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 318 | : Source(layer), mStatus(NO_ERROR), mBufferSize(0) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | { |
| 320 | if (buffers.heap == NULL) { |
| 321 | // this is allowed, but in this case, it is illegal to receive |
| 322 | // postBuffer(). The surface just erases the framebuffer with |
| 323 | // fully transparent pixels. |
| 324 | mBufferHeap = buffers; |
| 325 | mLayer.setNeedsBlending(false); |
| 326 | return; |
| 327 | } |
| 328 | |
| 329 | status_t err = (buffers.heap->heapID() >= 0) ? NO_ERROR : NO_INIT; |
| 330 | if (err != NO_ERROR) { |
| 331 | LOGE("LayerBuffer::BufferSource: invalid heap (%s)", strerror(err)); |
| 332 | mStatus = err; |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | PixelFormatInfo info; |
| 337 | err = getPixelFormatInfo(buffers.format, &info); |
| 338 | if (err != NO_ERROR) { |
| 339 | LOGE("LayerBuffer::BufferSource: invalid format %d (%s)", |
| 340 | buffers.format, strerror(err)); |
| 341 | mStatus = err; |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | if (buffers.hor_stride<0 || buffers.ver_stride<0) { |
| 346 | LOGE("LayerBuffer::BufferSource: invalid parameters " |
| 347 | "(w=%d, h=%d, xs=%d, ys=%d)", |
| 348 | buffers.w, buffers.h, buffers.hor_stride, buffers.ver_stride); |
| 349 | mStatus = BAD_VALUE; |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | mBufferHeap = buffers; |
| 354 | mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0); |
| 355 | mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride; |
| 356 | mLayer.forceVisibilityTransaction(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | LayerBuffer::BufferSource::~BufferSource() |
| 360 | { |
Mathias Agopian | 2d41cb9 | 2010-01-21 16:04:56 -0800 | [diff] [blame] | 361 | class MessageDestroyTexture : public MessageBase { |
| 362 | SurfaceFlinger* flinger; |
| 363 | GLuint name; |
| 364 | public: |
| 365 | MessageDestroyTexture( |
| 366 | SurfaceFlinger* flinger, GLuint name) |
| 367 | : flinger(flinger), name(name) { } |
| 368 | virtual bool handler() { |
| 369 | glDeleteTextures(1, &name); |
| 370 | return true; |
| 371 | } |
| 372 | }; |
| 373 | |
Mathias Agopian | 999543b | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 374 | if (mTexture.name != -1U) { |
Mathias Agopian | 2d41cb9 | 2010-01-21 16:04:56 -0800 | [diff] [blame] | 375 | // GL textures can only be destroyed from the GL thread |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 376 | getFlinger()->mEventQueue.postMessage( |
| 377 | new MessageDestroyTexture(getFlinger(), mTexture.name) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 378 | } |
Mathias Agopian | 9042b45 | 2009-10-26 20:12:37 -0700 | [diff] [blame] | 379 | if (mTexture.image != EGL_NO_IMAGE_KHR) { |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 380 | EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); |
Mathias Agopian | 9042b45 | 2009-10-26 20:12:37 -0700 | [diff] [blame] | 381 | eglDestroyImageKHR(dpy, mTexture.image); |
Mathias Agopian | 68eeb80 | 2009-06-25 15:39:25 -0700 | [diff] [blame] | 382 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | void LayerBuffer::BufferSource::postBuffer(ssize_t offset) |
| 386 | { |
| 387 | ISurface::BufferHeap buffers; |
| 388 | { // scope for the lock |
Mathias Agopian | b34d143 | 2009-09-08 20:02:47 -0700 | [diff] [blame] | 389 | Mutex::Autolock _l(mBufferSourceLock); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | buffers = mBufferHeap; |
| 391 | if (buffers.heap != 0) { |
| 392 | const size_t memorySize = buffers.heap->getSize(); |
| 393 | if ((size_t(offset) + mBufferSize) > memorySize) { |
| 394 | LOGE("LayerBuffer::BufferSource::postBuffer() " |
| 395 | "invalid buffer (offset=%d, size=%d, heap-size=%d", |
| 396 | int(offset), int(mBufferSize), int(memorySize)); |
| 397 | return; |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | sp<Buffer> buffer; |
| 403 | if (buffers.heap != 0) { |
Mathias Agopian | 1d211f8 | 2010-03-08 11:14:20 -0800 | [diff] [blame] | 404 | buffer = new LayerBuffer::Buffer(buffers, offset, mBufferSize); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 405 | if (buffer->getStatus() != NO_ERROR) |
| 406 | buffer.clear(); |
| 407 | setBuffer(buffer); |
| 408 | mLayer.invalidate(); |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | void LayerBuffer::BufferSource::unregisterBuffers() |
| 413 | { |
Mathias Agopian | b34d143 | 2009-09-08 20:02:47 -0700 | [diff] [blame] | 414 | Mutex::Autolock _l(mBufferSourceLock); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 415 | mBufferHeap.heap.clear(); |
| 416 | mBuffer.clear(); |
| 417 | mLayer.invalidate(); |
| 418 | } |
| 419 | |
| 420 | sp<LayerBuffer::Buffer> LayerBuffer::BufferSource::getBuffer() const |
| 421 | { |
Mathias Agopian | b34d143 | 2009-09-08 20:02:47 -0700 | [diff] [blame] | 422 | Mutex::Autolock _l(mBufferSourceLock); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 423 | return mBuffer; |
| 424 | } |
| 425 | |
| 426 | void LayerBuffer::BufferSource::setBuffer(const sp<LayerBuffer::Buffer>& buffer) |
| 427 | { |
Mathias Agopian | b34d143 | 2009-09-08 20:02:47 -0700 | [diff] [blame] | 428 | Mutex::Autolock _l(mBufferSourceLock); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 429 | mBuffer = buffer; |
| 430 | } |
| 431 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 432 | void LayerBuffer::BufferSource::onDraw(const Region& clip) const |
| 433 | { |
Mathias Agopian | 999543b | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 434 | sp<Buffer> ourBuffer(getBuffer()); |
| 435 | if (UNLIKELY(ourBuffer == 0)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 436 | // nothing to do, we don't have a buffer |
| 437 | mLayer.clearWithOpenGL(clip); |
| 438 | return; |
| 439 | } |
| 440 | |
Mathias Agopian | cbc4c9f | 2009-06-23 21:11:43 -0700 | [diff] [blame] | 441 | status_t err = NO_ERROR; |
| 442 | NativeBuffer src(ourBuffer->getBuffer()); |
Mathias Agopian | a280496 | 2009-09-08 23:52:08 -0700 | [diff] [blame] | 443 | const Rect transformedBounds(mLayer.getTransformedBounds()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 444 | |
Mathias Agopian | 9042b45 | 2009-10-26 20:12:37 -0700 | [diff] [blame] | 445 | #if defined(EGL_ANDROID_image_native_buffer) |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 446 | if (GLExtensions::getInstance().haveDirectTexture()) { |
Mathias Agopian | fcdd394 | 2010-02-04 17:13:06 -0800 | [diff] [blame] | 447 | err = INVALID_OPERATION; |
| 448 | if (ourBuffer->supportsCopybit()) { |
Mathias Agopian | fcdd394 | 2010-02-04 17:13:06 -0800 | [diff] [blame] | 449 | copybit_device_t* copybit = mLayer.mBlitEngine; |
| 450 | if (copybit && err != NO_ERROR) { |
| 451 | // create our EGLImageKHR the first time |
| 452 | err = initTempBuffer(); |
| 453 | if (err == NO_ERROR) { |
| 454 | // NOTE: Assume the buffer is allocated with the proper USAGE flags |
| 455 | const NativeBuffer& dst(mTempBuffer); |
| 456 | region_iterator clip(Region(Rect(dst.crop.r, dst.crop.b))); |
| 457 | copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0); |
| 458 | copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF); |
| 459 | copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE); |
| 460 | err = copybit->stretch(copybit, &dst.img, &src.img, |
| 461 | &dst.crop, &src.crop, &clip); |
| 462 | if (err != NO_ERROR) { |
| 463 | clearTempBufferImage(); |
| 464 | } |
| 465 | } |
| 466 | } |
Mathias Agopian | 90daccf | 2009-11-05 23:08:00 -0800 | [diff] [blame] | 467 | } |
Mathias Agopian | cbc4c9f | 2009-06-23 21:11:43 -0700 | [diff] [blame] | 468 | } |
Mathias Agopian | 26c28b1 | 2009-06-24 22:39:26 -0700 | [diff] [blame] | 469 | #endif |
Mathias Agopian | 9042b45 | 2009-10-26 20:12:37 -0700 | [diff] [blame] | 470 | else { |
| 471 | err = INVALID_OPERATION; |
| 472 | } |
| 473 | |
| 474 | if (err != NO_ERROR) { |
Mathias Agopian | f007a2f | 2009-10-28 21:00:29 -0700 | [diff] [blame] | 475 | // slower fallback |
Mathias Agopian | 999543b | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 476 | GGLSurface t; |
| 477 | t.version = sizeof(GGLSurface); |
| 478 | t.width = src.crop.r; |
| 479 | t.height = src.crop.b; |
| 480 | t.stride = src.img.w; |
| 481 | t.vstride= src.img.h; |
| 482 | t.format = src.img.format; |
Mathias Agopian | 2eab9d8 | 2009-06-24 16:55:59 -0700 | [diff] [blame] | 483 | t.data = (GGLubyte*)src.img.base; |
Mathias Agopian | 999543b | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 484 | const Region dirty(Rect(t.width, t.height)); |
Mathias Agopian | 9f2c4fd | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 485 | mTextureManager.loadTexture(&mTexture, dirty, t); |
Mathias Agopian | dff8e58 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 486 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 487 | |
Mathias Agopian | e96aa3e | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 488 | mLayer.setBufferTransform(mBufferHeap.transform); |
Mathias Agopian | 9042b45 | 2009-10-26 20:12:37 -0700 | [diff] [blame] | 489 | mLayer.drawWithOpenGL(clip, mTexture); |
| 490 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 491 | |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 492 | status_t LayerBuffer::BufferSource::initTempBuffer() const |
| 493 | { |
| 494 | // figure out the size we need now |
| 495 | const ISurface::BufferHeap& buffers(mBufferHeap); |
| 496 | uint32_t w = mLayer.mTransformedBounds.width(); |
| 497 | uint32_t h = mLayer.mTransformedBounds.height(); |
Omprakash Dhyade | 92bd90d | 2010-08-05 16:28:37 -0700 | [diff] [blame] | 498 | if (mLayer.getOrientation() & (Transform::ROT_90 | Transform::ROT_270)) { |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 499 | int t = w; w = h; h = t; |
| 500 | } |
| 501 | |
Mathias Agopian | d23fa27 | 2010-01-20 14:31:53 -0800 | [diff] [blame] | 502 | // we're in the copybit case, so make sure we can handle this blit |
| 503 | // we don't have to keep the aspect ratio here |
| 504 | copybit_device_t* copybit = mLayer.mBlitEngine; |
| 505 | const int down = copybit->get(copybit, COPYBIT_MINIFICATION_LIMIT); |
| 506 | const int up = copybit->get(copybit, COPYBIT_MAGNIFICATION_LIMIT); |
| 507 | if (buffers.w > w*down) w = buffers.w / down; |
| 508 | else if (w > buffers.w*up) w = buffers.w*up; |
| 509 | if (buffers.h > h*down) h = buffers.h / down; |
| 510 | else if (h > buffers.h*up) h = buffers.h*up; |
| 511 | |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 512 | if (mTexture.image != EGL_NO_IMAGE_KHR) { |
| 513 | // we have an EGLImage, make sure the needed size didn't change |
| 514 | if (w!=mTexture.width || h!= mTexture.height) { |
| 515 | // delete the EGLImage and texture |
Mathias Agopian | d2832fb4 | 2010-01-20 13:56:07 -0800 | [diff] [blame] | 516 | clearTempBufferImage(); |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 517 | } else { |
| 518 | // we're good, we have an EGLImageKHR and it's (still) the |
| 519 | // right size |
| 520 | return NO_ERROR; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | // figure out if we need linear filtering |
| 525 | if (buffers.w * h == buffers.h * w) { |
| 526 | // same pixel area, don't use filtering |
Mathias Agopian | 9237703 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 527 | mLayer.mNeedsFiltering = false; |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | // Allocate a temporary buffer and create the corresponding EGLImageKHR |
Mathias Agopian | 08956f0 | 2010-02-12 18:50:28 -0800 | [diff] [blame] | 531 | // once the EGLImage has been created we don't need the |
| 532 | // graphic buffer reference anymore. |
| 533 | sp<GraphicBuffer> buffer = new GraphicBuffer( |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 534 | w, h, HAL_PIXEL_FORMAT_RGB_565, |
| 535 | GraphicBuffer::USAGE_HW_TEXTURE | |
| 536 | GraphicBuffer::USAGE_HW_2D); |
| 537 | |
Mathias Agopian | 08956f0 | 2010-02-12 18:50:28 -0800 | [diff] [blame] | 538 | status_t err = buffer->initCheck(); |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 539 | if (err == NO_ERROR) { |
| 540 | NativeBuffer& dst(mTempBuffer); |
Mathias Agopian | 08956f0 | 2010-02-12 18:50:28 -0800 | [diff] [blame] | 541 | dst.img.w = buffer->getStride(); |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 542 | dst.img.h = h; |
Mathias Agopian | 08956f0 | 2010-02-12 18:50:28 -0800 | [diff] [blame] | 543 | dst.img.format = buffer->getPixelFormat(); |
| 544 | dst.img.handle = (native_handle_t *)buffer->handle; |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 545 | dst.img.base = 0; |
| 546 | dst.crop.l = 0; |
| 547 | dst.crop.t = 0; |
| 548 | dst.crop.r = w; |
| 549 | dst.crop.b = h; |
| 550 | |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 551 | EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); |
Mathias Agopian | 9f2c4fd | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 552 | err = mTextureManager.initEglImage(&mTexture, dpy, buffer); |
Mathias Agopian | 76169da | 2009-12-09 14:32:56 -0800 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | return err; |
| 556 | } |
| 557 | |
Mathias Agopian | d2832fb4 | 2010-01-20 13:56:07 -0800 | [diff] [blame] | 558 | void LayerBuffer::BufferSource::clearTempBufferImage() const |
| 559 | { |
Mathias Agopian | a1a1798 | 2010-01-21 16:27:30 -0800 | [diff] [blame] | 560 | // delete the image |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 561 | EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); |
Mathias Agopian | d2832fb4 | 2010-01-20 13:56:07 -0800 | [diff] [blame] | 562 | eglDestroyImageKHR(dpy, mTexture.image); |
Mathias Agopian | a1a1798 | 2010-01-21 16:27:30 -0800 | [diff] [blame] | 563 | |
| 564 | // and the associated texture (recreate a name) |
| 565 | glDeleteTextures(1, &mTexture.name); |
Mathias Agopian | d2832fb4 | 2010-01-20 13:56:07 -0800 | [diff] [blame] | 566 | Texture defaultTexture; |
| 567 | mTexture = defaultTexture; |
Mathias Agopian | d2832fb4 | 2010-01-20 13:56:07 -0800 | [diff] [blame] | 568 | } |
| 569 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 570 | // --------------------------------------------------------------------------- |
| 571 | |
| 572 | LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer, |
| 573 | sp<OverlayRef>* overlayRef, |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 574 | uint32_t w, uint32_t h, int32_t format, int32_t orientation) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 575 | : Source(layer), mVisibilityChanged(false), |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 576 | mOverlay(0), mOverlayHandle(0), mOverlayDevice(0), mOrientation(orientation) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 577 | { |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 578 | overlay_control_device_t* overlay_dev = getFlinger()->getOverlayEngine(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 579 | if (overlay_dev == NULL) { |
| 580 | // overlays not supported |
| 581 | return; |
| 582 | } |
| 583 | |
| 584 | mOverlayDevice = overlay_dev; |
| 585 | overlay_t* overlay = overlay_dev->createOverlay(overlay_dev, w, h, format); |
| 586 | if (overlay == NULL) { |
| 587 | // couldn't create the overlay (no memory? no more overlays?) |
| 588 | return; |
| 589 | } |
| 590 | |
| 591 | // enable dithering... |
| 592 | overlay_dev->setParameter(overlay_dev, overlay, |
| 593 | OVERLAY_DITHER, OVERLAY_ENABLE); |
| 594 | |
| 595 | mOverlay = overlay; |
| 596 | mWidth = overlay->w; |
| 597 | mHeight = overlay->h; |
| 598 | mFormat = overlay->format; |
| 599 | mWidthStride = overlay->w_stride; |
| 600 | mHeightStride = overlay->h_stride; |
Rebecca Schultz Zavin | 43ab763 | 2009-07-21 16:17:59 -0700 | [diff] [blame] | 601 | mInitialized = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 602 | |
| 603 | mOverlayHandle = overlay->getHandleRef(overlay); |
| 604 | |
Mathias Agopian | a280496 | 2009-09-08 23:52:08 -0700 | [diff] [blame] | 605 | sp<OverlayChannel> channel = new OverlayChannel( &layer ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 606 | |
| 607 | *overlayRef = new OverlayRef(mOverlayHandle, channel, |
| 608 | mWidth, mHeight, mFormat, mWidthStride, mHeightStride); |
Mathias Agopian | 781953d | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 609 | getFlinger()->signalEvent(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | LayerBuffer::OverlaySource::~OverlaySource() |
| 613 | { |
| 614 | if (mOverlay && mOverlayDevice) { |
| 615 | overlay_control_device_t* overlay_dev = mOverlayDevice; |
| 616 | overlay_dev->destroyOverlay(overlay_dev, mOverlay); |
| 617 | } |
| 618 | } |
| 619 | |
Rebecca Schultz Zavin | 7ac5e69 | 2009-07-20 21:18:04 -0700 | [diff] [blame] | 620 | void LayerBuffer::OverlaySource::onDraw(const Region& clip) const |
| 621 | { |
Mathias Agopian | 8ae0384 | 2009-09-15 19:31:28 -0700 | [diff] [blame] | 622 | // this would be where the color-key would be set, should we need it. |
Mathias Agopian | 0d3c006 | 2010-05-26 22:26:12 -0700 | [diff] [blame] | 623 | GLclampf red = 0; |
| 624 | GLclampf green = 0; |
| 625 | GLclampf blue = 0; |
Rebecca Schultz Zavin | c854678 | 2009-09-01 23:06:45 -0700 | [diff] [blame] | 626 | mLayer.clearWithOpenGL(clip, red, green, blue, 0); |
Rebecca Schultz Zavin | 7ac5e69 | 2009-07-20 21:18:04 -0700 | [diff] [blame] | 627 | } |
| 628 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 629 | void LayerBuffer::OverlaySource::onTransaction(uint32_t flags) |
| 630 | { |
| 631 | const Layer::State& front(mLayer.drawingState()); |
| 632 | const Layer::State& temp(mLayer.currentState()); |
| 633 | if (temp.sequence != front.sequence) { |
| 634 | mVisibilityChanged = true; |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | void LayerBuffer::OverlaySource::onVisibilityResolved( |
| 639 | const Transform& planeTransform) |
| 640 | { |
| 641 | // this code-path must be as tight as possible, it's called each time |
| 642 | // the screen is composited. |
| 643 | if (UNLIKELY(mOverlay != 0)) { |
Rebecca Schultz Zavin | 43ab763 | 2009-07-21 16:17:59 -0700 | [diff] [blame] | 644 | if (mVisibilityChanged || !mInitialized) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 645 | mVisibilityChanged = false; |
Rebecca Schultz Zavin | 43ab763 | 2009-07-21 16:17:59 -0700 | [diff] [blame] | 646 | mInitialized = true; |
Mathias Agopian | a280496 | 2009-09-08 23:52:08 -0700 | [diff] [blame] | 647 | const Rect bounds(mLayer.getTransformedBounds()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 648 | int x = bounds.left; |
| 649 | int y = bounds.top; |
| 650 | int w = bounds.width(); |
| 651 | int h = bounds.height(); |
| 652 | |
| 653 | // we need a lock here to protect "destroy" |
Mathias Agopian | b34d143 | 2009-09-08 20:02:47 -0700 | [diff] [blame] | 654 | Mutex::Autolock _l(mOverlaySourceLock); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 655 | if (mOverlay) { |
| 656 | overlay_control_device_t* overlay_dev = mOverlayDevice; |
| 657 | overlay_dev->setPosition(overlay_dev, mOverlay, x,y,w,h); |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 658 | // we need to combine the layer orientation and the |
| 659 | // user-requested orientation. |
| 660 | Transform finalTransform = Transform(mOrientation) * |
| 661 | Transform(mLayer.getOrientation()); |
Rebecca Schultz Zavin | 43ab763 | 2009-07-21 16:17:59 -0700 | [diff] [blame] | 662 | overlay_dev->setParameter(overlay_dev, mOverlay, |
Chih-Chung Chang | e1ceec2 | 2010-01-21 17:31:06 -0800 | [diff] [blame] | 663 | OVERLAY_TRANSFORM, finalTransform.getOrientation()); |
Rebecca Schultz Zavin | 7ac5e69 | 2009-07-20 21:18:04 -0700 | [diff] [blame] | 664 | overlay_dev->commit(overlay_dev, mOverlay); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
Mathias Agopian | a280496 | 2009-09-08 23:52:08 -0700 | [diff] [blame] | 670 | void LayerBuffer::OverlaySource::destroy() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 671 | { |
| 672 | // we need a lock here to protect "onVisibilityResolved" |
Mathias Agopian | b34d143 | 2009-09-08 20:02:47 -0700 | [diff] [blame] | 673 | Mutex::Autolock _l(mOverlaySourceLock); |
Mathias Agopian | a280496 | 2009-09-08 23:52:08 -0700 | [diff] [blame] | 674 | if (mOverlay && mOverlayDevice) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 675 | overlay_control_device_t* overlay_dev = mOverlayDevice; |
| 676 | overlay_dev->destroyOverlay(overlay_dev, mOverlay); |
| 677 | mOverlay = 0; |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | // --------------------------------------------------------------------------- |
| 682 | }; // namespace android |