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

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

Issue 2602563002: Refactor DrawTextureQuad and CheckPixels in gl_tests util (Closed)
Patch Set: rebase only Created 3 years, 11 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 #ifndef GL_GLEXT_PROTOTYPES 5 #ifndef GL_GLEXT_PROTOTYPES
6 #define GL_GLEXT_PROTOTYPES 6 #define GL_GLEXT_PROTOTYPES
7 #endif 7 #endif
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 GLint value = 0; 113 GLint value = 0;
114 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 114 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
115 GLuint fb_id = value; 115 GLuint fb_id = value;
116 EXPECT_EQ(framebuffer_id_, fb_id); 116 EXPECT_EQ(framebuffer_id_, fb_id);
117 117
118 // Check that FB is complete. 118 // Check that FB is complete.
119 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 119 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
120 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 120 glCheckFramebufferStatus(GL_FRAMEBUFFER));
121 121
122 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; 122 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u};
123 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); 123 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels, nullptr);
124 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 124 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
125 } 125 }
126 126
127 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, DefaultFBO) { 127 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, DefaultFBO) {
128 if (!available_) 128 if (!available_)
129 return; 129 return;
130 130
131 glBindFramebuffer(GL_FRAMEBUFFER, 0); 131 glBindFramebuffer(GL_FRAMEBUFFER, 0);
132 glApplyScreenSpaceAntialiasingCHROMIUM(); 132 glApplyScreenSpaceAntialiasingCHROMIUM();
133 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); 133 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
(...skipping 18 matching lines...) Expand all
152 continue; 152 continue;
153 153
154 glClear(GL_COLOR_BUFFER_BIT); 154 glClear(GL_COLOR_BUFFER_BIT);
155 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 155 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
156 156
157 glApplyScreenSpaceAntialiasingCHROMIUM(); 157 glApplyScreenSpaceAntialiasingCHROMIUM();
158 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) << "index:" 158 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()) << "index:"
159 << index; 159 << index;
160 160
161 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; 161 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u};
162 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); 162 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels, nullptr);
163 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 163 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
164 } 164 }
165 } 165 }
166 166
167 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, ImmutableTexture) { 167 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, ImmutableTexture) {
168 if (!available_) 168 if (!available_)
169 return; 169 return;
170 170
171 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { 171 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) {
172 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; 172 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test...";
173 return; 173 return;
174 } 174 }
175 GLenum internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; 175 GLenum internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT};
176 for (auto internal_format : internal_formats) { 176 for (auto internal_format : internal_formats) {
177 glDeleteTextures(1, &textures_); 177 glDeleteTextures(1, &textures_);
178 glDeleteFramebuffers(1, &framebuffer_id_); 178 glDeleteFramebuffers(1, &framebuffer_id_);
179 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 179 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
180 glTexStorage2DEXT(GL_TEXTURE_2D, 1, internal_format, 1, 1); 180 glTexStorage2DEXT(GL_TEXTURE_2D, 1, internal_format, 1, 1);
181 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 181 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
182 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 182 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
183 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 183 glCheckFramebufferStatus(GL_FRAMEBUFFER));
184 184
185 glClear(GL_COLOR_BUFFER_BIT); 185 glClear(GL_COLOR_BUFFER_BIT);
186 186
187 glApplyScreenSpaceAntialiasingCHROMIUM(); 187 glApplyScreenSpaceAntialiasingCHROMIUM();
188 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 188 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
189 189
190 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u}; 190 uint8_t pixels[1 * 4] = {0u, 255u, 0u, 255u};
191 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); 191 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels, nullptr);
192 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 192 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
193 } 193 }
194 } 194 }
195 195
196 // Similar to webgl conformance test 'testAntialias(true)' in 196 // Similar to webgl conformance test 'testAntialias(true)' in
197 // context-attributes-alpha-depth-stencil-antialias.html 197 // context-attributes-alpha-depth-stencil-antialias.html
198 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, AntiAliasing) { 198 TEST_F(GLApplyScreenSpaceAntialiasingCHROMIUMTest, AntiAliasing) {
199 if (!available_) 199 if (!available_)
200 return; 200 return;
201 201
(...skipping 10 matching lines...) Expand all
212 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, 0u, 0u, 0u, 0u, 212 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, 0u, 0u, 0u, 0u,
213 255u, 0u, 0u, 255u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 213 255u, 0u, 0u, 255u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
214 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 214 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
215 }; 215 };
216 glBindTexture(GL_TEXTURE_2D, textures_); 216 glBindTexture(GL_TEXTURE_2D, textures_);
217 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, length, length, 0, GL_RGBA, 217 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, length, length, 0, GL_RGBA,
218 GL_UNSIGNED_BYTE, rgba_pixels); 218 GL_UNSIGNED_BYTE, rgba_pixels);
219 219
220 uint8_t transparent[4] = {0u, 0u, 0u, 0u}; 220 uint8_t transparent[4] = {0u, 0u, 0u, 0u};
221 uint8_t red[4] = {255u, 0u, 0u, 255u}; 221 uint8_t red[4] = {255u, 0u, 0u, 255u};
222 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, red); 222 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, red, nullptr);
223 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, red); 223 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, red, nullptr);
224 GLTestHelper::CheckPixels(0, 2, 1, 1, 0, transparent); 224 GLTestHelper::CheckPixels(0, 2, 1, 1, 0, transparent, nullptr);
225 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, red); 225 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, red, nullptr);
226 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, transparent); 226 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, transparent, nullptr);
227 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 227 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
228 228
229 glApplyScreenSpaceAntialiasingCHROMIUM(); 229 glApplyScreenSpaceAntialiasingCHROMIUM();
230 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 230 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
231 231
232 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, red); 232 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, red, nullptr);
233 GLTestHelper::CheckPixels(2, 2, 1, 1, 0, transparent); 233 GLTestHelper::CheckPixels(2, 2, 1, 1, 0, transparent, nullptr);
234 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 234 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
235 235
236 // Check if middle pixel is anti-aliased. 236 // Check if middle pixel is anti-aliased.
237 uint8_t pixels[4] = {0u}; 237 uint8_t pixels[4] = {0u};
238 glReadPixels(1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); 238 glReadPixels(1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
239 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 239 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
240 EXPECT_NE(transparent, pixels); 240 EXPECT_NE(transparent, pixels);
241 EXPECT_NE(red, pixels); 241 EXPECT_NE(red, pixels);
242 EXPECT_TRUE(pixels[0] > transparent[0] && pixels[0] < red[0]); 242 EXPECT_TRUE(pixels[0] > transparent[0] && pixels[0] < red[0]);
243 EXPECT_EQ(0u, pixels[1]); 243 EXPECT_EQ(0u, pixels[1]);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 387
388 // test using program before 388 // test using program before
389 uint8_t expected[] = { 389 uint8_t expected[] = {
390 0, 255, 0, 255, 390 0, 255, 0, 255,
391 }; 391 };
392 uint8_t zero[] = { 392 uint8_t zero[] = {
393 0, 0, 0, 0, 393 0, 0, 0, 0,
394 }; 394 };
395 glClearColor(0, 0, 0, 0); 395 glClearColor(0, 0, 0, 0);
396 glClear(GL_COLOR_BUFFER_BIT); 396 glClear(GL_COLOR_BUFFER_BIT);
397 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 397 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr));
398 glDrawArrays(GL_TRIANGLES, 0, 6); 398 glDrawArrays(GL_TRIANGLES, 0, 6);
399 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 399 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr));
400 400
401 // Call copyTextureCHROMIUM 401 // Call copyTextureCHROMIUM
402 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; 402 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
403 glBindTexture(GL_TEXTURE_2D, textures_); 403 glBindTexture(GL_TEXTURE_2D, textures_);
404 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 404 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
405 pixels); 405 pixels);
406 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_); 406 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_);
407 glApplyScreenSpaceAntialiasingCHROMIUM(); 407 glApplyScreenSpaceAntialiasingCHROMIUM();
408 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 408 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
409 409
410 // test using program after 410 // test using program after
411 glClear(GL_COLOR_BUFFER_BIT); 411 glClear(GL_COLOR_BUFFER_BIT);
412 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 412 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr));
413 glDrawArrays(GL_TRIANGLES, 0, 6); 413 glDrawArrays(GL_TRIANGLES, 0, 6);
414 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 414 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr));
415 415
416 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 416 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
417 417
418 gl2.MakeCurrent(); 418 gl2.MakeCurrent();
419 gl2.Destroy(); 419 gl2.Destroy();
420 gl_.MakeCurrent(); 420 gl_.MakeCurrent();
421 } 421 }
422 422
423 } // namespace gpu 423 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/compressed_texture_test.cc ('k') | gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698