1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_SERVERS_UHRCROP_REGIONS_MAPPER_H 18 #define ANDROID_SERVERS_UHRCROP_REGIONS_MAPPER_H 19 20 #include <utils/Errors.h> 21 #include <array> 22 23 #include "camera/CameraMetadata.h" 24 25 namespace android { 26 27 namespace camera3 { 28 29 /** 30 * Utilities to transform SCALER_CROP_REGION and metering regions for ultra high 31 * resolution sensors. 32 */ 33 class UHRCropAndMeteringRegionMapper { 34 public: 35 UHRCropAndMeteringRegionMapper() = default; 36 UHRCropAndMeteringRegionMapper(const CameraMetadata &deviceInfo, bool usePreCorrectionArray); 37 38 /** 39 * Adjust capture request assuming rotate and crop AUTO is enabled 40 */ 41 status_t updateCaptureRequest(CameraMetadata *request); 42 43 private: 44 45 void fixCropRegionsIfNeeded(CameraMetadata *request); 46 void fixMeteringRegionsIfNeeded(CameraMetadata *request); 47 48 int32_t mArrayWidth = 0; 49 int32_t mArrayHeight = 0; 50 int32_t mArrayWidthMaximumResolution = 0; 51 int32_t mArrayHeightMaximumResolution = 0; 52 bool mIsValid = false; 53 }; // class UHRCropAndMeteringRegionMapper 54 55 } // namespace camera3 56 57 } // namespace android 58 59 #endif 60