Home | History | Annotate | Download | only in bitmapcomparers
      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.bitmapcomparers;
     17 
     18 /**
     19  * This abstract class can be used by the tester to implement their own comparison methods
     20  */
     21 public abstract class BitmapComparer {
     22     /**
     23      * Compares the two bitmaps given using Java.
     24      * @param offset where in the bitmaps to start
     25      * @param stride how much to skip between two different rows
     26      * @param width the width of the subsection being tested
     27      * @param height the height of the subsection being tested
     28      * @return
     29      */
     30     public abstract boolean verifySame(int[] ideal, int[] given, int offset, int stride, int width,
     31             int height);
     32 
     33     /**
     34      * This calculates the position in an array that would represent a bitmap given the parameters.
     35      */
     36     protected static int indexFromXAndY(int x, int y, int stride, int offset) {
     37         return x + (y * stride) + offset;
     38     }
     39 }
     40