OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file looks like a unit test, but it contains benchmarks and test | 5 // This file looks like a unit test, but it contains benchmarks and test |
6 // utilities intended for manual evaluation of the scalers in | 6 // utilities intended for manual evaluation of the scalers in |
7 // gl_helper*. These tests produce output in the form of files and printouts, | 7 // gl_helper*. These tests produce output in the form of files and printouts, |
8 // but cannot really "fail". There is no point in making these tests part | 8 // but cannot really "fail". There is no point in making these tests part |
9 // of any test automation run. | 9 // of any test automation run. |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 static_cast<int>(bitmap->rowBytes()), true, | 103 static_cast<int>(bitmap->rowBytes()), true, |
104 std::vector<gfx::PNGCodec::Comment>(), &compressed)); | 104 std::vector<gfx::PNGCodec::Comment>(), &compressed)); |
105 ASSERT_TRUE(compressed.size()); | 105 ASSERT_TRUE(compressed.size()); |
106 FILE* f = base::OpenFile(filename, "wb"); | 106 FILE* f = base::OpenFile(filename, "wb"); |
107 ASSERT_TRUE(f); | 107 ASSERT_TRUE(f); |
108 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), | 108 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), |
109 compressed.size()); | 109 compressed.size()); |
110 base::CloseFile(f); | 110 base::CloseFile(f); |
111 } | 111 } |
112 | 112 |
113 scoped_ptr<gpu::GLInProcessContext> context_; | 113 std::unique_ptr<gpu::GLInProcessContext> context_; |
114 gpu::gles2::GLES2Interface* gl_; | 114 gpu::gles2::GLES2Interface* gl_; |
115 scoped_ptr<content::GLHelper> helper_; | 115 std::unique_ptr<content::GLHelper> helper_; |
116 scoped_ptr<content::GLHelperScaling> helper_scaling_; | 116 std::unique_ptr<content::GLHelperScaling> helper_scaling_; |
117 std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_; | 117 std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_; |
118 }; | 118 }; |
119 | 119 |
120 TEST_F(GLHelperTest, ScaleBenchmark) { | 120 TEST_F(GLHelperTest, ScaleBenchmark) { |
121 int output_sizes[] = {1920, 1080, 1249, 720, // Output size on pixel | 121 int output_sizes[] = {1920, 1080, 1249, 720, // Output size on pixel |
122 256, 144}; | 122 256, 144}; |
123 int input_sizes[] = {3200, 2040, 2560, 1476, // Pixel tab size | 123 int input_sizes[] = {3200, 2040, 2560, 1476, // Pixel tab size |
124 1920, 1080, 1280, 720, 800, 480, 256, 144}; | 124 1920, 1080, 1280, 720, 800, 480, 256, 144}; |
125 | 125 |
126 for (size_t q = 0; q < arraysize(kQualities); q++) { | 126 for (size_t q = 0; q < arraysize(kQualities); q++) { |
(...skipping 17 matching lines...) Expand all Loading... |
144 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer); | 144 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
145 gl_->BindTexture(GL_TEXTURE_2D, dst_texture); | 145 gl_->BindTexture(GL_TEXTURE_2D, dst_texture); |
146 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dst_size.width(), | 146 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dst_size.width(), |
147 dst_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); | 147 dst_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); |
148 gl_->BindTexture(GL_TEXTURE_2D, src_texture); | 148 gl_->BindTexture(GL_TEXTURE_2D, src_texture); |
149 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src_size.width(), | 149 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src_size.width(), |
150 src_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, | 150 src_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, |
151 input.getPixels()); | 151 input.getPixels()); |
152 | 152 |
153 gfx::Rect src_subrect(0, 0, src_size.width(), src_size.height()); | 153 gfx::Rect src_subrect(0, 0, src_size.width(), src_size.height()); |
154 scoped_ptr<content::GLHelper::ScalerInterface> scaler( | 154 std::unique_ptr<content::GLHelper::ScalerInterface> scaler( |
155 helper_->CreateScaler(kQualities[q], src_size, src_subrect, | 155 helper_->CreateScaler(kQualities[q], src_size, src_subrect, |
156 dst_size, false, false)); | 156 dst_size, false, false)); |
157 // Scale once beforehand before we start measuring. | 157 // Scale once beforehand before we start measuring. |
158 scaler->Scale(src_texture, dst_texture); | 158 scaler->Scale(src_texture, dst_texture); |
159 gl_->Finish(); | 159 gl_->Finish(); |
160 | 160 |
161 base::TimeTicks start_time = base::TimeTicks::Now(); | 161 base::TimeTicks start_time = base::TimeTicks::Now(); |
162 int iterations = 0; | 162 int iterations = 0; |
163 base::TimeTicks end_time; | 163 base::TimeTicks end_time; |
164 while (true) { | 164 while (true) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 kQualityNames[q], percents[p]); | 238 kQualityNames[q], percents[p]); |
239 VLOG(0) << "Writing " << filename; | 239 VLOG(0) << "Writing " << filename; |
240 SaveToFile(&output_pixels, base::FilePath::FromUTF8Unsafe(filename)); | 240 SaveToFile(&output_pixels, base::FilePath::FromUTF8Unsafe(filename)); |
241 } | 241 } |
242 } | 242 } |
243 gl_->DeleteTextures(1, &src_texture); | 243 gl_->DeleteTextures(1, &src_texture); |
244 gl_->DeleteFramebuffers(1, &framebuffer); | 244 gl_->DeleteFramebuffers(1, &framebuffer); |
245 } | 245 } |
246 | 246 |
247 } // namespace | 247 } // namespace |
OLD | NEW |