OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/output/compositor_frame_metadata.h" | 10 #include "cc/output/compositor_frame_metadata.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 EXPECT_TRUE(renderer_->stencil_enabled()); | 356 EXPECT_TRUE(renderer_->stencil_enabled()); |
357 } | 357 } |
358 | 358 |
359 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { | 359 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { |
360 public: | 360 public: |
361 ForbidSynchronousCallContext() {} | 361 ForbidSynchronousCallContext() {} |
362 | 362 |
363 virtual void getAttachedShaders(GLuint program, | 363 virtual void getAttachedShaders(GLuint program, |
364 GLsizei max_count, | 364 GLsizei max_count, |
365 GLsizei* count, | 365 GLsizei* count, |
366 GLuint* shaders) OVERRIDE { | 366 GLuint* shaders) override { |
367 ADD_FAILURE(); | 367 ADD_FAILURE(); |
368 } | 368 } |
369 virtual GLint getAttribLocation(GLuint program, const GLchar* name) OVERRIDE { | 369 virtual GLint getAttribLocation(GLuint program, const GLchar* name) override { |
370 ADD_FAILURE(); | 370 ADD_FAILURE(); |
371 return 0; | 371 return 0; |
372 } | 372 } |
373 virtual void getBooleanv(GLenum pname, GLboolean* value) OVERRIDE { | 373 virtual void getBooleanv(GLenum pname, GLboolean* value) override { |
374 ADD_FAILURE(); | 374 ADD_FAILURE(); |
375 } | 375 } |
376 virtual void getBufferParameteriv(GLenum target, | 376 virtual void getBufferParameteriv(GLenum target, |
377 GLenum pname, | 377 GLenum pname, |
378 GLint* value) OVERRIDE { | 378 GLint* value) override { |
379 ADD_FAILURE(); | 379 ADD_FAILURE(); |
380 } | 380 } |
381 virtual GLenum getError() OVERRIDE { | 381 virtual GLenum getError() override { |
382 ADD_FAILURE(); | 382 ADD_FAILURE(); |
383 return GL_NO_ERROR; | 383 return GL_NO_ERROR; |
384 } | 384 } |
385 virtual void getFloatv(GLenum pname, GLfloat* value) OVERRIDE { | 385 virtual void getFloatv(GLenum pname, GLfloat* value) override { |
386 ADD_FAILURE(); | 386 ADD_FAILURE(); |
387 } | 387 } |
388 virtual void getFramebufferAttachmentParameteriv(GLenum target, | 388 virtual void getFramebufferAttachmentParameteriv(GLenum target, |
389 GLenum attachment, | 389 GLenum attachment, |
390 GLenum pname, | 390 GLenum pname, |
391 GLint* value) OVERRIDE { | 391 GLint* value) override { |
392 ADD_FAILURE(); | 392 ADD_FAILURE(); |
393 } | 393 } |
394 virtual void getIntegerv(GLenum pname, GLint* value) OVERRIDE { | 394 virtual void getIntegerv(GLenum pname, GLint* value) override { |
395 if (pname == GL_MAX_TEXTURE_SIZE) { | 395 if (pname == GL_MAX_TEXTURE_SIZE) { |
396 // MAX_TEXTURE_SIZE is cached client side, so it's OK to query. | 396 // MAX_TEXTURE_SIZE is cached client side, so it's OK to query. |
397 *value = 1024; | 397 *value = 1024; |
398 } else { | 398 } else { |
399 ADD_FAILURE(); | 399 ADD_FAILURE(); |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 // We allow querying the shader compilation and program link status in debug | 403 // We allow querying the shader compilation and program link status in debug |
404 // mode, but not release. | 404 // mode, but not release. |
405 virtual void getProgramiv(GLuint program, | 405 virtual void getProgramiv(GLuint program, |
406 GLenum pname, | 406 GLenum pname, |
407 GLint* value) OVERRIDE { | 407 GLint* value) override { |
408 #ifndef NDEBUG | 408 #ifndef NDEBUG |
409 *value = 1; | 409 *value = 1; |
410 #else | 410 #else |
411 ADD_FAILURE(); | 411 ADD_FAILURE(); |
412 #endif | 412 #endif |
413 } | 413 } |
414 | 414 |
415 virtual void getShaderiv(GLuint shader, GLenum pname, GLint* value) OVERRIDE { | 415 virtual void getShaderiv(GLuint shader, GLenum pname, GLint* value) override { |
416 #ifndef NDEBUG | 416 #ifndef NDEBUG |
417 *value = 1; | 417 *value = 1; |
418 #else | 418 #else |
419 ADD_FAILURE(); | 419 ADD_FAILURE(); |
420 #endif | 420 #endif |
421 } | 421 } |
422 | 422 |
423 virtual void getRenderbufferParameteriv(GLenum target, | 423 virtual void getRenderbufferParameteriv(GLenum target, |
424 GLenum pname, | 424 GLenum pname, |
425 GLint* value) OVERRIDE { | 425 GLint* value) override { |
426 ADD_FAILURE(); | 426 ADD_FAILURE(); |
427 } | 427 } |
428 | 428 |
429 virtual void getShaderPrecisionFormat(GLenum shadertype, | 429 virtual void getShaderPrecisionFormat(GLenum shadertype, |
430 GLenum precisiontype, | 430 GLenum precisiontype, |
431 GLint* range, | 431 GLint* range, |
432 GLint* precision) OVERRIDE { | 432 GLint* precision) override { |
433 ADD_FAILURE(); | 433 ADD_FAILURE(); |
434 } | 434 } |
435 virtual void getTexParameterfv(GLenum target, | 435 virtual void getTexParameterfv(GLenum target, |
436 GLenum pname, | 436 GLenum pname, |
437 GLfloat* value) OVERRIDE { | 437 GLfloat* value) override { |
438 ADD_FAILURE(); | 438 ADD_FAILURE(); |
439 } | 439 } |
440 virtual void getTexParameteriv(GLenum target, | 440 virtual void getTexParameteriv(GLenum target, |
441 GLenum pname, | 441 GLenum pname, |
442 GLint* value) OVERRIDE { | 442 GLint* value) override { |
443 ADD_FAILURE(); | 443 ADD_FAILURE(); |
444 } | 444 } |
445 virtual void getUniformfv(GLuint program, | 445 virtual void getUniformfv(GLuint program, |
446 GLint location, | 446 GLint location, |
447 GLfloat* value) OVERRIDE { | 447 GLfloat* value) override { |
448 ADD_FAILURE(); | 448 ADD_FAILURE(); |
449 } | 449 } |
450 virtual void getUniformiv(GLuint program, | 450 virtual void getUniformiv(GLuint program, |
451 GLint location, | 451 GLint location, |
452 GLint* value) OVERRIDE { | 452 GLint* value) override { |
453 ADD_FAILURE(); | 453 ADD_FAILURE(); |
454 } | 454 } |
455 virtual GLint getUniformLocation(GLuint program, | 455 virtual GLint getUniformLocation(GLuint program, |
456 const GLchar* name) OVERRIDE { | 456 const GLchar* name) override { |
457 ADD_FAILURE(); | 457 ADD_FAILURE(); |
458 return 0; | 458 return 0; |
459 } | 459 } |
460 virtual void getVertexAttribfv(GLuint index, | 460 virtual void getVertexAttribfv(GLuint index, |
461 GLenum pname, | 461 GLenum pname, |
462 GLfloat* value) OVERRIDE { | 462 GLfloat* value) override { |
463 ADD_FAILURE(); | 463 ADD_FAILURE(); |
464 } | 464 } |
465 virtual void getVertexAttribiv(GLuint index, | 465 virtual void getVertexAttribiv(GLuint index, |
466 GLenum pname, | 466 GLenum pname, |
467 GLint* value) OVERRIDE { | 467 GLint* value) override { |
468 ADD_FAILURE(); | 468 ADD_FAILURE(); |
469 } | 469 } |
470 virtual GLsizeiptr getVertexAttribOffset(GLuint index, | 470 virtual GLsizeiptr getVertexAttribOffset(GLuint index, |
471 GLenum pname) OVERRIDE { | 471 GLenum pname) override { |
472 ADD_FAILURE(); | 472 ADD_FAILURE(); |
473 return 0; | 473 return 0; |
474 } | 474 } |
475 }; | 475 }; |
476 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { | 476 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { |
477 FakeOutputSurfaceClient output_surface_client; | 477 FakeOutputSurfaceClient output_surface_client; |
478 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 478 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
479 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); | 479 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); |
480 CHECK(output_surface->BindToClient(&output_surface_client)); | 480 CHECK(output_surface->BindToClient(&output_surface_client)); |
481 | 481 |
(...skipping 15 matching lines...) Expand all Loading... |
497 output_surface.get(), | 497 output_surface.get(), |
498 resource_provider.get()); | 498 resource_provider.get()); |
499 } | 499 } |
500 | 500 |
501 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { | 501 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { |
502 public: | 502 public: |
503 LoseContextOnFirstGetContext() {} | 503 LoseContextOnFirstGetContext() {} |
504 | 504 |
505 virtual void getProgramiv(GLuint program, | 505 virtual void getProgramiv(GLuint program, |
506 GLenum pname, | 506 GLenum pname, |
507 GLint* value) OVERRIDE { | 507 GLint* value) override { |
508 context_lost_ = true; | 508 context_lost_ = true; |
509 *value = 0; | 509 *value = 0; |
510 } | 510 } |
511 | 511 |
512 virtual void getShaderiv(GLuint shader, GLenum pname, GLint* value) OVERRIDE { | 512 virtual void getShaderiv(GLuint shader, GLenum pname, GLint* value) override { |
513 context_lost_ = true; | 513 context_lost_ = true; |
514 *value = 0; | 514 *value = 0; |
515 } | 515 } |
516 }; | 516 }; |
517 | 517 |
518 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { | 518 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { |
519 FakeOutputSurfaceClient output_surface_client; | 519 FakeOutputSurfaceClient output_surface_client; |
520 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 520 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
521 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); | 521 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); |
522 CHECK(output_surface->BindToClient(&output_surface_client)); | 522 CHECK(output_surface->BindToClient(&output_surface_client)); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 Mock::VerifyAndClearExpectations(context); | 693 Mock::VerifyAndClearExpectations(context); |
694 } | 694 } |
695 | 695 |
696 class VisibilityChangeIsLastCallTrackingContext | 696 class VisibilityChangeIsLastCallTrackingContext |
697 : public TestWebGraphicsContext3D { | 697 : public TestWebGraphicsContext3D { |
698 public: | 698 public: |
699 VisibilityChangeIsLastCallTrackingContext() | 699 VisibilityChangeIsLastCallTrackingContext() |
700 : last_call_was_set_visibility_(false) {} | 700 : last_call_was_set_visibility_(false) {} |
701 | 701 |
702 // TestWebGraphicsContext3D methods. | 702 // TestWebGraphicsContext3D methods. |
703 virtual void flush() OVERRIDE { last_call_was_set_visibility_ = false; } | 703 virtual void flush() override { last_call_was_set_visibility_ = false; } |
704 virtual void deleteTexture(GLuint) OVERRIDE { | 704 virtual void deleteTexture(GLuint) override { |
705 last_call_was_set_visibility_ = false; | 705 last_call_was_set_visibility_ = false; |
706 } | 706 } |
707 virtual void deleteFramebuffer(GLuint) OVERRIDE { | 707 virtual void deleteFramebuffer(GLuint) override { |
708 last_call_was_set_visibility_ = false; | 708 last_call_was_set_visibility_ = false; |
709 } | 709 } |
710 virtual void deleteQueryEXT(GLuint) OVERRIDE { | 710 virtual void deleteQueryEXT(GLuint) override { |
711 last_call_was_set_visibility_ = false; | 711 last_call_was_set_visibility_ = false; |
712 } | 712 } |
713 virtual void deleteRenderbuffer(GLuint) OVERRIDE { | 713 virtual void deleteRenderbuffer(GLuint) override { |
714 last_call_was_set_visibility_ = false; | 714 last_call_was_set_visibility_ = false; |
715 } | 715 } |
716 | 716 |
717 // Methods added for test. | 717 // Methods added for test. |
718 void set_last_call_was_visibility(bool visible) { | 718 void set_last_call_was_visibility(bool visible) { |
719 DCHECK(last_call_was_set_visibility_ == false); | 719 DCHECK(last_call_was_set_visibility_ == false); |
720 last_call_was_set_visibility_ = true; | 720 last_call_was_set_visibility_ = true; |
721 } | 721 } |
722 bool last_call_was_set_visibility() const { | 722 bool last_call_was_set_visibility() const { |
723 return last_call_was_set_visibility_; | 723 return last_call_was_set_visibility_; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 | 972 |
973 // In multiple render passes all but the root pass should clear the | 973 // In multiple render passes all but the root pass should clear the |
974 // framebuffer. | 974 // framebuffer. |
975 Mock::VerifyAndClearExpectations(&mock_context); | 975 Mock::VerifyAndClearExpectations(&mock_context); |
976 } | 976 } |
977 | 977 |
978 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { | 978 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { |
979 public: | 979 public: |
980 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} | 980 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} |
981 | 981 |
982 virtual void clear(GLbitfield) OVERRIDE { EXPECT_FALSE(scissor_enabled_); } | 982 virtual void clear(GLbitfield) override { EXPECT_FALSE(scissor_enabled_); } |
983 | 983 |
984 virtual void enable(GLenum cap) OVERRIDE { | 984 virtual void enable(GLenum cap) override { |
985 if (cap == GL_SCISSOR_TEST) | 985 if (cap == GL_SCISSOR_TEST) |
986 scissor_enabled_ = true; | 986 scissor_enabled_ = true; |
987 } | 987 } |
988 | 988 |
989 virtual void disable(GLenum cap) OVERRIDE { | 989 virtual void disable(GLenum cap) override { |
990 if (cap == GL_SCISSOR_TEST) | 990 if (cap == GL_SCISSOR_TEST) |
991 scissor_enabled_ = false; | 991 scissor_enabled_ = false; |
992 } | 992 } |
993 | 993 |
994 private: | 994 private: |
995 bool scissor_enabled_; | 995 bool scissor_enabled_; |
996 }; | 996 }; |
997 | 997 |
998 TEST_F(GLRendererTest, ScissorTestWhenClearing) { | 998 TEST_F(GLRendererTest, ScissorTestWhenClearing) { |
999 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( | 999 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 | 1062 |
1063 class DiscardCheckingContext : public TestWebGraphicsContext3D { | 1063 class DiscardCheckingContext : public TestWebGraphicsContext3D { |
1064 public: | 1064 public: |
1065 DiscardCheckingContext() : discarded_(0) { | 1065 DiscardCheckingContext() : discarded_(0) { |
1066 set_have_post_sub_buffer(true); | 1066 set_have_post_sub_buffer(true); |
1067 set_have_discard_framebuffer(true); | 1067 set_have_discard_framebuffer(true); |
1068 } | 1068 } |
1069 | 1069 |
1070 virtual void discardFramebufferEXT(GLenum target, | 1070 virtual void discardFramebufferEXT(GLenum target, |
1071 GLsizei numAttachments, | 1071 GLsizei numAttachments, |
1072 const GLenum* attachments) OVERRIDE { | 1072 const GLenum* attachments) override { |
1073 ++discarded_; | 1073 ++discarded_; |
1074 } | 1074 } |
1075 | 1075 |
1076 int discarded() const { return discarded_; } | 1076 int discarded() const { return discarded_; } |
1077 void reset() { discarded_ = 0; } | 1077 void reset() { discarded_ = 0; } |
1078 | 1078 |
1079 private: | 1079 private: |
1080 int discarded_; | 1080 int discarded_; |
1081 }; | 1081 }; |
1082 | 1082 |
1083 class NonReshapableOutputSurface : public FakeOutputSurface { | 1083 class NonReshapableOutputSurface : public FakeOutputSurface { |
1084 public: | 1084 public: |
1085 explicit NonReshapableOutputSurface( | 1085 explicit NonReshapableOutputSurface( |
1086 scoped_ptr<TestWebGraphicsContext3D> context3d) | 1086 scoped_ptr<TestWebGraphicsContext3D> context3d) |
1087 : FakeOutputSurface(TestContextProvider::Create(context3d.Pass()), | 1087 : FakeOutputSurface(TestContextProvider::Create(context3d.Pass()), |
1088 false) { | 1088 false) { |
1089 surface_size_ = gfx::Size(500, 500); | 1089 surface_size_ = gfx::Size(500, 500); |
1090 } | 1090 } |
1091 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE {} | 1091 virtual void Reshape(const gfx::Size& size, float scale_factor) override {} |
1092 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; } | 1092 void set_fixed_size(const gfx::Size& size) { surface_size_ = size; } |
1093 }; | 1093 }; |
1094 | 1094 |
1095 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { | 1095 TEST_F(GLRendererTest, NoDiscardOnPartialUpdates) { |
1096 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); | 1096 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); |
1097 DiscardCheckingContext* context = context_owned.get(); | 1097 DiscardCheckingContext* context = context_owned.get(); |
1098 | 1098 |
1099 FakeOutputSurfaceClient output_surface_client; | 1099 FakeOutputSurfaceClient output_surface_client; |
1100 scoped_ptr<NonReshapableOutputSurface> output_surface( | 1100 scoped_ptr<NonReshapableOutputSurface> output_surface( |
1101 new NonReshapableOutputSurface(context_owned.Pass())); | 1101 new NonReshapableOutputSurface(context_owned.Pass())); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 class FlippedScissorAndViewportContext : public TestWebGraphicsContext3D { | 1251 class FlippedScissorAndViewportContext : public TestWebGraphicsContext3D { |
1252 public: | 1252 public: |
1253 FlippedScissorAndViewportContext() | 1253 FlippedScissorAndViewportContext() |
1254 : did_call_viewport_(false), did_call_scissor_(false) {} | 1254 : did_call_viewport_(false), did_call_scissor_(false) {} |
1255 virtual ~FlippedScissorAndViewportContext() { | 1255 virtual ~FlippedScissorAndViewportContext() { |
1256 EXPECT_TRUE(did_call_viewport_); | 1256 EXPECT_TRUE(did_call_viewport_); |
1257 EXPECT_TRUE(did_call_scissor_); | 1257 EXPECT_TRUE(did_call_scissor_); |
1258 } | 1258 } |
1259 | 1259 |
1260 virtual void viewport(GLint x, GLint y, GLsizei width, GLsizei height) | 1260 virtual void viewport(GLint x, GLint y, GLsizei width, GLsizei height) |
1261 OVERRIDE { | 1261 override { |
1262 EXPECT_EQ(10, x); | 1262 EXPECT_EQ(10, x); |
1263 EXPECT_EQ(390, y); | 1263 EXPECT_EQ(390, y); |
1264 EXPECT_EQ(100, width); | 1264 EXPECT_EQ(100, width); |
1265 EXPECT_EQ(100, height); | 1265 EXPECT_EQ(100, height); |
1266 did_call_viewport_ = true; | 1266 did_call_viewport_ = true; |
1267 } | 1267 } |
1268 | 1268 |
1269 virtual void scissor(GLint x, GLint y, GLsizei width, GLsizei height) | 1269 virtual void scissor(GLint x, GLint y, GLsizei width, GLsizei height) |
1270 OVERRIDE { | 1270 override { |
1271 EXPECT_EQ(30, x); | 1271 EXPECT_EQ(30, x); |
1272 EXPECT_EQ(450, y); | 1272 EXPECT_EQ(450, y); |
1273 EXPECT_EQ(20, width); | 1273 EXPECT_EQ(20, width); |
1274 EXPECT_EQ(20, height); | 1274 EXPECT_EQ(20, height); |
1275 did_call_scissor_ = true; | 1275 did_call_scissor_ = true; |
1276 } | 1276 } |
1277 | 1277 |
1278 private: | 1278 private: |
1279 bool did_call_viewport_; | 1279 bool did_call_viewport_; |
1280 bool did_call_scissor_; | 1280 bool did_call_scissor_; |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 base::MessageLoop::current()->Run(); | 1836 base::MessageLoop::current()->Run(); |
1837 | 1837 |
1838 // The sync point should have happened. | 1838 // The sync point should have happened. |
1839 EXPECT_EQ(1, sync_point_callback_count); | 1839 EXPECT_EQ(1, sync_point_callback_count); |
1840 EXPECT_EQ(1, other_callback_count); | 1840 EXPECT_EQ(1, other_callback_count); |
1841 } | 1841 } |
1842 #endif // OS_ANDROID | 1842 #endif // OS_ANDROID |
1843 | 1843 |
1844 } // namespace | 1844 } // namespace |
1845 } // namespace cc | 1845 } // namespace cc |
OLD | NEW |