Merge "sdm: color-manager: Frame capture interface."

This commit is contained in:
Linux Build Service Account
2016-08-13 13:52:16 -07:00
committed by Gerrit - the friendly Code Review server
3 changed files with 53 additions and 41 deletions

View File

@@ -144,16 +144,16 @@ struct PPDisplayAPIPayload {
return ret; return ret;
} }
DisplayError CreatePayloadBytes(uint8_t *output, uint32_t size_in_bytes) { DisplayError CreatePayloadBytes(uint32_t size_in_bytes, uint8_t **output) {
DisplayError ret = kErrorNone; DisplayError ret = kErrorNone;
payload = new uint8_t[size_in_bytes](); payload = new uint8_t[size_in_bytes]();
if (!payload) { if (!payload) {
ret = kErrorMemory; ret = kErrorMemory;
output = NULL; *output = NULL;
} else { } else {
this->size = size_in_bytes; this->size = size_in_bytes;
output = payload; *output = payload;
own_payload = true; own_payload = true;
} }
return ret; return ret;

View File

@@ -343,14 +343,12 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
if (enable) { if (enable) {
std::memset(&buffer_info, 0x00, sizeof(buffer_info)); std::memset(&buffer_info, 0x00, sizeof(buffer_info));
hwc_display->GetFrameBufferResolution(&buffer_info.buffer_config.width, hwc_display->GetPanelResolution(&buffer_info.buffer_config.width,
&buffer_info.buffer_config.height); &buffer_info.buffer_config.height);
if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) { if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) {
buffer_info.buffer_config.format = kFormatRGB888; buffer_info.buffer_config.format = kFormatRGB888;
} else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) { } else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) {
// TODO(user): Complete the implementation buffer_info.buffer_config.format = kFormatRGBA1010102;
DLOGE("RGB 10-bit format NOT supported");
return -EFAULT;
} else { } else {
DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format); DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format);
return -EFAULT; return -EFAULT;
@@ -370,7 +368,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
ret = buffer_allocator_->AllocateBuffer(&buffer_info); ret = buffer_allocator_->AllocateBuffer(&buffer_info);
if (ret != 0) { if (ret != 0) {
DLOGE("Buffer allocation failed. ret: %d", ret); DLOGE("Buffer allocation failed. ret: %d", ret);
delete[] buffer_allocator_; delete buffer_allocator_;
buffer_allocator_ = NULL; buffer_allocator_ = NULL;
return -ENOMEM; return -ENOMEM;
} else { } else {
@@ -382,7 +380,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
DLOGE("mmap failed. err = %d", errno); DLOGE("mmap failed. err = %d", errno);
frame_capture_data->buffer = NULL; frame_capture_data->buffer = NULL;
ret = buffer_allocator_->FreeBuffer(&buffer_info); ret = buffer_allocator_->FreeBuffer(&buffer_info);
delete[] buffer_allocator_; delete buffer_allocator_;
buffer_allocator_ = NULL; buffer_allocator_ = NULL;
return -EFAULT; return -EFAULT;
} else { } else {
@@ -390,22 +388,30 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
frame_capture_data->buffer_stride = buffer_info.alloc_buffer_info.stride; frame_capture_data->buffer_stride = buffer_info.alloc_buffer_info.stride;
frame_capture_data->buffer_size = buffer_info.alloc_buffer_info.size; frame_capture_data->buffer_size = buffer_info.alloc_buffer_info.size;
} }
// TODO(user): Call HWC interface to provide the buffer and rectangle information ret = hwc_display->FrameCaptureAsync(buffer_info, 1);
if (ret < 0) {
DLOGE("FrameCaptureAsync failed. ret = %d", ret);
}
} }
} else { } else {
if (frame_capture_data->buffer != NULL) { ret = hwc_display->GetFrameCaptureStatus();
if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) { if (!ret) {
DLOGE("munmap failed. err = %d", errno); if (frame_capture_data->buffer != NULL) {
if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) {
DLOGE("munmap failed. err = %d", errno);
}
} }
} if (buffer_allocator_ != NULL) {
if (buffer_allocator_ != NULL) { std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData)); ret = buffer_allocator_->FreeBuffer(&buffer_info);
ret = buffer_allocator_->FreeBuffer(&buffer_info); if (ret != 0) {
if (ret != 0) { DLOGE("FreeBuffer failed. ret = %d", ret);
DLOGE("FreeBuffer failed. ret = %d", ret); }
delete buffer_allocator_;
buffer_allocator_ = NULL;
} }
delete[] buffer_allocator_; } else {
buffer_allocator_ = NULL; DLOGE("GetFrameCaptureStatus failed. ret = %d", ret);
} }
} }
return ret; return ret;

