Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2dae590 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera: Document behavior when cropRegion and zoomRation conflict

In case cropRegion == windowboxing and zoomRatio != 1.0f, specify the
camera framework behavior of overriding cropRegion.

Test: CaptureRequestTest#testZoomRatio
Bug: 172873869
Change-Id: I9f3f51bca431841feacb4b2cce702dea179bacb9
parent 763b935e
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1957,7 +1957,10 @@ typedef enum acamera_metadata_tag {
     * explicitly set ACAMERA_CONTROL_ZOOM_RATIO, its value defaults to 1.0.</p>
     * <p>One limitation of controlling zoom using zoomRatio is that the ACAMERA_SCALER_CROP_REGION
     * must only be used for letterboxing or pillarboxing of the sensor active array, and no
     * FREEFORM cropping can be used with ACAMERA_CONTROL_ZOOM_RATIO other than 1.0.</p>
     * FREEFORM cropping can be used with ACAMERA_CONTROL_ZOOM_RATIO other than 1.0. If
     * ACAMERA_CONTROL_ZOOM_RATIO is not 1.0, and ACAMERA_SCALER_CROP_REGION is set to be
     * windowboxing, the camera framework will override the ACAMERA_SCALER_CROP_REGION to be
     * the active array.</p>
     *
     * @see ACAMERA_CONTROL_AE_REGIONS
     * @see ACAMERA_CONTROL_ZOOM_RATIO
@@ -3651,7 +3654,9 @@ typedef enum acamera_metadata_tag {
     * </ol>
     * </li>
     * <li>Setting ACAMERA_CONTROL_ZOOM_RATIO to values different than 1.0 and
     * ACAMERA_SCALER_CROP_REGION to be windowboxing at the same time is undefined behavior.</li>
     * ACAMERA_SCALER_CROP_REGION to be windowboxing at the same time are not supported. In this
     * case, the camera framework will override the ACAMERA_SCALER_CROP_REGION to be the active
     * array.</li>
     * </ul>
     * <p>LEGACY capability devices will only support CENTER_ONLY cropping.</p>
     *
+13 −0
Original line number Diff line number Diff line
@@ -153,6 +153,19 @@ status_t ZoomRatioMapper::updateCaptureRequest(CameraMetadata* request) {
    entry = request->find(ANDROID_CONTROL_ZOOM_RATIO);
    if (entry.count == 1 && entry.data.f[0] != 1.0f) {
        zoomRatioIs1 = false;

        // If cropRegion is windowboxing, override it with activeArray
        camera_metadata_entry_t cropRegionEntry = request->find(ANDROID_SCALER_CROP_REGION);
        if (cropRegionEntry.count == 4) {
            int cropWidth = cropRegionEntry.data.i32[2];
            int cropHeight = cropRegionEntry.data.i32[3];
            if (cropWidth < mArrayWidth && cropHeight < mArrayHeight) {
                cropRegionEntry.data.i32[0] = 0;
                cropRegionEntry.data.i32[1] = 0;
                cropRegionEntry.data.i32[2] = mArrayWidth;
                cropRegionEntry.data.i32[3] = mArrayHeight;
            }
        }
    }

    if (mHalSupportsZoomRatio && zoomRatioIs1) {