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

Side by Side Diff: ui/gl/test/gl_image_test_template.h

Issue 1576353007: gl, ozone: add new GLImageBindTest unittests and make ozone run it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « ui/gl/test/gl_image_test_support.cc ('k') | ui/gl/test/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file defines tests that implementations of GLImage should pass in order 5 // This file defines tests that implementations of GLImage should pass in order
6 // to be conformant. 6 // to be conformant.
7 7
8 #ifndef UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ 8 #ifndef UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_
9 #define UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ 9 #define UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_
10 10
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 glDeleteProgram(program); 204 glDeleteProgram(program);
205 glDeleteBuffersARB(1, &vertex_buffer); 205 glDeleteBuffersARB(1, &vertex_buffer);
206 glDeleteFramebuffersEXT(1, &framebuffer); 206 glDeleteFramebuffersEXT(1, &framebuffer);
207 } 207 }
208 208
209 // The GLImageCopyTest test case verifies that the GLImage implementation 209 // The GLImageCopyTest test case verifies that the GLImage implementation
210 // handles CopyTexImage correctly. 210 // handles CopyTexImage correctly.
211 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); 211 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage);
212 212
213 template <typename GLImageTestDelegate>
214 class GLImageBindTest : public GLImageTest<GLImageTestDelegate> {};
215
216 TYPED_TEST_CASE_P(GLImageBindTest);
217
218 TYPED_TEST_P(GLImageBindTest, BindTexImage) {
219 const gfx::Size image_size(256, 256);
220 const uint8_t image_color[] = {0x10, 0x20, 0, 0xff};
221
222 GLuint framebuffer =
223 GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height());
224 ASSERT_TRUE(framebuffer);
225 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer);
226 glViewport(0, 0, image_size.width(), image_size.height());
227
228 GLuint program = this->CreateSingleTextureProgram();
229 GLuint vertex_buffer = gfx::GLHelper::SetupQuadVertexBuffer();
230
231 for (auto format : gfx::GetBufferFormatsForTesting()) {
232 if (!TypeParam::IsSupported(format)) {
233 continue;
234 }
235
236 // Create a solid color green image of preferred format. This must succeed
237 // in order for a GLImage to be conformant.
238 scoped_refptr<gl::GLImage> image =
239 this->delegate_.CreateSolidColorImage(image_size, format, image_color);
240 ASSERT_TRUE(image);
241
242 GLuint texture = GLTestHelper::CreateTexture(GL_TEXTURE_2D);
243
244 // Bind |image| to |texture|.
245 bool rv = image->BindTexImage(GL_TEXTURE_2D);
246 EXPECT_TRUE(rv);
247
248 // Draw |texture| to viewport and read back pixels to check expectations.
249 gfx::GLHelper::DrawQuad(vertex_buffer);
250
251 GLTestHelper::CheckPixels(0, 0, image_size.width(), image_size.height(),
252 image_color);
253
254 // Clean up.
255 glDeleteTextures(1, &texture);
256 image->Destroy(true);
257 }
258 glDeleteProgram(program);
259 glDeleteBuffersARB(1, &vertex_buffer);
260 glDeleteFramebuffersEXT(1, &framebuffer);
261 }
262
263 // The GLImageBindTest test case verifies that the GLImage implementation
264 // handles BindTexImage correctly.
265 REGISTER_TYPED_TEST_CASE_P(GLImageBindTest, BindTexImage);
266
213 } // namespace gl 267 } // namespace gl
214 268
215 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ 269 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_
OLDNEW
« no previous file with comments | « ui/gl/test/gl_image_test_support.cc ('k') | ui/gl/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698