Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Side by Side Diff: gpu/command_buffer/tests/gl_ext_multisample_compatibility_unittest.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo part of clang-format Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h> 6 #include <GLES2/gl2ext.h>
7 #include <GLES2/gl2extchromium.h> 7 #include <GLES2/gl2extchromium.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
no sievers 2016/04/05 19:02:41 #include <memory>
Mostyn Bramley-Moore 2016/04/05 21:35:32 Done.
10 #include "gpu/command_buffer/tests/gl_manager.h" 10 #include "gpu/command_buffer/tests/gl_manager.h"
11 #include "gpu/command_buffer/tests/gl_test_utils.h" 11 #include "gpu/command_buffer/tests/gl_test_utils.h"
12 #include "gpu/config/gpu_test_config.h" 12 #include "gpu/config/gpu_test_config.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #define SHADER0(Src) #Src 15 #define SHADER0(Src) #Src
16 16
17 namespace gpu { 17 namespace gpu {
18 18
19 class EXTMultisampleCompatibilityTest : public testing::Test { 19 class EXTMultisampleCompatibilityTest : public testing::Test {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f}; 149 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 1.0f};
150 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f}; 150 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 1.0f};
151 static const float kRed[] = {1.0f, 0.0f, 0.0f, 1.0f}; 151 static const float kRed[] = {1.0f, 0.0f, 0.0f, 1.0f};
152 152
153 // Different drivers seem to behave differently with respect to resulting 153 // Different drivers seem to behave differently with respect to resulting
154 // values. These might be due to different MSAA sample counts causing 154 // values. These might be due to different MSAA sample counts causing
155 // different samples to hit. Other option is driver bugs. Just test that 155 // different samples to hit. Other option is driver bugs. Just test that
156 // disabling multisample causes a difference. 156 // disabling multisample causes a difference.
157 scoped_ptr<uint8_t[]> results[3]; 157 std::unique_ptr<uint8_t[]> results[3];
158 const GLint kResultSize = kWidth * kHeight * 4; 158 const GLint kResultSize = kWidth * kHeight * 4;
159 for (int pass = 0; pass < 3; pass++) { 159 for (int pass = 0; pass < 3; pass++) {
160 PrepareForDraw(); 160 PrepareForDraw();
161 // Green: from top right to bottom left. 161 // Green: from top right to bottom left.
162 glUniform4fv(color_loc_, 1, kGreen); 162 glUniform4fv(color_loc_, 1, kGreen);
163 glDrawArrays(GL_TRIANGLES, 0, 3); 163 glDrawArrays(GL_TRIANGLES, 0, 3);
164 164
165 // Blue: from top left to bottom right. 165 // Blue: from top left to bottom right.
166 glUniform4fv(color_loc_, 1, kBlue); 166 glUniform4fv(color_loc_, 1, kBlue);
167 glDrawArrays(GL_TRIANGLES, 3, 3); 167 glDrawArrays(GL_TRIANGLES, 3, 3);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 0.5f}; 199 static const float kBlue[] = {0.0f, 0.0f, 1.0f, 0.5f};
200 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 0.5f}; 200 static const float kGreen[] = {0.0f, 1.0f, 0.0f, 0.5f};
201 static const float kRed[] = {1.0f, 0.0f, 0.0f, 0.5f}; 201 static const float kRed[] = {1.0f, 0.0f, 0.0f, 0.5f};
202 202
203 // Different drivers seem to behave differently with respect to resulting 203 // Different drivers seem to behave differently with respect to resulting
204 // alpha value. These might be due to different MSAA sample counts causing 204 // alpha value. These might be due to different MSAA sample counts causing
205 // different samples to hit. Other option is driver bugs. Testing exact or 205 // different samples to hit. Other option is driver bugs. Testing exact or
206 // even approximate sample values is not that easy. Thus, just test 206 // even approximate sample values is not that easy. Thus, just test
207 // representative positions which have fractional pixels, inspecting that 207 // representative positions which have fractional pixels, inspecting that
208 // normal rendering is different to SAMPLE_ALPHA_TO_ONE rendering. 208 // normal rendering is different to SAMPLE_ALPHA_TO_ONE rendering.
209 scoped_ptr<uint8_t[]> results[3]; 209 std::unique_ptr<uint8_t[]> results[3];
210 const GLint kResultSize = kWidth * kHeight * 4; 210 const GLint kResultSize = kWidth * kHeight * 4;
211 211
212 for (int pass = 0; pass < 3; ++pass) { 212 for (int pass = 0; pass < 3; ++pass) {
213 PrepareForDraw(); 213 PrepareForDraw();
214 if (pass == 1) { 214 if (pass == 1) {
215 glEnable(GL_SAMPLE_ALPHA_TO_ONE_EXT); 215 glEnable(GL_SAMPLE_ALPHA_TO_ONE_EXT);
216 } 216 }
217 glEnable(GL_MULTISAMPLE_EXT); 217 glEnable(GL_MULTISAMPLE_EXT);
218 glUniform4fv(color_loc_, 1, kGreen); 218 glUniform4fv(color_loc_, 1, kGreen);
219 glDrawArrays(GL_TRIANGLES, 0, 3); 219 glDrawArrays(GL_TRIANGLES, 0, 3);
(...skipping 14 matching lines...) Expand all
234 glDisable(GL_SAMPLE_ALPHA_TO_ONE_EXT); 234 glDisable(GL_SAMPLE_ALPHA_TO_ONE_EXT);
235 } 235 }
236 } 236 }
237 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize)); 237 EXPECT_NE(0, memcmp(results[0].get(), results[1].get(), kResultSize));
238 // Verify that rendering is deterministic, so that the pass above does not 238 // Verify that rendering is deterministic, so that the pass above does not
239 // come from non-deterministic rendering. 239 // come from non-deterministic rendering.
240 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize)); 240 EXPECT_EQ(0, memcmp(results[0].get(), results[2].get(), kResultSize));
241 } 241 }
242 242
243 } // namespace gpu 243 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698