| Index: cc/resources/texture_compressor_perftest.cc
|
| diff --git a/cc/resources/texture_compressor_perftest.cc b/cc/resources/texture_compressor_perftest.cc
|
| index d2ad5bcc21aea0142a7390351dcb9c4a7994fcd9..7d68bd6f5f3d9415e2d14de53de87fd4f860935f 100644
|
| --- a/cc/resources/texture_compressor_perftest.cc
|
| +++ b/cc/resources/texture_compressor_perftest.cc
|
| @@ -17,8 +17,12 @@
|
|
|
| const int kImageWidth = 256;
|
| const int kImageHeight = 256;
|
| -const int kImageChannels = 4;
|
| -const int kImageSizeInBytes = kImageWidth * kImageHeight * kImageChannels;
|
| +const int kImageSizeInBytes = kImageWidth * kImageHeight * 4;
|
| +
|
| +const TextureCompressor::Quality kQualities[] = {
|
| + TextureCompressor::kQualityLow,
|
| + TextureCompressor::kQualityMedium,
|
| + TextureCompressor::kQualityHigh};
|
|
|
| std::string FormatName(TextureCompressor::Format format) {
|
| switch (format) {
|
| @@ -45,9 +49,7 @@
|
| }
|
|
|
| class TextureCompressorPerfTest
|
| - : public testing::TestWithParam<
|
| - ::testing::tuple<TextureCompressor::Quality,
|
| - TextureCompressor::Format>> {
|
| + : public testing::TestWithParam<TextureCompressor::Format> {
|
| public:
|
| TextureCompressorPerfTest()
|
| : timer_(kWarmupRuns,
|
| @@ -55,20 +57,18 @@
|
| kTimeCheckInterval) {}
|
|
|
| void SetUp() override {
|
| - TextureCompressor::Format format = ::testing::get<1>(GetParam());
|
| + TextureCompressor::Format format = GetParam();
|
| compressor_ = TextureCompressor::Create(format);
|
| }
|
|
|
| - void RunTest(const std::string& name) {
|
| - TextureCompressor::Quality quality = ::testing::get<0>(GetParam());
|
| + void RunTest(const std::string& name, TextureCompressor::Quality quality) {
|
| timer_.Reset();
|
| do {
|
| compressor_->Compress(src_, dst_, kImageWidth, kImageHeight, quality);
|
| timer_.NextLap();
|
| } while (!timer_.HasTimeLimitExpired());
|
|
|
| - TextureCompressor::Format format = ::testing::get<1>(GetParam());
|
| - std::string str = FormatName(format) + " " + QualityName(quality);
|
| + std::string str = FormatName(GetParam()) + " " + QualityName(quality);
|
| perf_test::PrintResult("Compress256x256", name, str, timer_.MsPerLap(),
|
| "us", true);
|
| }
|
| @@ -80,42 +80,24 @@
|
| uint8_t dst_[kImageSizeInBytes];
|
| };
|
|
|
| -TEST_P(TextureCompressorPerfTest, Compress256x256BlackAndWhiteGradientImage) {
|
| +TEST_P(TextureCompressorPerfTest, Compress256x256Image) {
|
| for (int i = 0; i < kImageSizeInBytes; ++i)
|
| src_[i] = i % 256;
|
|
|
| - RunTest("BlackAndWhiteGradientImage");
|
| + for (auto& quality : kQualities)
|
| + RunTest("Image", quality);
|
| }
|
|
|
| -TEST_P(TextureCompressorPerfTest, Compress256x256SolidBlackImage) {
|
| +TEST_P(TextureCompressorPerfTest, Compress256x256SolidImage) {
|
| memset(src_, 0, kImageSizeInBytes);
|
|
|
| - RunTest("SolidBlackImage");
|
| + for (auto& quality : kQualities)
|
| + RunTest("SolidImage", quality);
|
| }
|
|
|
| -TEST_P(TextureCompressorPerfTest, Compress256x256SolidColorImage) {
|
| - for (int i = 0; i < kImageSizeInBytes; ++i)
|
| - src_[i] = (4 - i % 4) * 50;
|
| -
|
| - RunTest("SolidColorImage");
|
| -}
|
| -
|
| -TEST_P(TextureCompressorPerfTest, Compress256x256RandomColorImage) {
|
| - unsigned int kImageSeed = 1234567890;
|
| - srand(kImageSeed);
|
| - for (int i = 0; i < kImageSizeInBytes; ++i)
|
| - src_[i] = rand() % 256; // NOLINT
|
| -
|
| - RunTest("RandomColorImage");
|
| -}
|
| -
|
| -INSTANTIATE_TEST_CASE_P(
|
| - TextureCompressorPerfTests,
|
| - TextureCompressorPerfTest,
|
| - ::testing::Combine(::testing::Values(TextureCompressor::kQualityLow,
|
| - TextureCompressor::kQualityMedium,
|
| - TextureCompressor::kQualityHigh),
|
| - ::testing::Values(TextureCompressor::kFormatETC1)));
|
| +INSTANTIATE_TEST_CASE_P(TextureCompressorPerfTests,
|
| + TextureCompressorPerfTest,
|
| + ::testing::Values(TextureCompressor::kFormatETC1));
|
|
|
| } // namespace
|
| } // namespace cc
|
|
|