1 /* 2 * Copyright 2020 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 package android.graphics.cts; 17 18 import static org.junit.Assert.assertNotNull; 19 20 import android.graphics.ColorSpace; 21 import android.graphics.ColorSpace.Named; 22 23 /** 24 * Helper class for ADataSpace. 25 */ 26 final class DataSpace { DataSpace()27 private DataSpace() { 28 } 29 30 // These match the values in data_space.h 31 public static final int ADATASPACE_UNKNOWN = 0; 32 public static final int ADATASPACE_SRGB = 142671872; 33 public static final int ADATASPACE_SCRGB = 411107328; 34 public static final int ADATASPACE_SRGB_LINEAR = 138477568; 35 public static final int ADATASPACE_SCRGB_LINEAR = 406913024; 36 public static final int ADATASPACE_DISPLAY_P3 = 143261696; 37 public static final int ADATASPACE_BT2020 = 147193856; 38 public static final int ADATASPACE_ADOBE_RGB = 151715840; 39 public static final int ADATASPACE_DCI_P3 = 155844608; 40 public static final int ADATASPACE_BT709 = 281083904; 41 fromColorSpace(ColorSpace cs)42 public static int fromColorSpace(ColorSpace cs) { 43 assertNotNull(cs); 44 if (cs == ColorSpace.get(Named.DISPLAY_P3)) { 45 return ADATASPACE_DISPLAY_P3; 46 } 47 if (cs == ColorSpace.get(Named.BT2020)) { 48 return ADATASPACE_BT2020; 49 } 50 if (cs == ColorSpace.get(Named.ADOBE_RGB)) { 51 return ADATASPACE_ADOBE_RGB; 52 } 53 if (cs == ColorSpace.get(Named.BT709)) { 54 return ADATASPACE_BT709; 55 } 56 if (cs == ColorSpace.get(Named.DCI_P3)) { 57 return ADATASPACE_DCI_P3; 58 } 59 60 if (cs == ColorSpace.get(Named.SRGB)) { 61 return ADATASPACE_SRGB; 62 } 63 if (cs == ColorSpace.get(Named.EXTENDED_SRGB)) { 64 return ADATASPACE_SCRGB; 65 } 66 67 if (cs == ColorSpace.get(Named.LINEAR_SRGB)) { 68 return ADATASPACE_SRGB_LINEAR; 69 } 70 if (cs == ColorSpace.get(Named.LINEAR_EXTENDED_SRGB)) { 71 return ADATASPACE_SCRGB_LINEAR; 72 } 73 74 return ADATASPACE_UNKNOWN; 75 } 76 } 77