diff options
Diffstat (limited to 'libs/ui')
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 21 | ||||
-rw-r--r-- | libs/ui/GraphicBufferMapper.cpp | 14 |
2 files changed, 35 insertions, 0 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index b9cab85..580788d 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -174,6 +174,27 @@ status_t GraphicBuffer::lock(uint32_t usage, const Rect& rect, void** vaddr) return res; } +status_t GraphicBuffer::lockYCbCr(uint32_t usage, android_ycbcr *ycbcr) +{ + const Rect lockBounds(width, height); + status_t res = lockYCbCr(usage, lockBounds, ycbcr); + return res; +} + +status_t GraphicBuffer::lockYCbCr(uint32_t usage, const Rect& rect, + android_ycbcr *ycbcr) +{ + if (rect.left < 0 || rect.right > this->width || + rect.top < 0 || rect.bottom > this->height) { + ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)", + rect.left, rect.top, rect.right, rect.bottom, + this->width, this->height); + return BAD_VALUE; + } + status_t res = getBufferMapper().lockYCbCr(handle, usage, rect, ycbcr); + return res; +} + status_t GraphicBuffer::unlock() { status_t res = getBufferMapper().unlock(handle); diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp index 967da98..a4cfce2 100644 --- a/libs/ui/GraphicBufferMapper.cpp +++ b/libs/ui/GraphicBufferMapper.cpp @@ -84,6 +84,20 @@ status_t GraphicBufferMapper::lock(buffer_handle_t handle, return err; } +status_t GraphicBufferMapper::lockYCbCr(buffer_handle_t handle, + int usage, const Rect& bounds, android_ycbcr *ycbcr) +{ + ATRACE_CALL(); + status_t err; + + err = mAllocMod->lock_ycbcr(mAllocMod, handle, usage, + bounds.left, bounds.top, bounds.width(), bounds.height(), + ycbcr); + + ALOGW_IF(err, "lock(...) failed %d (%s)", err, strerror(-err)); + return err; +} + status_t GraphicBufferMapper::unlock(buffer_handle_t handle) { ATRACE_CALL(); |