OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "cc/debug/lap_timer.h" | 6 #include "cc/debug/lap_timer.h" |
7 #include "cc/resources/texture_compressor.h" | 7 #include "cc/resources/texture_compressor.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "testing/perf/perf_test.h" | 9 #include "testing/perf/perf_test.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 namespace { | 12 namespace { |
13 | 13 |
14 const int kTimeLimitMillis = 2000; | 14 const int kTimeLimitMillis = 2000; |
15 const int kWarmupRuns = 5; | 15 const int kWarmupRuns = 5; |
16 const int kTimeCheckInterval = 10; | 16 const int kTimeCheckInterval = 10; |
17 | 17 |
18 const int kImageWidth = 256; | 18 const int kImageWidth = 256; |
19 const int kImageHeight = 256; | 19 const int kImageHeight = 256; |
20 const int kImageSizeInBytes = kImageWidth * kImageHeight * 4; | 20 const int kImageChannels = 4; |
21 const int kImageSizeInBytes = kImageWidth * kImageHeight * kImageChannels; | |
21 | 22 |
22 const TextureCompressor::Quality kQualities[] = { | 23 const TextureCompressor::Quality kQualities[] = { |
23 TextureCompressor::kQualityLow, | 24 TextureCompressor::kQualityLow, |
24 TextureCompressor::kQualityMedium, | 25 TextureCompressor::kQualityMedium, |
25 TextureCompressor::kQualityHigh}; | 26 TextureCompressor::kQualityHigh}; |
26 | 27 |
27 std::string FormatName(TextureCompressor::Format format) { | 28 std::string FormatName(TextureCompressor::Format format) { |
28 switch (format) { | 29 switch (format) { |
29 case TextureCompressor::kFormatETC1: | 30 case TextureCompressor::kFormatETC1: |
30 return "ETC1"; | 31 return "ETC1"; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 "us", true); | 74 "us", true); |
74 } | 75 } |
75 | 76 |
76 protected: | 77 protected: |
77 LapTimer timer_; | 78 LapTimer timer_; |
78 scoped_ptr<TextureCompressor> compressor_; | 79 scoped_ptr<TextureCompressor> compressor_; |
79 uint8_t src_[kImageSizeInBytes]; | 80 uint8_t src_[kImageSizeInBytes]; |
80 uint8_t dst_[kImageSizeInBytes]; | 81 uint8_t dst_[kImageSizeInBytes]; |
81 }; | 82 }; |
82 | 83 |
83 TEST_P(TextureCompressorPerfTest, Compress256x256Image) { | 84 TEST_P(TextureCompressorPerfTest, Compress256x256BlackAndWhiteGradientImage) { |
84 for (int i = 0; i < kImageSizeInBytes; ++i) | 85 for (int i = 0; i < kImageSizeInBytes; ++i) |
85 src_[i] = i % 256; | 86 src_[i] = i % 256; |
86 | 87 |
87 for (auto& quality : kQualities) | 88 for (auto& quality : kQualities) |
reveman
2015/05/06 18:44:03
While touching this file, do you mind removing all
radu.velea
2015/05/07 11:21:41
Done.
| |
88 RunTest("Image", quality); | 89 RunTest("BlackAndWhiteGradientImage", quality); |
89 } | 90 } |
90 | 91 |
91 TEST_P(TextureCompressorPerfTest, Compress256x256SolidImage) { | 92 TEST_P(TextureCompressorPerfTest, Compress256x256SolidBlackImage) { |
92 memset(src_, 0, kImageSizeInBytes); | 93 memset(src_, 0, kImageSizeInBytes); |
93 | 94 |
94 for (auto& quality : kQualities) | 95 for (auto& quality : kQualities) |
95 RunTest("SolidImage", quality); | 96 RunTest("SolidBlackImage", quality); |
97 } | |
98 | |
99 TEST_P(TextureCompressorPerfTest, Compress256x256SolidColorImage) { | |
100 for (int i = 0; i < kImageSizeInBytes; ++i) | |
101 src_[i] = (4 - i % 4) * 50; | |
102 | |
103 for (auto& quality : kQualities) | |
104 RunTest("SolidColorImage", quality); | |
105 } | |
106 | |
107 TEST_P(TextureCompressorPerfTest, Compress256x256RandomColorImage) { | |
108 unsigned int kImageSeed = 1234567890; | |
109 for (int i = 0; i < kImageSizeInBytes; ++i) | |
110 src_[i] = rand_r(&kImageSeed) % 256; | |
111 | |
112 for (auto& quality : kQualities) | |
113 RunTest("RandomColorImage", quality); | |
96 } | 114 } |
97 | 115 |
98 INSTANTIATE_TEST_CASE_P(TextureCompressorPerfTests, | 116 INSTANTIATE_TEST_CASE_P(TextureCompressorPerfTests, |
99 TextureCompressorPerfTest, | 117 TextureCompressorPerfTest, |
100 ::testing::Values(TextureCompressor::kFormatETC1)); | 118 ::testing::Values(TextureCompressor::kFormatETC1)); |
101 | 119 |
102 } // namespace | 120 } // namespace |
103 } // namespace cc | 121 } // namespace cc |
OLD | NEW |