diff options
| author | 2020-07-17 15:22:25 +0000 | |
|---|---|---|
| committer | 2020-07-17 15:22:25 +0000 | |
| commit | 56892df0aa2edcfd2f0a00a1aad402a615cdebc5 (patch) | |
| tree | 1895482384a7a2f5bbb6a5389fd47ceffcf7be20 | |
| parent | 1816c43d4b0e54f3a9179870262472768052cdb5 (diff) | |
| parent | c7481bbeb35c8c64cf21e79794dafb615197dbf1 (diff) | |
Fix TextureView calling eglCreateImage with a destructed buffer am: df8a0739f7 am: c7481bbeb3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/12174650
Change-Id: I5b9de8180507101a14f89f80e40a18bc760842ed
| -rw-r--r-- | libs/nativedisplay/include/surfacetexture/surface_texture_platform.h | 2 | ||||
| -rw-r--r-- | libs/nativedisplay/surfacetexture/surface_texture.cpp | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h b/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h index e2d036bfb0..f3716674c5 100644 --- a/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h +++ b/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h @@ -79,6 +79,8 @@ typedef int (*ASurfaceTexture_fenceWait)(int fence, void* fencePassThroughHandle /** * ASurfaceTexture_dequeueBuffer returns the next available AHardwareBuffer. + * The caller gets ownership of the buffer and need to release it with + * AHardwareBuffer_release. */ AHardwareBuffer* ASurfaceTexture_dequeueBuffer(ASurfaceTexture* st, int* outSlotid, android_dataspace* outDataspace, diff --git a/libs/nativedisplay/surfacetexture/surface_texture.cpp b/libs/nativedisplay/surfacetexture/surface_texture.cpp index d1bcd8d1b1..ebe4484873 100644 --- a/libs/nativedisplay/surfacetexture/surface_texture.cpp +++ b/libs/nativedisplay/surfacetexture/surface_texture.cpp @@ -208,7 +208,15 @@ AHardwareBuffer* ASurfaceTexture_dequeueBuffer(ASurfaceTexture* st, int* outSlot *outNewContent = true; } } while (buffer.get() && (!queueEmpty)); - return reinterpret_cast<AHardwareBuffer*>(buffer.get()); + AHardwareBuffer* result = nullptr; + if (buffer.get()) { + result = buffer->toAHardwareBuffer(); + // add a reference to keep the hardware buffer alive, even if + // BufferQueueProducer is disconnected. This is needed, because + // sp reference is destroyed at the end of this function. + AHardwareBuffer_acquire(result); + } + return result; } } // namespace android |