Skip to content

Commit

Permalink
Add GRALLOC_USAGE_HW_COMPOSER usage flag to preview streams
Browse files Browse the repository at this point in the history
This CL adds GRALLOC_USAGE_HW_COMPOSER usage flag to preview streams. In
Chrome Camera App (CCA), we set the format of preview stream to be
HAL_PIXEL_FORMAT_YCBCR_420_888, which is identical to the format used by
portrait mode. We need an additional usage for HAL to differentiate the
streams.

BUG=None
TEST=Recompiled and redeployed Chrome and verified the usage flag in HAL
adapter.

Change-Id: I2b6002e87f2539ca9338af84aa0daa4927575235
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635123
Auto-Submit: Jasmine Chen <lnishan@google.com>
Commit-Queue: Jasmine Chen <lnishan@google.com>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667861}
  • Loading branch information
lnishan authored and Commit Bot committed Jun 11, 2019
1 parent 91ce11a commit 8356c3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions media/capture/video/chromeos/camera_device_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ void CameraDeviceDelegate::ConfigureStreams(
chrome_capture_params_.requested_format.frame_size.height();
preview_stream->format =
cros::mojom::HalPixelFormat::HAL_PIXEL_FORMAT_YCbCr_420_888;
preview_stream->usage = cros::mojom::GRALLOC_USAGE_HW_COMPOSER;
preview_stream->data_space = 0;
preview_stream->rotation =
cros::mojom::Camera3StreamRotation::CAMERA3_STREAM_ROTATION_0;
Expand Down
15 changes: 15 additions & 0 deletions media/capture/video/chromeos/mojo/camera3.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ module cros.mojom;

import "media/capture/video/chromeos/mojo/camera_metadata.mojom";

// These usages flags are defined in gralloc.h. They determine the nature of
// the buffers allocated by gralloc. Read more on:
// https://source.android.com/devices/graphics/arch-bq-gralloc#gralloc_HAL
const uint32 GRALLOC_USAGE_SW_READ_NEVER = 0x00000000;
const uint32 GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003;
const uint32 GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000;
const uint32 GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030;
const uint32 GRALLOC_USAGE_HW_COMPOSER = 0x00000800;
const uint32 GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000;
const uint32 GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000;

[Extensible]
enum HalPixelFormat {
HAL_PIXEL_FORMAT_RGBA_8888 = 0x1,
Expand Down Expand Up @@ -56,6 +67,10 @@ struct Camera3Stream {
uint32 width;
uint32 height;
HalPixelFormat format;
// usage stores the gralloc usage flags for this stream and determines the
// nature of it. The value is used by Chrome VCD, Android framework and camera
// HAL. Read more on:
// https://source.android.com/devices/graphics/arch-bq-gralloc#gralloc_HAL
uint32 usage;
uint32 max_buffers;
uint32 data_space;
Expand Down

0 comments on commit 8356c3c

Please sign in to comment.