1 /* 2 * Copyright (C) 2014 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.uirendering.cts.bitmapverifiers; 17 18 import android.graphics.Bitmap; 19 import android.graphics.Color; 20 21 /** 22 * Checks to see if a Bitmap follows the algorithm provided by the verifier 23 */ 24 public abstract class BitmapVerifier { 25 protected static final int PASS_COLOR = Color.WHITE; 26 protected static final int FAIL_COLOR = Color.RED; 27 28 protected Bitmap mDifferenceBitmap; 29 30 /** 31 * This will test if the bitmap is good or not. 32 */ verify(int[] bitmap, int offset, int stride, int width, int height)33 public abstract boolean verify(int[] bitmap, int offset, int stride, int width, int height); 34 35 /** 36 * This calculates the position in an array that would represent a bitmap given the parameters. 37 */ indexFromXAndY(int x, int y, int stride, int offset)38 protected static int indexFromXAndY(int x, int y, int stride, int offset) { 39 return x + (y * stride) + offset; 40 } 41 getDifferenceBitmap()42 public Bitmap getDifferenceBitmap() { 43 return mDifferenceBitmap; 44 } 45 } 46