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 22 matching lines...) Expand all Loading... |
33 using testing::_; | 33 using testing::_; |
34 using testing::AnyNumber; | 34 using testing::AnyNumber; |
35 using testing::Args; | 35 using testing::Args; |
36 using testing::AtLeast; | 36 using testing::AtLeast; |
37 using testing::ElementsAre; | 37 using testing::ElementsAre; |
38 using testing::Expectation; | 38 using testing::Expectation; |
39 using testing::InSequence; | 39 using testing::InSequence; |
40 using testing::Mock; | 40 using testing::Mock; |
41 using testing::Return; | 41 using testing::Return; |
42 using testing::StrictMock; | 42 using testing::StrictMock; |
43 using blink::WebGLId; | |
44 using blink::WebString; | 43 using blink::WebString; |
45 using blink::WGC3Dbitfield; | |
46 using blink::WGC3Dboolean; | |
47 using blink::WGC3Dchar; | |
48 using blink::WGC3Denum; | |
49 using blink::WGC3Dfloat; | |
50 using blink::WGC3Dint; | |
51 using blink::WGC3Dintptr; | |
52 using blink::WGC3Dsizei; | |
53 using blink::WGC3Dsizeiptr; | |
54 using blink::WGC3Duint; | |
55 | 44 |
56 namespace cc { | 45 namespace cc { |
57 | 46 |
58 class GLRendererTest : public testing::Test { | 47 class GLRendererTest : public testing::Test { |
59 protected: | 48 protected: |
60 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } | 49 RenderPass* root_render_pass() { return render_passes_in_draw_order_.back(); } |
61 | 50 |
62 RenderPassList render_passes_in_draw_order_; | 51 RenderPassList render_passes_in_draw_order_; |
63 }; | 52 }; |
64 | 53 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 viewport_rect, | 390 viewport_rect, |
402 true, | 391 true, |
403 false); | 392 false); |
404 EXPECT_TRUE(renderer_->stencil_enabled()); | 393 EXPECT_TRUE(renderer_->stencil_enabled()); |
405 } | 394 } |
406 | 395 |
407 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { | 396 class ForbidSynchronousCallContext : public TestWebGraphicsContext3D { |
408 public: | 397 public: |
409 ForbidSynchronousCallContext() {} | 398 ForbidSynchronousCallContext() {} |
410 | 399 |
411 virtual bool getActiveAttrib(WebGLId program, | 400 virtual bool getActiveAttrib(GLuint program, |
412 WGC3Duint index, | 401 GLuint index, |
413 blink::WebGraphicsContext3D::ActiveInfo& info) | 402 blink::WebGraphicsContext3D::ActiveInfo& info) |
414 OVERRIDE { | 403 OVERRIDE { |
415 ADD_FAILURE(); | 404 ADD_FAILURE(); |
416 return false; | 405 return false; |
417 } | 406 } |
418 virtual bool getActiveUniform(WebGLId program, | 407 virtual bool getActiveUniform(GLuint program, |
419 WGC3Duint index, | 408 GLuint index, |
420 blink::WebGraphicsContext3D::ActiveInfo& info) | 409 blink::WebGraphicsContext3D::ActiveInfo& info) |
421 OVERRIDE { | 410 OVERRIDE { |
422 ADD_FAILURE(); | 411 ADD_FAILURE(); |
423 return false; | 412 return false; |
424 } | 413 } |
425 virtual void getAttachedShaders(WebGLId program, | 414 virtual void getAttachedShaders(GLuint program, |
426 WGC3Dsizei max_count, | 415 GLsizei max_count, |
427 WGC3Dsizei* count, | 416 GLsizei* count, |
428 WebGLId* shaders) OVERRIDE { | 417 GLuint* shaders) OVERRIDE { |
429 ADD_FAILURE(); | 418 ADD_FAILURE(); |
430 } | 419 } |
431 virtual WGC3Dint getAttribLocation(WebGLId program, | 420 virtual GLint getAttribLocation(GLuint program, const GLchar* name) OVERRIDE { |
432 const WGC3Dchar* name) OVERRIDE { | |
433 ADD_FAILURE(); | 421 ADD_FAILURE(); |
434 return 0; | 422 return 0; |
435 } | 423 } |
436 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) OVERRIDE { | 424 virtual void getBooleanv(GLenum pname, GLboolean* value) OVERRIDE { |
437 ADD_FAILURE(); | 425 ADD_FAILURE(); |
438 } | 426 } |
439 virtual void getBufferParameteriv(WGC3Denum target, | 427 virtual void getBufferParameteriv(GLenum target, |
440 WGC3Denum pname, | 428 GLenum pname, |
441 WGC3Dint* value) OVERRIDE { | 429 GLint* value) OVERRIDE { |
442 ADD_FAILURE(); | 430 ADD_FAILURE(); |
443 } | 431 } |
444 virtual WGC3Denum getError() OVERRIDE { | 432 virtual GLenum getError() OVERRIDE { |
445 ADD_FAILURE(); | 433 ADD_FAILURE(); |
446 return 0; | 434 return GL_NO_ERROR; |
447 } | 435 } |
448 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) OVERRIDE { | 436 virtual void getFloatv(GLenum pname, GLfloat* value) OVERRIDE { |
449 ADD_FAILURE(); | 437 ADD_FAILURE(); |
450 } | 438 } |
451 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, | 439 virtual void getFramebufferAttachmentParameteriv(GLenum target, |
452 WGC3Denum attachment, | 440 GLenum attachment, |
453 WGC3Denum pname, | 441 GLenum pname, |
454 WGC3Dint* value) OVERRIDE { | 442 GLint* value) OVERRIDE { |
455 ADD_FAILURE(); | 443 ADD_FAILURE(); |
456 } | 444 } |
457 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) OVERRIDE { | 445 virtual void getIntegerv(GLenum pname, GLint* value) OVERRIDE { |
458 if (pname == GL_MAX_TEXTURE_SIZE) { | 446 if (pname == GL_MAX_TEXTURE_SIZE) { |
459 // MAX_TEXTURE_SIZE is cached client side, so it's OK to query. | 447 // MAX_TEXTURE_SIZE is cached client side, so it's OK to query. |
460 *value = 1024; | 448 *value = 1024; |
461 } else { | 449 } else { |
462 ADD_FAILURE(); | 450 ADD_FAILURE(); |
463 } | 451 } |
464 } | 452 } |
465 | 453 |
466 // We allow querying the shader compilation and program link status in debug | 454 // We allow querying the shader compilation and program link status in debug |
467 // mode, but not release. | 455 // mode, but not release. |
468 virtual void getProgramiv(WebGLId program, | 456 virtual void getProgramiv(GLuint program, |
469 WGC3Denum pname, | 457 GLenum pname, |
470 WGC3Dint* value) OVERRIDE { | 458 GLint* value) OVERRIDE { |
471 #ifndef NDEBUG | 459 #ifndef NDEBUG |
472 *value = 1; | 460 *value = 1; |
473 #else | 461 #else |
474 ADD_FAILURE(); | 462 ADD_FAILURE(); |
475 #endif | 463 #endif |
476 } | 464 } |
477 | 465 |
478 virtual void getShaderiv(WebGLId shader, | 466 virtual void getShaderiv(GLuint shader, GLenum pname, GLint* value) OVERRIDE { |
479 WGC3Denum pname, | |
480 WGC3Dint* value) OVERRIDE { | |
481 #ifndef NDEBUG | 467 #ifndef NDEBUG |
482 *value = 1; | 468 *value = 1; |
483 #else | 469 #else |
484 ADD_FAILURE(); | 470 ADD_FAILURE(); |
485 #endif | 471 #endif |
486 } | 472 } |
487 | 473 |
488 virtual WebString getString(WGC3Denum name) OVERRIDE { | 474 virtual WebString getString(GLenum name) OVERRIDE { |
489 ADD_FAILURE() << name; | 475 ADD_FAILURE() << name; |
490 return WebString(); | 476 return WebString(); |
491 } | 477 } |
492 | 478 |
493 virtual WebString getProgramInfoLog(WebGLId program) OVERRIDE { | 479 virtual WebString getProgramInfoLog(GLuint program) OVERRIDE { |
494 ADD_FAILURE(); | 480 ADD_FAILURE(); |
495 return WebString(); | 481 return WebString(); |
496 } | 482 } |
497 virtual void getRenderbufferParameteriv(WGC3Denum target, | 483 virtual void getRenderbufferParameteriv(GLenum target, |
498 WGC3Denum pname, | 484 GLenum pname, |
499 WGC3Dint* value) OVERRIDE { | 485 GLint* value) OVERRIDE { |
500 ADD_FAILURE(); | 486 ADD_FAILURE(); |
501 } | 487 } |
502 | 488 |
503 virtual WebString getShaderInfoLog(WebGLId shader) OVERRIDE { | 489 virtual WebString getShaderInfoLog(GLuint shader) OVERRIDE { |
504 ADD_FAILURE(); | 490 ADD_FAILURE(); |
505 return WebString(); | 491 return WebString(); |
506 } | 492 } |
507 virtual void getShaderPrecisionFormat(WGC3Denum shadertype, | 493 virtual void getShaderPrecisionFormat(GLenum shadertype, |
508 WGC3Denum precisiontype, | 494 GLenum precisiontype, |
509 WGC3Dint* range, | 495 GLint* range, |
510 WGC3Dint* precision) OVERRIDE { | 496 GLint* precision) OVERRIDE { |
511 ADD_FAILURE(); | 497 ADD_FAILURE(); |
512 } | 498 } |
513 virtual WebString getShaderSource(WebGLId shader) OVERRIDE { | 499 virtual WebString getShaderSource(GLuint shader) OVERRIDE { |
514 ADD_FAILURE(); | 500 ADD_FAILURE(); |
515 return WebString(); | 501 return WebString(); |
516 } | 502 } |
517 virtual void getTexParameterfv(WGC3Denum target, | 503 virtual void getTexParameterfv(GLenum target, |
518 WGC3Denum pname, | 504 GLenum pname, |
519 WGC3Dfloat* value) OVERRIDE { | 505 GLfloat* value) OVERRIDE { |
520 ADD_FAILURE(); | 506 ADD_FAILURE(); |
521 } | 507 } |
522 virtual void getTexParameteriv(WGC3Denum target, | 508 virtual void getTexParameteriv(GLenum target, |
523 WGC3Denum pname, | 509 GLenum pname, |
524 WGC3Dint* value) OVERRIDE { | 510 GLint* value) OVERRIDE { |
525 ADD_FAILURE(); | 511 ADD_FAILURE(); |
526 } | 512 } |
527 virtual void getUniformfv(WebGLId program, | 513 virtual void getUniformfv(GLuint program, |
528 WGC3Dint location, | 514 GLint location, |
529 WGC3Dfloat* value) OVERRIDE { | 515 GLfloat* value) OVERRIDE { |
530 ADD_FAILURE(); | 516 ADD_FAILURE(); |
531 } | 517 } |
532 virtual void getUniformiv(WebGLId program, | 518 virtual void getUniformiv(GLuint program, |
533 WGC3Dint location, | 519 GLint location, |
534 WGC3Dint* value) OVERRIDE { | 520 GLint* value) OVERRIDE { |
535 ADD_FAILURE(); | 521 ADD_FAILURE(); |
536 } | 522 } |
537 virtual WGC3Dint getUniformLocation(WebGLId program, | 523 virtual GLint getUniformLocation(GLuint program, |
538 const WGC3Dchar* name) OVERRIDE { | 524 const GLchar* name) OVERRIDE { |
539 ADD_FAILURE(); | 525 ADD_FAILURE(); |
540 return 0; | 526 return 0; |
541 } | 527 } |
542 virtual void getVertexAttribfv(WGC3Duint index, | 528 virtual void getVertexAttribfv(GLuint index, |
543 WGC3Denum pname, | 529 GLenum pname, |
544 WGC3Dfloat* value) OVERRIDE { | 530 GLfloat* value) OVERRIDE { |
545 ADD_FAILURE(); | 531 ADD_FAILURE(); |
546 } | 532 } |
547 virtual void getVertexAttribiv(WGC3Duint index, | 533 virtual void getVertexAttribiv(GLuint index, |
548 WGC3Denum pname, | 534 GLenum pname, |
549 WGC3Dint* value) OVERRIDE { | 535 GLint* value) OVERRIDE { |
550 ADD_FAILURE(); | 536 ADD_FAILURE(); |
551 } | 537 } |
552 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, | 538 virtual GLsizeiptr getVertexAttribOffset(GLuint index, |
553 WGC3Denum pname) OVERRIDE { | 539 GLenum pname) OVERRIDE { |
554 ADD_FAILURE(); | 540 ADD_FAILURE(); |
555 return 0; | 541 return 0; |
556 } | 542 } |
557 }; | 543 }; |
558 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { | 544 TEST_F(GLRendererTest, InitializationDoesNotMakeSynchronousCalls) { |
559 FakeOutputSurfaceClient output_surface_client; | 545 FakeOutputSurfaceClient output_surface_client; |
560 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 546 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
561 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); | 547 scoped_ptr<TestWebGraphicsContext3D>(new ForbidSynchronousCallContext))); |
562 CHECK(output_surface->BindToClient(&output_surface_client)); | 548 CHECK(output_surface->BindToClient(&output_surface_client)); |
563 | 549 |
564 scoped_ptr<ResourceProvider> resource_provider( | 550 scoped_ptr<ResourceProvider> resource_provider( |
565 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 551 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
566 | 552 |
567 LayerTreeSettings settings; | 553 LayerTreeSettings settings; |
568 FakeRendererClient renderer_client; | 554 FakeRendererClient renderer_client; |
569 FakeRendererGL renderer(&renderer_client, | 555 FakeRendererGL renderer(&renderer_client, |
570 &settings, | 556 &settings, |
571 output_surface.get(), | 557 output_surface.get(), |
572 resource_provider.get()); | 558 resource_provider.get()); |
573 } | 559 } |
574 | 560 |
575 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { | 561 class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { |
576 public: | 562 public: |
577 LoseContextOnFirstGetContext() {} | 563 LoseContextOnFirstGetContext() {} |
578 | 564 |
579 virtual void getProgramiv(WebGLId program, | 565 virtual void getProgramiv(GLuint program, |
580 WGC3Denum pname, | 566 GLenum pname, |
581 WGC3Dint* value) OVERRIDE { | 567 GLint* value) OVERRIDE { |
582 context_lost_ = true; | 568 context_lost_ = true; |
583 *value = 0; | 569 *value = 0; |
584 } | 570 } |
585 | 571 |
586 virtual void getShaderiv(WebGLId shader, | 572 virtual void getShaderiv(GLuint shader, GLenum pname, GLint* value) OVERRIDE { |
587 WGC3Denum pname, | |
588 WGC3Dint* value) OVERRIDE { | |
589 context_lost_ = true; | 573 context_lost_ = true; |
590 *value = 0; | 574 *value = 0; |
591 } | 575 } |
592 }; | 576 }; |
593 | 577 |
594 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { | 578 TEST_F(GLRendererTest, InitializationWithQuicklyLostContextDoesNotAssert) { |
595 FakeOutputSurfaceClient output_surface_client; | 579 FakeOutputSurfaceClient output_surface_client; |
596 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 580 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
597 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); | 581 scoped_ptr<TestWebGraphicsContext3D>(new LoseContextOnFirstGetContext))); |
598 CHECK(output_surface->BindToClient(&output_surface_client)); | 582 CHECK(output_surface->BindToClient(&output_surface_client)); |
599 | 583 |
600 scoped_ptr<ResourceProvider> resource_provider( | 584 scoped_ptr<ResourceProvider> resource_provider( |
601 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); | 585 ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); |
602 | 586 |
603 LayerTreeSettings settings; | 587 LayerTreeSettings settings; |
604 FakeRendererClient renderer_client; | 588 FakeRendererClient renderer_client; |
605 FakeRendererGL renderer(&renderer_client, | 589 FakeRendererGL renderer(&renderer_client, |
606 &settings, | 590 &settings, |
607 output_surface.get(), | 591 output_surface.get(), |
608 resource_provider.get()); | 592 resource_provider.get()); |
609 } | 593 } |
610 | 594 |
611 class ClearCountingContext : public TestWebGraphicsContext3D { | 595 class ClearCountingContext : public TestWebGraphicsContext3D { |
612 public: | 596 public: |
613 ClearCountingContext() { test_capabilities_.discard_framebuffer = true; } | 597 ClearCountingContext() { test_capabilities_.discard_framebuffer = true; } |
614 | 598 |
615 MOCK_METHOD3(discardFramebufferEXT, | 599 MOCK_METHOD3(discardFramebufferEXT, |
616 void(WGC3Denum target, | 600 void(GLenum target, |
617 WGC3Dsizei numAttachments, | 601 GLsizei numAttachments, |
618 const WGC3Denum* attachments)); | 602 const GLenum* attachments)); |
619 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); | 603 MOCK_METHOD1(clear, void(GLbitfield mask)); |
620 }; | 604 }; |
621 | 605 |
622 TEST_F(GLRendererTest, OpaqueBackground) { | 606 TEST_F(GLRendererTest, OpaqueBackground) { |
623 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); | 607 scoped_ptr<ClearCountingContext> context_owned(new ClearCountingContext); |
624 ClearCountingContext* context = context_owned.get(); | 608 ClearCountingContext* context = context_owned.get(); |
625 | 609 |
626 FakeOutputSurfaceClient output_surface_client; | 610 FakeOutputSurfaceClient output_surface_client; |
627 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 611 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
628 context_owned.PassAs<TestWebGraphicsContext3D>())); | 612 context_owned.PassAs<TestWebGraphicsContext3D>())); |
629 CHECK(output_surface->BindToClient(&output_surface_client)); | 613 CHECK(output_surface->BindToClient(&output_surface_client)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 false); | 726 false); |
743 Mock::VerifyAndClearExpectations(context); | 727 Mock::VerifyAndClearExpectations(context); |
744 } | 728 } |
745 | 729 |
746 class VisibilityChangeIsLastCallTrackingContext | 730 class VisibilityChangeIsLastCallTrackingContext |
747 : public TestWebGraphicsContext3D { | 731 : public TestWebGraphicsContext3D { |
748 public: | 732 public: |
749 VisibilityChangeIsLastCallTrackingContext() | 733 VisibilityChangeIsLastCallTrackingContext() |
750 : last_call_was_set_visibility_(false) {} | 734 : last_call_was_set_visibility_(false) {} |
751 | 735 |
752 // WebGraphicsContext3D methods. | 736 // TestWebGraphicsContext3D methods. |
753 virtual void flush() OVERRIDE { last_call_was_set_visibility_ = false; } | 737 virtual void flush() OVERRIDE { last_call_was_set_visibility_ = false; } |
754 virtual void deleteTexture(WebGLId) OVERRIDE { | 738 virtual void deleteTexture(GLuint) OVERRIDE { |
755 last_call_was_set_visibility_ = false; | 739 last_call_was_set_visibility_ = false; |
756 } | 740 } |
757 virtual void deleteFramebuffer(WebGLId) OVERRIDE { | 741 virtual void deleteFramebuffer(GLuint) OVERRIDE { |
758 last_call_was_set_visibility_ = false; | 742 last_call_was_set_visibility_ = false; |
759 } | 743 } |
760 virtual void deleteQueryEXT(WebGLId) OVERRIDE { | 744 virtual void deleteQueryEXT(GLuint) OVERRIDE { |
761 last_call_was_set_visibility_ = false; | 745 last_call_was_set_visibility_ = false; |
762 } | 746 } |
763 virtual void deleteRenderbuffer(WebGLId) OVERRIDE { | 747 virtual void deleteRenderbuffer(GLuint) OVERRIDE { |
764 last_call_was_set_visibility_ = false; | 748 last_call_was_set_visibility_ = false; |
765 } | 749 } |
766 | 750 |
767 // Methods added for test. | 751 // Methods added for test. |
768 void set_last_call_was_visibility(bool visible) { | 752 void set_last_call_was_visibility(bool visible) { |
769 DCHECK(last_call_was_set_visibility_ == false); | 753 DCHECK(last_call_was_set_visibility_ == false); |
770 last_call_was_set_visibility_ = true; | 754 last_call_was_set_visibility_ = true; |
771 } | 755 } |
772 bool last_call_was_set_visibility() const { | 756 bool last_call_was_set_visibility() const { |
773 return last_call_was_set_visibility_; | 757 return last_call_was_set_visibility_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 renderer.SetVisible(false); | 810 renderer.SetVisible(false); |
827 EXPECT_TRUE(context->last_call_was_set_visibility()); | 811 EXPECT_TRUE(context->last_call_was_set_visibility()); |
828 } | 812 } |
829 | 813 |
830 class TextureStateTrackingContext : public TestWebGraphicsContext3D { | 814 class TextureStateTrackingContext : public TestWebGraphicsContext3D { |
831 public: | 815 public: |
832 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) { | 816 TextureStateTrackingContext() : active_texture_(GL_INVALID_ENUM) { |
833 test_capabilities_.egl_image_external = true; | 817 test_capabilities_.egl_image_external = true; |
834 } | 818 } |
835 | 819 |
836 MOCK_METHOD3(texParameteri, | 820 MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); |
837 void(WGC3Denum target, WGC3Denum pname, WGC3Dint param)); | |
838 MOCK_METHOD4(drawElements, | 821 MOCK_METHOD4(drawElements, |
839 void(WGC3Denum mode, | 822 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
840 WGC3Dsizei count, | |
841 WGC3Denum type, | |
842 WGC3Dintptr offset)); | |
843 | 823 |
844 virtual void activeTexture(WGC3Denum texture) { | 824 virtual void activeTexture(GLenum texture) { |
845 EXPECT_NE(texture, active_texture_); | 825 EXPECT_NE(texture, active_texture_); |
846 active_texture_ = texture; | 826 active_texture_ = texture; |
847 } | 827 } |
848 | 828 |
849 WGC3Denum active_texture() const { return active_texture_; } | 829 GLenum active_texture() const { return active_texture_; } |
850 | 830 |
851 private: | 831 private: |
852 WGC3Denum active_texture_; | 832 GLenum active_texture_; |
853 }; | 833 }; |
854 | 834 |
855 TEST_F(GLRendererTest, ActiveTextureState) { | 835 TEST_F(GLRendererTest, ActiveTextureState) { |
856 scoped_ptr<TextureStateTrackingContext> context_owned( | 836 scoped_ptr<TextureStateTrackingContext> context_owned( |
857 new TextureStateTrackingContext); | 837 new TextureStateTrackingContext); |
858 TextureStateTrackingContext* context = context_owned.get(); | 838 TextureStateTrackingContext* context = context_owned.get(); |
859 | 839 |
860 FakeOutputSurfaceClient output_surface_client; | 840 FakeOutputSurfaceClient output_surface_client; |
861 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 841 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
862 context_owned.PassAs<TestWebGraphicsContext3D>())); | 842 context_owned.PassAs<TestWebGraphicsContext3D>())); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 1.f, | 899 1.f, |
920 viewport_rect, | 900 viewport_rect, |
921 viewport_rect, | 901 viewport_rect, |
922 true, | 902 true, |
923 false); | 903 false); |
924 Mock::VerifyAndClearExpectations(context); | 904 Mock::VerifyAndClearExpectations(context); |
925 } | 905 } |
926 | 906 |
927 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { | 907 class NoClearRootRenderPassMockContext : public TestWebGraphicsContext3D { |
928 public: | 908 public: |
929 MOCK_METHOD1(clear, void(WGC3Dbitfield mask)); | 909 MOCK_METHOD1(clear, void(GLbitfield mask)); |
930 MOCK_METHOD4(drawElements, | 910 MOCK_METHOD4(drawElements, |
931 void(WGC3Denum mode, | 911 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
932 WGC3Dsizei count, | |
933 WGC3Denum type, | |
934 WGC3Dintptr offset)); | |
935 }; | 912 }; |
936 | 913 |
937 TEST_F(GLRendererTest, ShouldClearRootRenderPass) { | 914 TEST_F(GLRendererTest, ShouldClearRootRenderPass) { |
938 scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( | 915 scoped_ptr<NoClearRootRenderPassMockContext> mock_context_owned( |
939 new NoClearRootRenderPassMockContext); | 916 new NoClearRootRenderPassMockContext); |
940 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); | 917 NoClearRootRenderPassMockContext* mock_context = mock_context_owned.get(); |
941 | 918 |
942 FakeOutputSurfaceClient output_surface_client; | 919 FakeOutputSurfaceClient output_surface_client; |
943 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 920 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
944 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); | 921 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 981 |
1005 // In multiple render passes all but the root pass should clear the | 982 // In multiple render passes all but the root pass should clear the |
1006 // framebuffer. | 983 // framebuffer. |
1007 Mock::VerifyAndClearExpectations(&mock_context); | 984 Mock::VerifyAndClearExpectations(&mock_context); |
1008 } | 985 } |
1009 | 986 |
1010 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { | 987 class ScissorTestOnClearCheckingContext : public TestWebGraphicsContext3D { |
1011 public: | 988 public: |
1012 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} | 989 ScissorTestOnClearCheckingContext() : scissor_enabled_(false) {} |
1013 | 990 |
1014 virtual void clear(WGC3Dbitfield) OVERRIDE { EXPECT_FALSE(scissor_enabled_); } | 991 virtual void clear(GLbitfield) OVERRIDE { EXPECT_FALSE(scissor_enabled_); } |
1015 | 992 |
1016 virtual void enable(WGC3Denum cap) OVERRIDE { | 993 virtual void enable(GLenum cap) OVERRIDE { |
1017 if (cap == GL_SCISSOR_TEST) | 994 if (cap == GL_SCISSOR_TEST) |
1018 scissor_enabled_ = true; | 995 scissor_enabled_ = true; |
1019 } | 996 } |
1020 | 997 |
1021 virtual void disable(WGC3Denum cap) OVERRIDE { | 998 virtual void disable(GLenum cap) OVERRIDE { |
1022 if (cap == GL_SCISSOR_TEST) | 999 if (cap == GL_SCISSOR_TEST) |
1023 scissor_enabled_ = false; | 1000 scissor_enabled_ = false; |
1024 } | 1001 } |
1025 | 1002 |
1026 private: | 1003 private: |
1027 bool scissor_enabled_; | 1004 bool scissor_enabled_; |
1028 }; | 1005 }; |
1029 | 1006 |
1030 TEST_F(GLRendererTest, ScissorTestWhenClearing) { | 1007 TEST_F(GLRendererTest, ScissorTestWhenClearing) { |
1031 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( | 1008 scoped_ptr<ScissorTestOnClearCheckingContext> context_owned( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 false); | 1063 false); |
1087 } | 1064 } |
1088 | 1065 |
1089 class DiscardCheckingContext : public TestWebGraphicsContext3D { | 1066 class DiscardCheckingContext : public TestWebGraphicsContext3D { |
1090 public: | 1067 public: |
1091 DiscardCheckingContext() : discarded_(0) { | 1068 DiscardCheckingContext() : discarded_(0) { |
1092 set_have_post_sub_buffer(true); | 1069 set_have_post_sub_buffer(true); |
1093 set_have_discard_framebuffer(true); | 1070 set_have_discard_framebuffer(true); |
1094 } | 1071 } |
1095 | 1072 |
1096 virtual void discardFramebufferEXT(WGC3Denum target, | 1073 virtual void discardFramebufferEXT(GLenum target, |
1097 WGC3Dsizei numAttachments, | 1074 GLsizei numAttachments, |
1098 const WGC3Denum* attachments) OVERRIDE { | 1075 const GLenum* attachments) OVERRIDE { |
1099 ++discarded_; | 1076 ++discarded_; |
1100 } | 1077 } |
1101 | 1078 |
1102 int discarded() const { return discarded_; } | 1079 int discarded() const { return discarded_; } |
1103 void reset() { discarded_ = 0; } | 1080 void reset() { discarded_ = 0; } |
1104 | 1081 |
1105 private: | 1082 private: |
1106 int discarded_; | 1083 int discarded_; |
1107 }; | 1084 }; |
1108 | 1085 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 | 1678 |
1702 TestSolidColorProgramAA(); | 1679 TestSolidColorProgramAA(); |
1703 } | 1680 } |
1704 | 1681 |
1705 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { | 1682 class OutputSurfaceMockContext : public TestWebGraphicsContext3D { |
1706 public: | 1683 public: |
1707 OutputSurfaceMockContext() { test_capabilities_.post_sub_buffer = true; } | 1684 OutputSurfaceMockContext() { test_capabilities_.post_sub_buffer = true; } |
1708 | 1685 |
1709 // Specifically override methods even if they are unused (used in conjunction | 1686 // Specifically override methods even if they are unused (used in conjunction |
1710 // with StrictMock). We need to make sure that GLRenderer does not issue | 1687 // with StrictMock). We need to make sure that GLRenderer does not issue |
1711 // framebuffer-related GL calls directly. Instead these are supposed to go | 1688 // framebuffer-related GLuint calls directly. Instead these are supposed to go |
1712 // through the OutputSurface abstraction. | 1689 // through the OutputSurface abstraction. |
1713 MOCK_METHOD2(bindFramebuffer, void(WGC3Denum target, WebGLId framebuffer)); | 1690 MOCK_METHOD2(bindFramebuffer, void(GLenum target, GLuint framebuffer)); |
1714 MOCK_METHOD3(reshapeWithScaleFactor, | 1691 MOCK_METHOD3(reshapeWithScaleFactor, |
1715 void(int width, int height, float scale_factor)); | 1692 void(int width, int height, float scale_factor)); |
1716 MOCK_METHOD4(drawElements, | 1693 MOCK_METHOD4(drawElements, |
1717 void(WGC3Denum mode, | 1694 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
1718 WGC3Dsizei count, | |
1719 WGC3Denum type, | |
1720 WGC3Dintptr offset)); | |
1721 }; | 1695 }; |
1722 | 1696 |
1723 class MockOutputSurface : public OutputSurface { | 1697 class MockOutputSurface : public OutputSurface { |
1724 public: | 1698 public: |
1725 MockOutputSurface() | 1699 MockOutputSurface() |
1726 : OutputSurface( | 1700 : OutputSurface( |
1727 TestContextProvider::Create(scoped_ptr<TestWebGraphicsContext3D>( | 1701 TestContextProvider::Create(scoped_ptr<TestWebGraphicsContext3D>( |
1728 new StrictMock<OutputSurfaceMockContext>))) { | 1702 new StrictMock<OutputSurfaceMockContext>))) { |
1729 surface_size_ = gfx::Size(100, 100); | 1703 surface_size_ = gfx::Size(100, 100); |
1730 } | 1704 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 base::MessageLoop::current()->Run(); | 1873 base::MessageLoop::current()->Run(); |
1900 | 1874 |
1901 // The sync point should have happened. | 1875 // The sync point should have happened. |
1902 EXPECT_EQ(1, sync_point_callback_count); | 1876 EXPECT_EQ(1, sync_point_callback_count); |
1903 EXPECT_EQ(1, other_callback_count); | 1877 EXPECT_EQ(1, other_callback_count); |
1904 } | 1878 } |
1905 #endif // OS_ANDROID | 1879 #endif // OS_ANDROID |
1906 | 1880 |
1907 } // namespace | 1881 } // namespace |
1908 } // namespace cc | 1882 } // namespace cc |
OLD | NEW |