Replace std::array with a raw C array

The clang version we're using don't support this feature (from OS X 10.7)
This commit is contained in:
David Capello 2015-06-23 11:23:05 -03:00
parent 5d6bdf5462
commit b9e7e1b373
2 changed files with 12 additions and 11 deletions

View File

@ -13,8 +13,6 @@
#include "doc/palette.h"
#include "doc/rgbmap.h"
#include <array>
namespace render {
// Creates a Bayer dither matrix.
@ -22,7 +20,7 @@ namespace render {
class BayerMatrix {
static int D2[4];
std::array<int, N*N> m_matrix;
int m_matrix[N*N];
public:
int maxValue() const { return N*N; }
@ -38,8 +36,8 @@ namespace render {
return m_matrix[(i%N)*N + (j%N)];
}
const std::array<int, N*N>& array() const {
return m_matrix;
int operator[](int i) const {
return m_matrix[i];
}
private:

View File

@ -18,29 +18,31 @@ using namespace render;
TEST(BayerMatrix, CheckD2)
{
BayerMatrix<2> matrix;
std::array<int, 2*2> expected = {
int expected[2*2] = {
0, 2,
3, 1
};
EXPECT_EQ(expected, matrix.array());
for (int i=0; i<2*2; ++i)
EXPECT_EQ(expected[i], matrix[i]);
}
TEST(BayerMatrix, CheckD4)
{
BayerMatrix<4> matrix;
std::array<int, 4*4> expected = {
int expected[4*4] = {
0, 8, 2, 10,
12, 4, 14, 6,
3, 11, 1, 9,
15, 7, 13, 5
};
EXPECT_EQ(expected, matrix.array());
for (int i=0; i<2*2; ++i)
EXPECT_EQ(expected[i], matrix[i]);
}
TEST(BayerMatrix, CheckD8)
{
BayerMatrix<8> matrix;
std::array<int, 8*8> expected = {
int expected[8*8] = {
0, 32, 8, 40, 2, 34, 10, 42,
48, 16, 56, 24, 50, 18, 58, 26,
12, 44, 4, 36, 14, 46, 6, 38,
@ -51,7 +53,8 @@ TEST(BayerMatrix, CheckD8)
15, 47, 7, 39, 13, 45, 5, 37,
63, 31, 55, 23, 61, 29, 53, 21
};
EXPECT_EQ(expected, matrix.array());
for (int i=0; i<2*2; ++i)
EXPECT_EQ(expected[i], matrix[i]);
}
int main(int argc, char** argv)