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;
}
DisplayError CreatePayloadBytes(uint8_t *output, uint32_t size_in_bytes) {
DisplayError CreatePayloadBytes(uint32_t size_in_bytes, uint8_t **output) {
DisplayError ret = kErrorNone;
payload = new uint8_t[size_in_bytes]();
if (!payload) {
ret = kErrorMemory;
output = NULL;
*output = NULL;
} else {
this->size = size_in_bytes;
output = payload;
*output = payload;
own_payload = true;
}
return ret;

View File

@@ -343,14 +343,12 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
if (enable) {
std::memset(&buffer_info, 0x00, sizeof(buffer_info));
hwc_display->GetFrameBufferResolution(&buffer_info.buffer_config.width,
&buffer_info.buffer_config.height);
hwc_display->GetPanelResolution(&buffer_info.buffer_config.width,
&buffer_info.buffer_config.height);
if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) {
buffer_info.buffer_config.format = kFormatRGB888;
} else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) {
// TODO(user): Complete the implementation
DLOGE("RGB 10-bit format NOT supported");
return -EFAULT;
buffer_info.buffer_config.format = kFormatRGBA1010102;
} else {
DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format);
return -EFAULT;
@@ -370,7 +368,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
ret = buffer_allocator_->AllocateBuffer(&buffer_info);
if (ret != 0) {
DLOGE("Buffer allocation failed. ret: %d", ret);
delete[] buffer_allocator_;
delete buffer_allocator_;
buffer_allocator_ = NULL;
return -ENOMEM;
} else {
@@ -382,7 +380,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
DLOGE("mmap failed. err = %d", errno);
frame_capture_data->buffer = NULL;
ret = buffer_allocator_->FreeBuffer(&buffer_info);
delete[] buffer_allocator_;
delete buffer_allocator_;
buffer_allocator_ = NULL;
return -EFAULT;
} 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_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 {
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);
ret = hwc_display->GetFrameCaptureStatus();
if (!ret) {
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) {
std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
ret = buffer_allocator_->FreeBuffer(&buffer_info);
if (ret != 0) {
DLOGE("FreeBuffer failed. ret = %d", ret);
if (buffer_allocator_ != NULL) {
std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
ret = buffer_allocator_->FreeBuffer(&buffer_info);
if (ret != 0) {
DLOGE("FreeBuffer failed. ret = %d", ret);
}
delete buffer_allocator_;
buffer_allocator_ = NULL;
}
delete[] buffer_allocator_;
buffer_allocator_ = NULL;
} else {
DLOGE("GetFrameCaptureStatus failed. ret = %d", ret);
}
}
return ret;

View File

@@ -200,14 +200,12 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
if (enable) {
std::memset(&buffer_info, 0x00, sizeof(buffer_info));
hwc_display->GetFrameBufferResolution(&buffer_info.buffer_config.width,
&buffer_info.buffer_config.height);
hwc_display->GetPanelResolution(&buffer_info.buffer_config.width,
&buffer_info.buffer_config.height);
if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) {
buffer_info.buffer_config.format = kFormatRGB888;
} else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) {
// TODO(user): Complete the implementation
DLOGE("RGB 10-bit format NOT supported");
return -EFAULT;
buffer_info.buffer_config.format = kFormatRGBA1010102;
} else {
DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format);
return -EFAULT;
@@ -227,7 +225,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
ret = buffer_allocator_->AllocateBuffer(&buffer_info);
if (ret != 0) {
DLOGE("Buffer allocation failed. ret: %d", ret);
delete[] buffer_allocator_;
delete buffer_allocator_;
buffer_allocator_ = NULL;
return -ENOMEM;
} else {
@@ -238,7 +236,7 @@ int HWCColorManager::SetFrameCapture(void *params, bool enable, HWCDisplay *hwc_
DLOGE("mmap failed. err = %d", errno);
frame_capture_data->buffer = NULL;
ret = buffer_allocator_->FreeBuffer(&buffer_info);
delete[] buffer_allocator_;
delete buffer_allocator_;
buffer_allocator_ = NULL;
return -EFAULT;
} 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_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 {
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);
ret = hwc_display->GetFrameCaptureStatus();
if (!ret) {
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) {
std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
ret = buffer_allocator_->FreeBuffer(&buffer_info);
if (ret != 0) {
DLOGE("FreeBuffer failed. ret = %d", ret);
if (buffer_allocator_ != NULL) {
std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
ret = buffer_allocator_->FreeBuffer(&buffer_info);
if (ret != 0) {
DLOGE("FreeBuffer failed. ret = %d", ret);
}
delete buffer_allocator_;
buffer_allocator_ = NULL;
}
delete[] buffer_allocator_;
buffer_allocator_ = NULL;
} else {
DLOGE("GetFrameCaptureStatus failed. ret = %d", ret);
}
}
return ret;