blob: fd0809d1f7fdae271843798e810a862224f1dbe5 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/base/tiling_data.h"
#include <algorithm>
#include <vector>
#include "cc/test/geometry_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
namespace {
int NumTiles(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
int num_tiles = tiling.num_tiles_x() * tiling.num_tiles_y();
// Assert no overflow.
EXPECT_GE(num_tiles, 0);
if (num_tiles > 0)
EXPECT_EQ(num_tiles / tiling.num_tiles_x(), tiling.num_tiles_y());
return num_tiles;
}
int XIndex(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int x_coord) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.TileXIndexFromSrcCoord(x_coord);
}
int YIndex(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int y_coord) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.TileYIndexFromSrcCoord(y_coord);
}
int MinBorderXIndex(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int x_coord) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.FirstBorderTileXIndexFromSrcCoord(x_coord);
}
int MinBorderYIndex(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int y_coord) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.FirstBorderTileYIndexFromSrcCoord(y_coord);
}
int MaxBorderXIndex(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int x_coord) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.LastBorderTileXIndexFromSrcCoord(x_coord);
}
int MaxBorderYIndex(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int y_coord) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.LastBorderTileYIndexFromSrcCoord(y_coord);
}
int PosX(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int x_index) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.TilePositionX(x_index);
}
int PosY(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int y_index) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.TilePositionY(y_index);
}
int SizeX(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int x_index) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.TileSizeX(x_index);
}
int SizeY(const gfx::Size& max_texture_size,
const gfx::Rect& tiling_rect,
bool has_border_texels,
int y_index) {
TilingData tiling(max_texture_size, tiling_rect, has_border_texels);
return tiling.TileSizeY(y_index);
}
class TilingDataTest : public ::testing::TestWithParam<gfx::Point> {};
TEST_P(TilingDataTest, NumTiles_NoTiling) {
gfx::Point origin = GetParam();
EXPECT_EQ(
1,
NumTiles(gfx::Size(16, 16), gfx::Rect(origin, gfx::Size(16, 16)), false));
EXPECT_EQ(
1,
NumTiles(gfx::Size(16, 16), gfx::Rect(origin, gfx::Size(15, 15)), true));
EXPECT_EQ(
1,
NumTiles(gfx::Size(16, 16), gfx::Rect(origin, gfx::Size(16, 16)), true));
EXPECT_EQ(
1,
NumTiles(gfx::Size(16, 16), gfx::Rect(origin, gfx::Size(1, 16)), false));
EXPECT_EQ(
1,
NumTiles(gfx::Size(15, 15), gfx::Rect(origin, gfx::Size(15, 15)), true));
EXPECT_EQ(
1,
NumTiles(gfx::Size(32, 16), gfx::Rect(origin, gfx::Size(32, 16)), false));
EXPECT_EQ(
1,
NumTiles(gfx::Size(32, 16), gfx::Rect(origin, gfx::Size(32, 16)), true));
}
TEST_P(TilingDataTest, NumTiles_TilingNoBorders) {
gfx::Point origin = GetParam();
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(0, 0)), false));
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(4, 0)), false));
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(0, 4)), false));
EXPECT_EQ(
0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(4, 0)), false));
EXPECT_EQ(
0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(0, 4)), false));
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(1, 1)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(1, 1), gfx::Rect(origin, gfx::Size(1, 1)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(1, 1), gfx::Rect(origin, gfx::Size(1, 2)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(1, 1), gfx::Rect(origin, gfx::Size(2, 1)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(1, 1)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(1, 2)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(2, 1)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(2, 2)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 3)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(1, 4)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(2, 4)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(3, 4)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(4, 4)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(5, 4)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(6, 4)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(7, 4)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(8, 4)), false));
EXPECT_EQ(
3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(9, 4)), false));
EXPECT_EQ(
3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(10, 4)), false));
EXPECT_EQ(
3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(11, 4)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(1, 5)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(2, 5)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(3, 5)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(4, 5)), false));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(5, 5)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 5)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(7, 5)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 5)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(9, 5)), false));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 5)), false));
EXPECT_EQ(
3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(11, 5)), false));
EXPECT_EQ(
1,
NumTiles(gfx::Size(16, 16), gfx::Rect(origin, gfx::Size(16, 16)), false));
EXPECT_EQ(
1,
NumTiles(gfx::Size(17, 17), gfx::Rect(origin, gfx::Size(16, 16)), false));
EXPECT_EQ(
4,
NumTiles(gfx::Size(15, 15), gfx::Rect(origin, gfx::Size(16, 16)), false));
EXPECT_EQ(
4,
NumTiles(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 16)), false));
EXPECT_EQ(
6,
NumTiles(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(17, 16)), false));
EXPECT_EQ(
8,
NumTiles(gfx::Size(5, 8), gfx::Rect(origin, gfx::Size(17, 16)), false));
}
TEST_P(TilingDataTest, NumTiles_TilingWithBorders) {
gfx::Point origin = GetParam();
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(0, 0)), true));
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(4, 0)), true));
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(0, 4)), true));
EXPECT_EQ(
0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(4, 0)), true));
EXPECT_EQ(
0, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(0, 4)), true));
EXPECT_EQ(
0, NumTiles(gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(1, 1)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(1, 1), gfx::Rect(origin, gfx::Size(1, 1)), true));
EXPECT_EQ(
0, NumTiles(gfx::Size(1, 1), gfx::Rect(origin, gfx::Size(1, 2)), true));
EXPECT_EQ(
0, NumTiles(gfx::Size(1, 1), gfx::Rect(origin, gfx::Size(2, 1)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(1, 1)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(1, 2)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(2, 1)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(2, 2), gfx::Rect(origin, gfx::Size(2, 2)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 3)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(2, 3)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 3)), true));
EXPECT_EQ(
2, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(4, 3)), true));
EXPECT_EQ(
3, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(5, 3)), true));
EXPECT_EQ(
4, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 3)), true));
EXPECT_EQ(
5, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(7, 3)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(1, 4)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(2, 4)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(3, 4)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(4, 4)), true));
EXPECT_EQ(
2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(5, 4)), true));
EXPECT_EQ(
2, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(6, 4)), true));
EXPECT_EQ(
3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(7, 4)), true));
EXPECT_EQ(
3, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(8, 4)), true));
EXPECT_EQ(
4, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(9, 4)), true));
EXPECT_EQ(
4, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(10, 4)), true));
EXPECT_EQ(
5, NumTiles(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(11, 4)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(1, 5)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(2, 5)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(3, 5)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(4, 5)), true));
EXPECT_EQ(
1, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(5, 5)), true));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 5)), true));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(7, 5)), true));
EXPECT_EQ(
2, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 5)), true));
EXPECT_EQ(
3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(9, 5)), true));
EXPECT_EQ(
3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 5)), true));
EXPECT_EQ(
3, NumTiles(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(11, 5)), true));
EXPECT_EQ(
30,
NumTiles(gfx::Size(8, 5), gfx::Rect(origin, gfx::Size(16, 32)), true));
}
TEST_P(TilingDataTest, TileXIndexFromSrcCoord) {
gfx::Point origin = GetParam();
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 1));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 2));
EXPECT_EQ(1,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 3));
EXPECT_EQ(1,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 4));
EXPECT_EQ(1,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 5));
EXPECT_EQ(2,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 6));
EXPECT_EQ(2,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 7));
EXPECT_EQ(2,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 8));
EXPECT_EQ(3,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 9));
EXPECT_EQ(3,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 10));
EXPECT_EQ(3,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 11));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x()));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 1));
EXPECT_EQ(1,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 2));
EXPECT_EQ(2,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 3));
EXPECT_EQ(3,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 4));
EXPECT_EQ(4,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 5));
EXPECT_EQ(5,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 6));
EXPECT_EQ(6,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 7));
EXPECT_EQ(7,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 8));
EXPECT_EQ(7,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 9));
EXPECT_EQ(7,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 10));
EXPECT_EQ(7,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 11));
EXPECT_EQ(0,
XIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
false,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.x() + 1));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 1));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 2));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 1));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 2));
EXPECT_EQ(1,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 3));
EXPECT_EQ(0,
XIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
true,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.x() + 1));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 1));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 2));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 0));
EXPECT_EQ(0,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 1));
EXPECT_EQ(1,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 2));
EXPECT_EQ(1,
XIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 3));
}
TEST_P(TilingDataTest, FirstBorderTileXIndexFromSrcCoord) {
gfx::Point origin = GetParam();
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 2));
EXPECT_EQ(1,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 3));
EXPECT_EQ(1,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 4));
EXPECT_EQ(1,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 5));
EXPECT_EQ(2,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 6));
EXPECT_EQ(2,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 7));
EXPECT_EQ(2,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 8));
EXPECT_EQ(3,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 9));
EXPECT_EQ(3,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 10));
EXPECT_EQ(3,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 11));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 2));
EXPECT_EQ(1,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 3));
EXPECT_EQ(2,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 4));
EXPECT_EQ(3,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 5));
EXPECT_EQ(4,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 6));
EXPECT_EQ(5,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 7));
EXPECT_EQ(6,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 8));
EXPECT_EQ(7,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 9));
EXPECT_EQ(7,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 10));
EXPECT_EQ(7,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 11));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 2));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 2));
EXPECT_EQ(1,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 3));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 2));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 1));
EXPECT_EQ(0,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 2));
EXPECT_EQ(1,
MinBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 3));
}
TEST_P(TilingDataTest, LastBorderTileXIndexFromSrcCoord) {
gfx::Point origin = GetParam();
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 2));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 3));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 4));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 5));
EXPECT_EQ(2,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 6));
EXPECT_EQ(2,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 7));
EXPECT_EQ(2,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 8));
EXPECT_EQ(3,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 9));
EXPECT_EQ(3,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 10));
EXPECT_EQ(3,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.x() + 11));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 0));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 1));
EXPECT_EQ(2,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 2));
EXPECT_EQ(3,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 3));
EXPECT_EQ(4,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 4));
EXPECT_EQ(5,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 5));
EXPECT_EQ(6,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 6));
EXPECT_EQ(7,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 7));
EXPECT_EQ(7,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 8));
EXPECT_EQ(7,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 9));
EXPECT_EQ(7,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 10));
EXPECT_EQ(7,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.x() + 11));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.x() + 2));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 1));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 2));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
false,
origin.x() + 3));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.x() + 1));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 0));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 1));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.x() + 2));
EXPECT_EQ(0,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 0));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 1));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 2));
EXPECT_EQ(1,
MaxBorderXIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(4, 3)),
true,
origin.x() + 3));
}
TEST_P(TilingDataTest, TileYIndexFromSrcCoord) {
gfx::Point origin = GetParam();
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 1));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 2));
EXPECT_EQ(1,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 3));
EXPECT_EQ(1,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 4));
EXPECT_EQ(1,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 5));
EXPECT_EQ(2,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 6));
EXPECT_EQ(2,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 7));
EXPECT_EQ(2,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 8));
EXPECT_EQ(3,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 9));
EXPECT_EQ(3,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 10));
EXPECT_EQ(3,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 11));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 1));
EXPECT_EQ(1,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 2));
EXPECT_EQ(2,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 3));
EXPECT_EQ(3,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 4));
EXPECT_EQ(4,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 5));
EXPECT_EQ(5,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 6));
EXPECT_EQ(6,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 7));
EXPECT_EQ(7,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 8));
EXPECT_EQ(7,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 9));
EXPECT_EQ(7,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 10));
EXPECT_EQ(7,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 11));
EXPECT_EQ(0,
YIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
false,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.y() + 1));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 1));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 2));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 1));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 2));
EXPECT_EQ(1,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 3));
EXPECT_EQ(0,
YIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
true,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.y() + 1));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 1));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 2));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 0));
EXPECT_EQ(0,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 1));
EXPECT_EQ(1,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 2));
EXPECT_EQ(1,
YIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 3));
}
TEST_P(TilingDataTest, FirstBorderTileYIndexFromSrcCoord) {
gfx::Point origin = GetParam();
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 2));
EXPECT_EQ(1,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 3));
EXPECT_EQ(1,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 4));
EXPECT_EQ(1,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 5));
EXPECT_EQ(2,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 6));
EXPECT_EQ(2,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 7));
EXPECT_EQ(2,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 8));
EXPECT_EQ(3,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 9));
EXPECT_EQ(3,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 10));
EXPECT_EQ(3,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 11));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 2));
EXPECT_EQ(1,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 3));
EXPECT_EQ(2,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 4));
EXPECT_EQ(3,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 5));
EXPECT_EQ(4,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 6));
EXPECT_EQ(5,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 7));
EXPECT_EQ(6,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 8));
EXPECT_EQ(7,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 9));
EXPECT_EQ(7,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 10));
EXPECT_EQ(7,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 11));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 2));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 2));
EXPECT_EQ(1,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 3));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 2));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 1));
EXPECT_EQ(0,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 2));
EXPECT_EQ(1,
MinBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 3));
}
TEST_P(TilingDataTest, LastBorderTileYIndexFromSrcCoord) {
gfx::Point origin = GetParam();
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 2));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 3));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 4));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 5));
EXPECT_EQ(2,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 6));
EXPECT_EQ(2,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 7));
EXPECT_EQ(2,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 8));
EXPECT_EQ(3,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 9));
EXPECT_EQ(3,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 10));
EXPECT_EQ(3,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
false,
origin.y() + 11));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 0));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 1));
EXPECT_EQ(2,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 2));
EXPECT_EQ(3,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 3));
EXPECT_EQ(4,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 4));
EXPECT_EQ(5,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 5));
EXPECT_EQ(6,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 6));
EXPECT_EQ(7,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 7));
EXPECT_EQ(7,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 8));
EXPECT_EQ(7,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 9));
EXPECT_EQ(7,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 10));
EXPECT_EQ(7,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(10, 10)),
true,
origin.y() + 11));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
false,
origin.y() + 2));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 1));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 2));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
false,
origin.y() + 3));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(1, 1),
gfx::Rect(origin, gfx::Size(1, 1)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(2, 2),
gfx::Rect(origin, gfx::Size(2, 2)),
true,
origin.y() + 1));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 0));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 1));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 3)),
true,
origin.y() + 2));
EXPECT_EQ(0,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 0));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 1));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 2));
EXPECT_EQ(1,
MaxBorderYIndex(gfx::Size(3, 3),
gfx::Rect(origin, gfx::Size(3, 4)),
true,
origin.y() + 3));
}
TEST_P(TilingDataTest, TileSizeX) {
gfx::Point origin = GetParam();
EXPECT_EQ(
5, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(5, 5)), false, 0));
EXPECT_EQ(
5, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(5, 5)), true, 0));
EXPECT_EQ(
5, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), false, 0));
EXPECT_EQ(
1, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), false, 1));
EXPECT_EQ(
4, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), true, 0));
EXPECT_EQ(
2, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), true, 1));
EXPECT_EQ(
5, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), false, 0));
EXPECT_EQ(
3, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), false, 1));
EXPECT_EQ(
4, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), true, 0));
EXPECT_EQ(
4, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), true, 1));
EXPECT_EQ(
5,
SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), false, 0));
EXPECT_EQ(
5,
SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), false, 1));
EXPECT_EQ(
4, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), true, 0));
EXPECT_EQ(
3, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), true, 1));
EXPECT_EQ(
3, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), true, 2));
EXPECT_EQ(
4, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(11, 11)), true, 2));
EXPECT_EQ(
3, SizeX(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(12, 12)), true, 2));
EXPECT_EQ(
3, SizeX(gfx::Size(5, 9), gfx::Rect(origin, gfx::Size(12, 17)), true, 2));
}
TEST_P(TilingDataTest, TileSizeY) {
gfx::Point origin = GetParam();
EXPECT_EQ(
5, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(5, 5)), false, 0));
EXPECT_EQ(
5, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(5, 5)), true, 0));
EXPECT_EQ(
5, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), false, 0));
EXPECT_EQ(
1, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), false, 1));
EXPECT_EQ(
4, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), true, 0));
EXPECT_EQ(
2, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(6, 6)), true, 1));
EXPECT_EQ(
5, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), false, 0));
EXPECT_EQ(
3, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), false, 1));
EXPECT_EQ(
4, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), true, 0));
EXPECT_EQ(
4, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(8, 8)), true, 1));
EXPECT_EQ(
5,
SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), false, 0));
EXPECT_EQ(
5,
SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), false, 1));
EXPECT_EQ(
4, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), true, 0));
EXPECT_EQ(
3, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), true, 1));
EXPECT_EQ(
3, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(10, 10)), true, 2));
EXPECT_EQ(
4, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(11, 11)), true, 2));
EXPECT_EQ(
3, SizeY(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(12, 12)), true, 2));
EXPECT_EQ(
3, SizeY(gfx::Size(9, 5), gfx::Rect(origin, gfx::Size(17, 12)), true, 2));
}
TEST_P(TilingDataTest, TileSizeX_and_TilePositionX) {
gfx::Point origin = GetParam();
// Single tile cases:
EXPECT_EQ(
1, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), false, 0));
EXPECT_EQ(
origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), false, 0));
EXPECT_EQ(
1,
SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 100)), false, 0));
EXPECT_EQ(
origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 100)), false, 0));
EXPECT_EQ(
3, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 1)), false, 0));
EXPECT_EQ(
origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 1)), false, 0));
EXPECT_EQ(
3,
SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 100)), false, 0));
EXPECT_EQ(
origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 100)), false, 0));
EXPECT_EQ(
1, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), true, 0));
EXPECT_EQ(origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), true, 0));
EXPECT_EQ(
1, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 100)), true, 0));
EXPECT_EQ(
origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 100)), true, 0));
EXPECT_EQ(
3, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 1)), true, 0));
EXPECT_EQ(origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 1)), true, 0));
EXPECT_EQ(
3, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 100)), true, 0));
EXPECT_EQ(
origin.x(),
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(3, 100)), true, 0));
// Multiple tiles:
// no border
// positions 0, 3
EXPECT_EQ(
2, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), false));
EXPECT_EQ(
3, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), false, 0));
EXPECT_EQ(
3, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), false, 1));
EXPECT_EQ(
origin.x() + 0,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), false, 0));
EXPECT_EQ(
origin.x() + 3,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), false, 1));
EXPECT_EQ(
3,
SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 100)), false, 0));
EXPECT_EQ(
3,
SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 100)), false, 1));
EXPECT_EQ(
origin.x() + 0,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 100)), false, 0));
EXPECT_EQ(
origin.x() + 3,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 100)), false, 1));
// Multiple tiles:
// with border
// positions 0, 2, 3, 4
EXPECT_EQ(
4, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true));
EXPECT_EQ(
2, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 0));
EXPECT_EQ(
1, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 1));
EXPECT_EQ(
1, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 2));
EXPECT_EQ(
2, SizeX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 3));
EXPECT_EQ(origin.x() + 0,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 0));
EXPECT_EQ(origin.x() + 2,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 1));
EXPECT_EQ(origin.x() + 3,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 2));
EXPECT_EQ(origin.x() + 4,
PosX(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(6, 1)), true, 3));
EXPECT_EQ(
2, SizeX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 0));
EXPECT_EQ(
1, SizeX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 1));
EXPECT_EQ(
1, SizeX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 2));
EXPECT_EQ(
2, SizeX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 3));
EXPECT_EQ(
origin.x() + 0,
PosX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 0));
EXPECT_EQ(
origin.x() + 2,
PosX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 1));
EXPECT_EQ(
origin.x() + 3,
PosX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 2));
EXPECT_EQ(
origin.x() + 4,
PosX(gfx::Size(3, 7), gfx::Rect(origin, gfx::Size(6, 100)), true, 3));
}
TEST_P(TilingDataTest, TileSizeY_and_TilePositionY) {
gfx::Point origin = GetParam();
// Single tile cases:
EXPECT_EQ(
1, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), false, 0));
EXPECT_EQ(
origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), false, 0));
EXPECT_EQ(
1,
SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 1)), false, 0));
EXPECT_EQ(
origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 1)), false, 0));
EXPECT_EQ(
3, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 3)), false, 0));
EXPECT_EQ(
origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 3)), false, 0));
EXPECT_EQ(
3,
SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 3)), false, 0));
EXPECT_EQ(
origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 3)), false, 0));
EXPECT_EQ(
1, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), true, 0));
EXPECT_EQ(origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 1)), true, 0));
EXPECT_EQ(
1, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 1)), true, 0));
EXPECT_EQ(
origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 1)), true, 0));
EXPECT_EQ(
3, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 3)), true, 0));
EXPECT_EQ(origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 3)), true, 0));
EXPECT_EQ(
3, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 3)), true, 0));
EXPECT_EQ(
origin.y(),
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 3)), true, 0));
// Multiple tiles:
// no border
// positions 0, 3
EXPECT_EQ(
2, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), false));
EXPECT_EQ(
3, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), false, 0));
EXPECT_EQ(
3, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), false, 1));
EXPECT_EQ(
origin.y() + 0,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), false, 0));
EXPECT_EQ(
origin.y() + 3,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), false, 1));
EXPECT_EQ(
3,
SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 6)), false, 0));
EXPECT_EQ(
3,
SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 6)), false, 1));
EXPECT_EQ(
origin.y() + 0,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 6)), false, 0));
EXPECT_EQ(
origin.y() + 3,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(100, 6)), false, 1));
// Multiple tiles:
// with border
// positions 0, 2, 3, 4
EXPECT_EQ(
4, NumTiles(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true));
EXPECT_EQ(
2, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 0));
EXPECT_EQ(
1, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 1));
EXPECT_EQ(
1, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 2));
EXPECT_EQ(
2, SizeY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 3));
EXPECT_EQ(origin.y() + 0,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 0));
EXPECT_EQ(origin.y() + 2,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 1));
EXPECT_EQ(origin.y() + 3,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 2));
EXPECT_EQ(origin.y() + 4,
PosY(gfx::Size(3, 3), gfx::Rect(origin, gfx::Size(1, 6)), true, 3));
EXPECT_EQ(
2, SizeY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 0));
EXPECT_EQ(
1, SizeY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 1));
EXPECT_EQ(
1, SizeY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 2));
EXPECT_EQ(
2, SizeY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 3));
EXPECT_EQ(
origin.y() + 0,
PosY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 0));
EXPECT_EQ(
origin.y() + 2,
PosY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 1));
EXPECT_EQ(
origin.y() + 3,
PosY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 2));
EXPECT_EQ(
origin.y() + 4,
PosY(gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(100, 6)), true, 3));
}
TEST_P(TilingDataTest, SetTotalSize) {
gfx::Point origin = GetParam();
TilingData data(gfx::Size(5, 5), gfx::Rect(origin, gfx::Size(5, 5)), false);
EXPECT_EQ(origin.x(), data.tiling_rect().x());
EXPECT_EQ(origin.y(), data.tiling_rect().y());
EXPECT_EQ(5, data.tiling_rect().width());
EXPECT_EQ(5, data.tiling_rect().height());
EXPECT_EQ(1, data.num_tiles_x());
EXPECT_EQ(5, data.TileSizeX(0));
EXPECT_EQ(1, data.num_tiles_y());
EXPECT_EQ(5, data.TileSizeY(0));
data.SetTilingRect(gfx::Rect(36, 82, 6, 5));
EXPECT_EQ(36, data.tiling_rect().x());
EXPECT_EQ(82, data.tiling_rect().y());
EXPECT_EQ(6, data.tiling_rect().width());
EXPECT_EQ(5, data.tiling_rect().height());
EXPECT_EQ(2, data.num_tiles_x());
EXPECT_EQ(5, data.TileSizeX(0));
EXPECT_EQ(1, data.TileSizeX(1));
EXPECT_EQ(1, data.num_tiles_y());
EXPECT_EQ(5, data.TileSizeY(0));
data.SetTilingRect(gfx::Rect(4, 22, 5, 12));
EXPECT_EQ(4, data.tiling_rect().x());
EXPECT_EQ(22, data.tiling_rect().y());
EXPECT_EQ(5, data.tiling_rect().width());
EXPECT_EQ(12, data.tiling_rect().height());
EXPECT_EQ(1, data.num_tiles_x());
EXPECT_EQ(5, data.TileSizeX(0));
EXPECT_EQ(3, data.num_tiles_y());
EXPECT_EQ(5, data.TileSizeY(0));
EXPECT_EQ(5, data.TileSizeY(1));
EXPECT_EQ(2, data.TileSizeY(2));
}
TEST_P(TilingDataTest, SetMaxTextureSizeNoBorders) {
gfx::Point origin = GetParam();
TilingData data(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 32)), false);
EXPECT_EQ(2, data.num_tiles_x());
EXPECT_EQ(4, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(32, 32));
EXPECT_EQ(gfx::Size(32, 32), data.max_texture_size());
EXPECT_EQ(1, data.num_tiles_x());
EXPECT_EQ(1, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(2, 2));
EXPECT_EQ(gfx::Size(2, 2), data.max_texture_size());
EXPECT_EQ(8, data.num_tiles_x());
EXPECT_EQ(16, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(5, 5));
EXPECT_EQ(gfx::Size(5, 5), data.max_texture_size());
EXPECT_EQ(4, data.num_tiles_x());
EXPECT_EQ(7, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(8, 5));
EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size());
EXPECT_EQ(2, data.num_tiles_x());
EXPECT_EQ(7, data.num_tiles_y());
}
TEST_P(TilingDataTest, SetMaxTextureSizeBorders) {
gfx::Point origin = GetParam();
TilingData data(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 32)), true);
EXPECT_EQ(3, data.num_tiles_x());
EXPECT_EQ(5, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(32, 32));
EXPECT_EQ(gfx::Size(32, 32), data.max_texture_size());
EXPECT_EQ(1, data.num_tiles_x());
EXPECT_EQ(1, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(2, 2));
EXPECT_EQ(gfx::Size(2, 2), data.max_texture_size());
EXPECT_EQ(0, data.num_tiles_x());
EXPECT_EQ(0, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(5, 5));
EXPECT_EQ(gfx::Size(5, 5), data.max_texture_size());
EXPECT_EQ(5, data.num_tiles_x());
EXPECT_EQ(10, data.num_tiles_y());
data.SetMaxTextureSize(gfx::Size(8, 5));
EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size());
EXPECT_EQ(3, data.num_tiles_x());
EXPECT_EQ(10, data.num_tiles_y());
}
TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBordersEmpty) {
gfx::Point origin = GetParam();
TilingData empty_total_size(
gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(8, 8)), true);
EXPECT_RECT_EQ(
gfx::Rect(),
empty_total_size.ExpandRectToTileBoundsWithBorders(gfx::Rect()));
EXPECT_RECT_EQ(gfx::Rect(),
empty_total_size.ExpandRectToTileBoundsWithBorders(
gfx::Rect(100, 100, 100, 100)));
EXPECT_RECT_EQ(gfx::Rect(),
empty_total_size.ExpandRectToTileBoundsWithBorders(
gfx::Rect(0, 0, 100, 100)));
TilingData empty_max_texture_size(
gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(0, 0)), true);
EXPECT_RECT_EQ(
gfx::Rect(),
empty_max_texture_size.ExpandRectToTileBoundsWithBorders(gfx::Rect()));
EXPECT_RECT_EQ(gfx::Rect(),
empty_max_texture_size.ExpandRectToTileBoundsWithBorders(
gfx::Rect(100, 100, 100, 100)));
EXPECT_RECT_EQ(gfx::Rect(),
empty_max_texture_size.ExpandRectToTileBoundsWithBorders(
gfx::Rect(0, 0, 100, 100)));
}
TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBorders) {
gfx::Point origin = GetParam();
TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true);
// Small rect at origin rounds up to tile 0, 0.
gfx::Rect at_origin_src(origin, gfx::Size(1, 1));
gfx::Rect at_origin_result(data.TileBoundsWithBorder(0, 0));
EXPECT_NE(at_origin_src, at_origin_result);
EXPECT_RECT_EQ(at_origin_result,
data.ExpandRectToTileBoundsWithBorders(at_origin_src));
// Arbitrary internal rect.
gfx::Rect rect_src(origin.x() + 6, origin.y() + 6, 1, 3);
// Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
// Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
gfx::Rect rect_result(gfx::UnionRects(data.TileBoundsWithBorder(2, 2),
data.TileBoundsWithBorder(3, 4)));
EXPECT_NE(rect_src, rect_result);
EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBoundsWithBorders(rect_src));
// On tile bounds rounds up to next tile (since border overlaps).
gfx::Rect border_rect_src(
gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
gfx::Rect border_rect_result(gfx::UnionRects(
data.TileBoundsWithBorder(0, 1), data.TileBoundsWithBorder(4, 5)));
EXPECT_RECT_EQ(border_rect_result,
data.ExpandRectToTileBoundsWithBorders(border_rect_src));
// Equal to tiling rect.
EXPECT_RECT_EQ(data.tiling_rect(),
data.ExpandRectToTileBoundsWithBorders(data.tiling_rect()));
// Containing, but larger than tiling rect.
EXPECT_RECT_EQ(data.tiling_rect(),
data.ExpandRectToTileBoundsWithBorders(
gfx::Rect(origin, gfx::Size(100, 100))));
// Non-intersecting with tiling rect.
gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100);
EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect()));
EXPECT_RECT_EQ(gfx::Rect(),
data.ExpandRectToTileBoundsWithBorders(non_intersect));
}
TEST_P(TilingDataTest, Assignment) {
gfx::Point origin = GetParam();
{
TilingData source(
gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 32)), true);
TilingData dest = source;
EXPECT_EQ(source.border_texels(), dest.border_texels());
EXPECT_EQ(source.max_texture_size(), dest.max_texture_size());
EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x());
EXPECT_EQ(source.num_tiles_y(), dest.num_tiles_y());
EXPECT_EQ(source.tiling_rect().x(), dest.tiling_rect().x());
EXPECT_EQ(source.tiling_rect().y(), dest.tiling_rect().y());
EXPECT_EQ(source.tiling_rect().width(), dest.tiling_rect().width());
EXPECT_EQ(source.tiling_rect().height(), dest.tiling_rect().height());
}
{
TilingData source(
gfx::Size(7, 3), gfx::Rect(origin, gfx::Size(6, 100)), false);
TilingData dest(source);
EXPECT_EQ(source.border_texels(), dest.border_texels());
EXPECT_EQ(source.max_texture_size(), dest.max_texture_size());
EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x());
EXPECT_EQ(source.num_tiles_y(), dest.num_tiles_y());
EXPECT_EQ(source.tiling_rect().x(), dest.tiling_rect().x());
EXPECT_EQ(source.tiling_rect().y(), dest.tiling