Loading include/gui/CpuConsumer.h +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,14 @@ class CpuConsumer : public ConsumerBase uint32_t scalingMode; int64_t timestamp; uint64_t frameNumber; // Values below are only valid when using // HAL_PIXEL_FORMAT_YCbCr_420_888, in which case LockedBuffer::data // contains the Y channel, and stride is the Y channel stride. For other // formats, these will all be 0. uint8_t *dataCb; uint8_t *dataCr; uint32_t chromaStride; uint32_t chromaStep; }; // Create a new CPU consumer. The maxLockedBuffers parameter specifies Loading include/ui/GraphicBuffer.h +3 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,9 @@ public: status_t lock(uint32_t usage, void** vaddr); status_t lock(uint32_t usage, const Rect& rect, void** vaddr); // For HAL_PIXEL_FORMAT_YCbCr_420_888 status_t lockYCbCr(uint32_t usage, android_ycbcr *ycbcr); status_t lockYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr); status_t unlock(); ANativeWindowBuffer* getNativeBuffer() const; Loading include/ui/GraphicBufferMapper.h +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ public: status_t lock(buffer_handle_t handle, int usage, const Rect& bounds, void** vaddr); status_t lockYCbCr(buffer_handle_t handle, int usage, const Rect& bounds, android_ycbcr *ycbcr); status_t unlock(buffer_handle_t handle); // dumps information about the mapping of this handle Loading libs/gui/CpuConsumer.cpp +35 −10 Original line number Diff line number Diff line Loading @@ -89,16 +89,34 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { } void *bufferPointer = NULL; android_ycbcr ycbcr = android_ycbcr(); if (mSlots[buf].mGraphicBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_YCbCr_420_888) { err = mSlots[buf].mGraphicBuffer->lockYCbCr( GraphicBuffer::USAGE_SW_READ_OFTEN, b.mCrop, &ycbcr); if (err != OK) { CC_LOGE("Unable to lock YCbCr buffer for CPU reading: %s (%d)", strerror(-err), err); return err; } bufferPointer = ycbcr.y; } else { err = mSlots[buf].mGraphicBuffer->lock( GraphicBuffer::USAGE_SW_READ_OFTEN, b.mCrop, &bufferPointer); if (bufferPointer != NULL && err != OK) { CC_LOGE("Unable to lock buffer for CPU reading: %s (%d)", strerror(-err), err); if (err != OK) { CC_LOGE("Unable to lock buffer for CPU reading: %s (%d)", strerror(-err), err); return err; } } size_t lockedIdx = 0; for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) { if (mAcquiredBuffers[lockedIdx].mSlot == Loading @@ -118,7 +136,9 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { nativeBuffer->width = mSlots[buf].mGraphicBuffer->getWidth(); nativeBuffer->height = mSlots[buf].mGraphicBuffer->getHeight(); nativeBuffer->format = mSlots[buf].mGraphicBuffer->getPixelFormat(); nativeBuffer->stride = mSlots[buf].mGraphicBuffer->getStride(); nativeBuffer->stride = (ycbcr.y != NULL) ? ycbcr.ystride : mSlots[buf].mGraphicBuffer->getStride(); nativeBuffer->crop = b.mCrop; nativeBuffer->transform = b.mTransform; Loading @@ -126,6 +146,11 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { nativeBuffer->timestamp = b.mTimestamp; nativeBuffer->frameNumber = b.mFrameNumber; nativeBuffer->dataCb = reinterpret_cast<uint8_t*>(ycbcr.cb); nativeBuffer->dataCr = reinterpret_cast<uint8_t*>(ycbcr.cr); nativeBuffer->chromaStride = ycbcr.cstride; nativeBuffer->chromaStep = ycbcr.chroma_step; mCurrentLockedBuffers++; return OK; Loading libs/ui/GraphicBuffer.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
include/gui/CpuConsumer.h +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,14 @@ class CpuConsumer : public ConsumerBase uint32_t scalingMode; int64_t timestamp; uint64_t frameNumber; // Values below are only valid when using // HAL_PIXEL_FORMAT_YCbCr_420_888, in which case LockedBuffer::data // contains the Y channel, and stride is the Y channel stride. For other // formats, these will all be 0. uint8_t *dataCb; uint8_t *dataCr; uint32_t chromaStride; uint32_t chromaStep; }; // Create a new CPU consumer. The maxLockedBuffers parameter specifies Loading
include/ui/GraphicBuffer.h +3 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,9 @@ public: status_t lock(uint32_t usage, void** vaddr); status_t lock(uint32_t usage, const Rect& rect, void** vaddr); // For HAL_PIXEL_FORMAT_YCbCr_420_888 status_t lockYCbCr(uint32_t usage, android_ycbcr *ycbcr); status_t lockYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr); status_t unlock(); ANativeWindowBuffer* getNativeBuffer() const; Loading
include/ui/GraphicBufferMapper.h +3 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ public: status_t lock(buffer_handle_t handle, int usage, const Rect& bounds, void** vaddr); status_t lockYCbCr(buffer_handle_t handle, int usage, const Rect& bounds, android_ycbcr *ycbcr); status_t unlock(buffer_handle_t handle); // dumps information about the mapping of this handle Loading
libs/gui/CpuConsumer.cpp +35 −10 Original line number Diff line number Diff line Loading @@ -89,16 +89,34 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { } void *bufferPointer = NULL; android_ycbcr ycbcr = android_ycbcr(); if (mSlots[buf].mGraphicBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_YCbCr_420_888) { err = mSlots[buf].mGraphicBuffer->lockYCbCr( GraphicBuffer::USAGE_SW_READ_OFTEN, b.mCrop, &ycbcr); if (err != OK) { CC_LOGE("Unable to lock YCbCr buffer for CPU reading: %s (%d)", strerror(-err), err); return err; } bufferPointer = ycbcr.y; } else { err = mSlots[buf].mGraphicBuffer->lock( GraphicBuffer::USAGE_SW_READ_OFTEN, b.mCrop, &bufferPointer); if (bufferPointer != NULL && err != OK) { CC_LOGE("Unable to lock buffer for CPU reading: %s (%d)", strerror(-err), err); if (err != OK) { CC_LOGE("Unable to lock buffer for CPU reading: %s (%d)", strerror(-err), err); return err; } } size_t lockedIdx = 0; for (; lockedIdx < mMaxLockedBuffers; lockedIdx++) { if (mAcquiredBuffers[lockedIdx].mSlot == Loading @@ -118,7 +136,9 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { nativeBuffer->width = mSlots[buf].mGraphicBuffer->getWidth(); nativeBuffer->height = mSlots[buf].mGraphicBuffer->getHeight(); nativeBuffer->format = mSlots[buf].mGraphicBuffer->getPixelFormat(); nativeBuffer->stride = mSlots[buf].mGraphicBuffer->getStride(); nativeBuffer->stride = (ycbcr.y != NULL) ? ycbcr.ystride : mSlots[buf].mGraphicBuffer->getStride(); nativeBuffer->crop = b.mCrop; nativeBuffer->transform = b.mTransform; Loading @@ -126,6 +146,11 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { nativeBuffer->timestamp = b.mTimestamp; nativeBuffer->frameNumber = b.mFrameNumber; nativeBuffer->dataCb = reinterpret_cast<uint8_t*>(ycbcr.cb); nativeBuffer->dataCr = reinterpret_cast<uint8_t*>(ycbcr.cr); nativeBuffer->chromaStride = ycbcr.cstride; nativeBuffer->chromaStep = ycbcr.chroma_step; mCurrentLockedBuffers++; return OK; Loading
libs/ui/GraphicBuffer.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -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); Loading