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

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

Issue 1484473003: gl, ozone: enable GLImageBindTest unittests Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase based on crrev.com/1879243002 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 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 protected: 140 protected:
141 scoped_refptr<gfx::GLSurface> surface_; 141 scoped_refptr<gfx::GLSurface> surface_;
142 scoped_refptr<gfx::GLContext> context_; 142 scoped_refptr<gfx::GLContext> context_;
143 GLImageTestDelegate delegate_; 143 GLImageTestDelegate delegate_;
144 }; 144 };
145 145
146 TYPED_TEST_CASE_P(GLImageTest); 146 TYPED_TEST_CASE_P(GLImageTest);
147 147
148 TYPED_TEST_P(GLImageTest, CreateAndDestroy) { 148 TYPED_TEST_P(GLImageTest, CreateAndDestroy) {
149 if (!this->delegate_.IsSupported())
150 return;
151
149 const gfx::Size small_image_size(4, 4); 152 const gfx::Size small_image_size(4, 4);
150 const gfx::Size large_image_size(512, 512); 153 const gfx::Size large_image_size(512, 512);
151 const uint8_t image_color[] = {0, 0xff, 0, 0xff}; 154 const uint8_t image_color[] = {0, 0xff, 0, 0xff};
152 155
153 // Create a small solid color green image of preferred format. This must 156 // Create a small solid color green image of preferred format. This must
154 // succeed in order for a GLImage to be conformant. 157 // succeed in order for a GLImage to be conformant.
155 scoped_refptr<gl::GLImage> small_image = 158 scoped_refptr<gl::GLImage> small_image =
156 this->delegate_.CreateSolidColorImage(small_image_size, image_color); 159 this->delegate_.CreateSolidColorImage(small_image_size, image_color);
157 ASSERT_TRUE(small_image); 160 ASSERT_TRUE(small_image);
158 161
(...skipping 18 matching lines...) Expand all
177 REGISTER_TYPED_TEST_CASE_P(GLImageTest, CreateAndDestroy); 180 REGISTER_TYPED_TEST_CASE_P(GLImageTest, CreateAndDestroy);
178 181
179 template <typename GLImageTestDelegate> 182 template <typename GLImageTestDelegate>
180 class GLImageZeroInitializeTest : public GLImageTest<GLImageTestDelegate> {}; 183 class GLImageZeroInitializeTest : public GLImageTest<GLImageTestDelegate> {};
181 184
182 // This test verifies that if an uninitialized image is bound to a texture, the 185 // This test verifies that if an uninitialized image is bound to a texture, the
183 // result is zero-initialized. 186 // result is zero-initialized.
184 TYPED_TEST_CASE_P(GLImageZeroInitializeTest); 187 TYPED_TEST_CASE_P(GLImageZeroInitializeTest);
185 188
186 TYPED_TEST_P(GLImageZeroInitializeTest, ZeroInitialize) { 189 TYPED_TEST_P(GLImageZeroInitializeTest, ZeroInitialize) {
190 // Ozone platform knows the supported format in runtime.
191 if (!this->delegate_.IsSupported())
192 return;
187 #if defined(OS_MACOSX) 193 #if defined(OS_MACOSX)
188 // This functionality is disabled on Mavericks because it breaks PDF 194 // This functionality is disabled on Mavericks because it breaks PDF
189 // rendering. https://crbug.com/594343. 195 // rendering. https://crbug.com/594343.
190 if (base::mac::IsOSMavericks()) 196 if (base::mac::IsOSMavericks())
191 return; 197 return;
192 #endif 198 #endif
193 199
194 const gfx::Size image_size(256, 256); 200 const gfx::Size image_size(256, 256);
195 201
196 GLuint framebuffer = 202 GLuint framebuffer =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 235 }
230 236
231 REGISTER_TYPED_TEST_CASE_P(GLImageZeroInitializeTest, ZeroInitialize); 237 REGISTER_TYPED_TEST_CASE_P(GLImageZeroInitializeTest, ZeroInitialize);
232 238
233 template <typename GLImageTestDelegate> 239 template <typename GLImageTestDelegate>
234 class GLImageBindTest : public GLImageTest<GLImageTestDelegate> {}; 240 class GLImageBindTest : public GLImageTest<GLImageTestDelegate> {};
235 241
236 TYPED_TEST_CASE_P(GLImageBindTest); 242 TYPED_TEST_CASE_P(GLImageBindTest);
237 243
238 TYPED_TEST_P(GLImageBindTest, BindTexImage) { 244 TYPED_TEST_P(GLImageBindTest, BindTexImage) {
245 if (!this->delegate_.IsSupported())
246 return;
247
239 const gfx::Size image_size(256, 256); 248 const gfx::Size image_size(256, 256);
240 const uint8_t image_color[] = {0x10, 0x20, 0, 0xff}; 249 // These values are picked so that RGB -> YUV on the CPU converted
250 // back to RGB on the GPU produces the original RGB values without
251 // any error.
252 uint8_t image_color[] = {0x10, 0x20, 0x00, 0xff};
253 // glReadPixels(.., GL_RGBA, ..) for RED texture returns (R, 0x00, 0x00, 0xff)
254 if (gfx::BufferFormat::R_8 == this->delegate_.GetBufferFormat())
255 image_color[1] = 0x00;
241 256
242 GLuint framebuffer = 257 GLuint framebuffer =
243 GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height()); 258 GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height());
244 ASSERT_TRUE(framebuffer); 259 ASSERT_TRUE(framebuffer);
245 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer); 260 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer);
246 glViewport(0, 0, image_size.width(), image_size.height()); 261 glViewport(0, 0, image_size.width(), image_size.height());
247 262
248 // Create a solid color green image of preferred format. This must succeed 263 // Create a solid color green image of preferred format. This must succeed
249 // in order for a GLImage to be conformant. 264 // in order for a GLImage to be conformant.
250 scoped_refptr<gl::GLImage> image = 265 scoped_refptr<gl::GLImage> image =
(...skipping 25 matching lines...) Expand all
276 } 291 }
277 292
278 REGISTER_TYPED_TEST_CASE_P(GLImageBindTest, BindTexImage); 293 REGISTER_TYPED_TEST_CASE_P(GLImageBindTest, BindTexImage);
279 294
280 template <typename GLImageTestDelegate> 295 template <typename GLImageTestDelegate>
281 class GLImageCopyTest : public GLImageTest<GLImageTestDelegate> {}; 296 class GLImageCopyTest : public GLImageTest<GLImageTestDelegate> {};
282 297
283 TYPED_TEST_CASE_P(GLImageCopyTest); 298 TYPED_TEST_CASE_P(GLImageCopyTest);
284 299
285 TYPED_TEST_P(GLImageCopyTest, CopyTexImage) { 300 TYPED_TEST_P(GLImageCopyTest, CopyTexImage) {
301 if (!this->delegate_.IsSupported())
302 return;
303
286 const gfx::Size image_size(256, 256); 304 const gfx::Size image_size(256, 256);
287 // These values are picked so that RGB -> YUV on the CPU converted 305 // These values are picked so that RGB -> YUV on the CPU converted
288 // back to RGB on the GPU produces the original RGB values without 306 // back to RGB on the GPU produces the original RGB values without
289 // any error. 307 // any error.
290 const uint8_t image_color[] = {0x10, 0x20, 0, 0xff}; 308 uint8_t image_color[] = {0x10, 0x20, 0x00, 0xff};
309 // glReadPixels(.., GL_RGBA, ..) for RED texture returns (R, 0x00, 0x00, 0xff)
310 if (gfx::BufferFormat::R_8 == this->delegate_.GetBufferFormat())
311 image_color[1] = 0x00;
291 const uint8_t texture_color[] = {0, 0, 0xff, 0xff}; 312 const uint8_t texture_color[] = {0, 0, 0xff, 0xff};
292 313
293 GLuint framebuffer = 314 GLuint framebuffer =
294 GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height()); 315 GLTestHelper::SetupFramebuffer(image_size.width(), image_size.height());
295 ASSERT_TRUE(framebuffer); 316 ASSERT_TRUE(framebuffer);
296 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer); 317 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer);
297 glViewport(0, 0, image_size.width(), image_size.height()); 318 glViewport(0, 0, image_size.width(), image_size.height());
298 319
299 // Create a solid color green image of preferred format. This must succeed 320 // Create a solid color green image of preferred format. This must succeed
300 // in order for a GLImage to be conformant. 321 // in order for a GLImage to be conformant.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 image->Destroy(true /* have_context */); 354 image->Destroy(true /* have_context */);
334 } 355 }
335 356
336 // The GLImageCopyTest test case verifies that the GLImage implementation 357 // The GLImageCopyTest test case verifies that the GLImage implementation
337 // handles CopyTexImage correctly. 358 // handles CopyTexImage correctly.
338 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage); 359 REGISTER_TYPED_TEST_CASE_P(GLImageCopyTest, CopyTexImage);
339 360
340 } // namespace gl 361 } // namespace gl
341 362
342 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_ 363 #endif // UI_GL_TEST_GL_IMAGE_TEST_TEMPLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698