1 /* 2 * Copyright (C) 2016 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.view.cts.surfacevalidator; 17 18 public class PixelColor { 19 public static final int BLACK = 0xFF000000; 20 public static final int RED = 0xFF0000FF; 21 public static final int GREEN = 0xFF00FF00; 22 public static final int BLUE = 0xFFFF0000; 23 public static final int YELLOW = 0xFF00FFFF; 24 public static final int MAGENTA = 0xFFFF00FF; 25 public static final int WHITE = 0xFFFFFFFF; 26 27 public static final int TRANSPARENT_RED = 0x7F0000FF; 28 public static final int TRANSPARENT_BLUE = 0x7FFF0000; 29 public static final int TRANSPARENT = 0x00000000; 30 31 // Default to black 32 public short mMinAlpha; 33 public short mMaxAlpha; 34 public short mMinRed; 35 public short mMaxRed; 36 public short mMinBlue; 37 public short mMaxBlue; 38 public short mMinGreen; 39 public short mMaxGreen; 40 41 public short mAlpha; 42 public short mRed; 43 public short mGreen; 44 public short mBlue; 45 PixelColor(int color)46 public PixelColor(int color) { 47 mAlpha = (short) ((color >> 24) & 0xFF); 48 mBlue = (short) ((color >> 16) & 0xFF); 49 mGreen = (short) ((color >> 8) & 0xFF); 50 mRed = (short) (color & 0xFF); 51 52 mMinAlpha = (short) getMinValue(mAlpha); 53 mMaxAlpha = (short) getMaxValue(mAlpha); 54 mMinRed = (short) getMinValue(mRed); 55 mMaxRed = (short) getMaxValue(mRed); 56 mMinBlue = (short) getMinValue(mBlue); 57 mMaxBlue = (short) getMaxValue(mBlue); 58 mMinGreen = (short) getMinValue(mGreen); 59 mMaxGreen = (short) getMaxValue(mGreen); 60 } 61 PixelColor()62 public PixelColor() { 63 this(BLACK); 64 } 65 getMinValue(short color)66 private int getMinValue(short color) { 67 return Math.max(color - 4, 0); 68 } 69 getMaxValue(short color)70 private int getMaxValue(short color) { 71 return Math.min(color + 4, 0xFF); 72 } 73 } 74