31 absl::optional<CFX_DIBitmap::PitchAndSize> result =
32 CFX_DIBitmap::CalculatePitchAndSize(100, 200, FXDIB_Format::kArgb, 0);
33 ASSERT_TRUE(result.has_value());
34 EXPECT_EQ(400u, result.value().pitch);
35 EXPECT_EQ(80000u, result.value().size);
39 CFX_DIBitmap::CalculatePitchAndSize(100, 200, FXDIB_Format::k8bppRgb, 0);
40 ASSERT_TRUE(result.has_value());
41 EXPECT_EQ(100u, result.value().pitch);
42 EXPECT_EQ(20000u, result.value().size);
46 CFX_DIBitmap::CalculatePitchAndSize(100, 200, FXDIB_Format::kArgb, 400);
47 ASSERT_TRUE(result.has_value());
48 EXPECT_EQ(400u, result.value().pitch);
49 EXPECT_EQ(80000u, result.value().size);
53 CFX_DIBitmap::CalculatePitchAndSize(100, 200, FXDIB_Format::kArgb, 455);
54 ASSERT_TRUE(result.has_value());
55 EXPECT_EQ(455u, result.value().pitch);
56 EXPECT_EQ(91000u, result.value().size);
61 static const CFX_Size kBadDimensions[] = {
62 {0, 0}, {-1, -1}, {-1, 0}, {0, -1},
63 {0, 200}, {100, 0}, {-1, 200}, {100, -1},
65 for (
const auto& dimension : kBadDimensions) {
66 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(
67 dimension.width, dimension.height, FXDIB_Format::kArgb, 0));
68 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(
69 dimension.width, dimension.height, FXDIB_Format::kArgb, 1));
75 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(
83 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(1073747000, 1,
85 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(1048576, 1024,
87 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(4194304, 1024,
91 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(
93 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(
95 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(
101 absl::optional<CFX_DIBitmap::PitchAndSize> result =
102 CFX_DIBitmap::CalculatePitchAndSize(536870908, 4, FXDIB_Format::k8bppRgb,
105 EXPECT_EQ(536870908u, result.value().pitch);
106 EXPECT_EQ(2147483632u, result.value().size);
107 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(536870909, 4,
111 result = CFX_DIBitmap::CalculatePitchAndSize(68174084, 63,
112 FXDIB_Format::k8bppRgb, 0);
114 EXPECT_EQ(68174084u, result.value().pitch);
115 EXPECT_EQ(4294967292u, result.value().size);
116 EXPECT_FALSE(CFX_DIBitmap::CalculatePitchAndSize(68174085, 63,
128 EXPECT_THAT(bitmap->GetBuffer(), ElementsAre(0xff, 0xff, 0xff, 0x7f));
139 EXPECT_THAT(bitmap->GetBuffer(), ElementsAre(0xff, 0xff, 0xff, 0x7f));
150 EXPECT_THAT(bitmap->GetBuffer(), ElementsAre(0xff, 0xff, 0xff, 0x7f));