diff options
author | Jamie Gennis <jgennis@google.com> | 2010-10-07 13:46:55 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2010-10-10 13:09:46 -0700 |
commit | 309d3bb2f902163356f9d40b6d45c11b435d77a9 (patch) | |
tree | 493773c2aaf08d88a9c0c798d9c152be6ff4e77b /libs/ui/GraphicBuffer.cpp | |
parent | 0a49dee588ea476c9cb14bf0f6397bc3a19d4aeb (diff) | |
download | frameworks_native-309d3bb2f902163356f9d40b6d45c11b435d77a9.zip frameworks_native-309d3bb2f902163356f9d40b6d45c11b435d77a9.tar.gz frameworks_native-309d3bb2f902163356f9d40b6d45c11b435d77a9.tar.bz2 |
Move binder magic from the Surface class to GraphicBuffer.
- Register buffers with Gralloc when unflattening a GraphicBuffer (rather than
doing it in the Surface class).
- Add support for a GraphicBuffer that wraps an android_native_window_t*.
Change-Id: I029ac086111bbac800e5ca37eb505f558b718cd8
Diffstat (limited to 'libs/ui/GraphicBuffer.cpp')
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 519c277..436e064 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -77,6 +77,19 @@ GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h, handle = inHandle; } +GraphicBuffer::GraphicBuffer(android_native_buffer_t* buffer, bool keepOwnership) + : BASE(), mOwner(keepOwnership ? ownHandle : ownNone), + mBufferMapper(GraphicBufferMapper::get()), + mInitCheck(NO_ERROR), mIndex(-1), mWrappedBuffer(buffer) +{ + width = buffer->width; + height = buffer->height; + stride = buffer->stride; + format = buffer->format; + usage = buffer->usage; + handle = buffer->handle; +} + GraphicBuffer::~GraphicBuffer() { if (handle) { @@ -87,12 +100,14 @@ GraphicBuffer::~GraphicBuffer() void GraphicBuffer::free_handle() { if (mOwner == ownHandle) { + mBufferMapper.unregisterBuffer(handle); native_handle_close(handle); native_handle_delete(const_cast<native_handle*>(handle)); } else if (mOwner == ownData) { GraphicBufferAllocator& allocator(GraphicBufferAllocator::get()); allocator.free(handle); } + mWrappedBuffer = 0; } status_t GraphicBuffer::initCheck() const { @@ -253,6 +268,11 @@ status_t GraphicBuffer::unflatten(void const* buffer, size_t size, } mOwner = ownHandle; + + if (handle != 0) { + mBufferMapper.registerBuffer(handle); + } + return NO_ERROR; } |