1 /*
2  * Copyright (C) 2011 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 #ifndef METERINGTEST_H
18 #define METERINGTEST_H
19 
20 #include <vector>
21 
22 #include "imagetesthandler.h"
23 
24 // Constructs a test handler for the metering test. The instance holds the pixel
25 // values of the gray checkers on the color checker under different metering
26 // settins. It can also compare two arrays of pixel values to tell whether one
27 // is brighter or equivalent or darker than the other one.
28 class MeteringTest : public ImageTestHandler {
29   public:
MeteringTest()30     MeteringTest() : ImageTestHandler() {}
MeteringTest(const int debugHeight,const int debugWidth)31     MeteringTest(const int debugHeight, const int debugWidth) :
32             ImageTestHandler(debugHeight, debugWidth) {}
~MeteringTest()33     ~MeteringTest() {}
34 
addDataToList(const std::vector<Vec3f> * checkerColors)35     void addDataToList(const std::vector<Vec3f>* checkerColors) {
36         mCheckerColors.push_back(*checkerColors);
37         delete checkerColors;
38     }
39 
40     void processData();
41 
42     void clearData();
43 
getComparisonResults()44     const std::vector<bool>* getComparisonResults() const {
45         return (&mComparisonResults);
46     }
47 
48   private:
49     bool isDarkerThan(const std::vector<Vec3f>* checkerColors1,
50                       const std::vector<Vec3f>* checkerColors2) const;
51     bool isEquivalentTo(const std::vector<Vec3f>* checkerColors1,
52                         const std::vector<Vec3f>* checkerColors2) const;
53 
54     std::vector<std::vector<Vec3f> > mCheckerColors;
55     std::vector<bool> mComparisonResults;
56     int mNumPatches;
57 };
58 
59 #endif
60