1 /* 2 * Copyright 2022 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 #pragma once 18 19 #include <vector> 20 21 #include <ui/GraphicTypes.h> 22 23 namespace android::ui { 24 25 using ColorModes = std::vector<ColorMode>; 26 isWideColorMode(ColorMode colorMode)27inline bool isWideColorMode(ColorMode colorMode) { 28 switch (colorMode) { 29 case ColorMode::DISPLAY_P3: 30 case ColorMode::ADOBE_RGB: 31 case ColorMode::DCI_P3: 32 case ColorMode::BT2020: 33 case ColorMode::DISPLAY_BT2020: 34 case ColorMode::BT2100_PQ: 35 case ColorMode::BT2100_HLG: 36 return true; 37 case ColorMode::NATIVE: 38 case ColorMode::STANDARD_BT601_625: 39 case ColorMode::STANDARD_BT601_625_UNADJUSTED: 40 case ColorMode::STANDARD_BT601_525: 41 case ColorMode::STANDARD_BT601_525_UNADJUSTED: 42 case ColorMode::STANDARD_BT709: 43 case ColorMode::SRGB: 44 return false; 45 } 46 } 47 pickDataspaceFor(ColorMode colorMode)48inline Dataspace pickDataspaceFor(ColorMode colorMode) { 49 switch (colorMode) { 50 case ColorMode::DISPLAY_P3: 51 case ColorMode::BT2100_PQ: 52 case ColorMode::BT2100_HLG: 53 case ColorMode::DISPLAY_BT2020: 54 return Dataspace::DISPLAY_P3; 55 default: 56 return Dataspace::V0_SRGB; 57 } 58 } 59 60 } // namespace android::ui 61