View File

@@ -200,14 +200,12 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
if (enable) { if (enable) {
std::memset(&buffer_info, 0x00, sizeof(buffer_info)); std::memset(&buffer_info, 0x00, sizeof(buffer_info));
hwc_display->GetFrameBufferResolution(&buffer_info.buffer_config.width, hwc_display->GetPanelResolution(&buffer_info.buffer_config.width,
&buffer_info.buffer_config.height); &buffer_info.buffer_config.height);
if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) { if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) {
buffer_info.buffer_config.format = kFormatRGB888; buffer_info.buffer_config.format = kFormatRGB888;
} else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) { } else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) {
// TODO(user): Complete the implementation buffer_info.buffer_config.format = kFormatRGBA1010102;
DLOGE("RGB 10-bit format NOT supported");
return -EFAULT;
} else { } else {
DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format); DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format);
return -EFAULT; return -EFAULT;
@@ -227,7 +225,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
ret = buffer_allocator_->AllocateBuffer(&buffer_info); ret = buffer_allocator_->AllocateBuffer(&buffer_info);
if (ret != 0) { if (ret != 0) {
DLOGE("Buffer allocation failed. ret: %d", ret); DLOGE("Buffer allocation failed. ret: %d", ret);
delete[] buffer_allocator_; delete buffer_allocator_;
buffer_allocator_ = NULL; buffer_allocator_ = NULL;
return -ENOMEM; return -ENOMEM;
} else { } else {
@@ -238,7 +236,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
DLOGE("mmap failed. err = %d", errno); DLOGE("mmap failed. err = %d", errno);
frame_capture_data->buffer = NULL; frame_capture_data->buffer = NULL;
ret = buffer_allocator_->FreeBuffer(&buffer_info); ret = buffer_allocator_->FreeBuffer(&buffer_info);
delete[] buffer_allocator_; delete buffer_allocator_;
buffer_allocator_ = NULL; buffer_allocator_ = NULL;
return -EFAULT; return -EFAULT;
} else { } else {
@@ -246,22 +244,30 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
frame_capture_data->buffer_stride = buffer_info.alloc_buffer_info.stride; frame_capture_data->buffer_stride = buffer_info.alloc_buffer_info.stride;
frame_capture_data->buffer_size = buffer_info.alloc_buffer_info.size; frame_capture_data->buffer_size = buffer_info.alloc_buffer_info.size;
} }
// TODO(user): Call HWC interface to provide the buffer and rectangle information ret = hwc_display->FrameCaptureAsync(buffer_info, 1);
if (ret < 0) {
DLOGE("FrameCaptureAsync failed. ret = %d", ret);
}
} }
} else { } else {
if (frame_capture_data->buffer != NULL) { ret = hwc_display->GetFrameCaptureStatus();
if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) { if (!ret) {
DLOGE("munmap failed. err = %d", errno); if (frame_capture_data->buffer != NULL) {
if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) {
DLOGE("munmap failed. err = %d", errno);
}
} }
} if (buffer_allocator_ != NULL) {
if (buffer_allocator_ != NULL) { std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData)); ret = buffer_allocator_->FreeBuffer(&buffer_info);
ret = buffer_allocator_->FreeBuffer(&buffer_info); if (ret != 0) {
if (ret != 0) { DLOGE("FreeBuffer failed. ret = %d", ret);
DLOGE("FreeBuffer failed. ret = %d", ret); }
delete buffer_allocator_;
buffer_allocator_ = NULL;
} }
delete[] buffer_allocator_; } else {
buffer_allocator_ = NULL; DLOGE("GetFrameCaptureStatus failed. ret = %d", ret);
} }
} }
return ret; return ret;