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

Side by Side Diff: gpu/command_buffer/service/framebuffer_manager_unittest.cc

Issue 16293004: Update gpu/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "gpu/command_buffer/service/error_state_mock.h" 5 #include "gpu/command_buffer/service/error_state_mock.h"
6 #include "gpu/command_buffer/service/framebuffer_manager.h" 6 #include "gpu/command_buffer/service/framebuffer_manager.h"
7 #include "gpu/command_buffer/service/feature_info.h" 7 #include "gpu/command_buffer/service/feature_info.h"
8 #include "gpu/command_buffer/service/renderbuffer_manager.h" 8 #include "gpu/command_buffer/service/renderbuffer_manager.h"
9 #include "gpu/command_buffer/service/test_helper.h" 9 #include "gpu/command_buffer/service/test_helper.h"
10 #include "gpu/command_buffer/service/texture_manager.h" 10 #include "gpu/command_buffer/service/texture_manager.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 424 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
425 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 425 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
426 EXPECT_FALSE( 426 EXPECT_FALSE(
427 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 427 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
428 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 428 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
429 framebuffer_->IsPossiblyComplete()); 429 framebuffer_->IsPossiblyComplete());
430 430
431 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id); 431 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id);
432 scoped_refptr<TextureRef> texture1( 432 scoped_refptr<TextureRef> texture1(
433 texture_manager_.GetTexture(kTextureClient1Id)); 433 texture_manager_.GetTexture(kTextureClient1Id));
434 ASSERT_TRUE(texture1 != NULL); 434 ASSERT_TRUE(texture1.get() != NULL);
435 435
436 // check adding one attachment 436 // check adding one attachment
437 framebuffer_->AttachTexture( 437 framebuffer_->AttachTexture(
438 GL_COLOR_ATTACHMENT0, texture1, kTarget1, kLevel1); 438 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1);
439 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 439 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
440 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 440 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
441 framebuffer_->IsPossiblyComplete()); 441 framebuffer_->IsPossiblyComplete());
442 EXPECT_TRUE(framebuffer_->IsCleared()); 442 EXPECT_TRUE(framebuffer_->IsCleared());
443 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); 443 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
444 444
445 // Try format that doesn't work with COLOR_ATTACHMENT0 445 // Try format that doesn't work with COLOR_ATTACHMENT0
446 texture_manager_.SetTarget(texture1, GL_TEXTURE_2D); 446 texture_manager_.SetTarget(texture1.get(), GL_TEXTURE_2D);
447 texture_manager_.SetLevelInfo( 447 texture_manager_.SetLevelInfo(texture1.get(),
448 texture1, GL_TEXTURE_2D, kLevel1, 448 GL_TEXTURE_2D,
449 kBadFormat1, kWidth1, kHeight1, kDepth, kBorder, kBadFormat1, kType, 449 kLevel1,
450 true); 450 kBadFormat1,
451 kWidth1,
452 kHeight1,
453 kDepth,
454 kBorder,
455 kBadFormat1,
456 kType,
457 true);
451 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 458 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
452 framebuffer_->IsPossiblyComplete()); 459 framebuffer_->IsPossiblyComplete());
453 460
454 // Try a good format. 461 // Try a good format.
455 texture_manager_.SetLevelInfo( 462 texture_manager_.SetLevelInfo(texture1.get(),
456 texture1, GL_TEXTURE_2D, kLevel1, 463 GL_TEXTURE_2D,
457 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, false); 464 kLevel1,
465 kFormat1,
466 kWidth1,
467 kHeight1,
468 kDepth,
469 kBorder,
470 kFormat1,
471 kType,
472 false);
458 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 473 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
459 framebuffer_->IsPossiblyComplete()); 474 framebuffer_->IsPossiblyComplete());
460 EXPECT_FALSE(framebuffer_->IsCleared()); 475 EXPECT_FALSE(framebuffer_->IsCleared());
461 texture_manager_.SetLevelInfo( 476 texture_manager_.SetLevelInfo(texture1.get(),
462 texture1, GL_TEXTURE_2D, kLevel1, 477 GL_TEXTURE_2D,
463 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, true); 478 kLevel1,
479 kFormat1,
480 kWidth1,
481 kHeight1,
482 kDepth,
483 kBorder,
484 kFormat1,
485 kType,
486 true);
464 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 487 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
465 framebuffer_->IsPossiblyComplete()); 488 framebuffer_->IsPossiblyComplete());
466 EXPECT_TRUE(framebuffer_->IsCleared()); 489 EXPECT_TRUE(framebuffer_->IsCleared());
467 EXPECT_EQ(static_cast<GLenum>(kFormat1), 490 EXPECT_EQ(static_cast<GLenum>(kFormat1),
468 framebuffer_->GetColorAttachmentFormat()); 491 framebuffer_->GetColorAttachmentFormat());
469 492
470 const Framebuffer::Attachment* attachment = 493 const Framebuffer::Attachment* attachment =
471 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 494 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
472 ASSERT_TRUE(attachment != NULL); 495 ASSERT_TRUE(attachment != NULL);
473 EXPECT_EQ(kWidth1, attachment->width()); 496 EXPECT_EQ(kWidth1, attachment->width());
474 EXPECT_EQ(kHeight1, attachment->height()); 497 EXPECT_EQ(kHeight1, attachment->height());
475 EXPECT_EQ(kSamples1, attachment->samples()); 498 EXPECT_EQ(kSamples1, attachment->samples());
476 EXPECT_EQ(kFormat1, attachment->internal_format()); 499 EXPECT_EQ(kFormat1, attachment->internal_format());
477 EXPECT_TRUE(attachment->cleared()); 500 EXPECT_TRUE(attachment->cleared());
478 501
479 // Check replacing an attachment 502 // Check replacing an attachment
480 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); 503 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
481 scoped_refptr<TextureRef> texture2( 504 scoped_refptr<TextureRef> texture2(
482 texture_manager_.GetTexture(kTextureClient2Id)); 505 texture_manager_.GetTexture(kTextureClient2Id));
483 ASSERT_TRUE(texture2 != NULL); 506 ASSERT_TRUE(texture2.get() != NULL);
484 texture_manager_.SetTarget(texture2, GL_TEXTURE_2D); 507 texture_manager_.SetTarget(texture2.get(), GL_TEXTURE_2D);
485 texture_manager_.SetLevelInfo( 508 texture_manager_.SetLevelInfo(texture2.get(),
486 texture2, GL_TEXTURE_2D, kLevel2, 509 GL_TEXTURE_2D,
487 kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType, true); 510 kLevel2,
511 kFormat2,
512 kWidth2,
513 kHeight2,
514 kDepth,
515 kBorder,
516 kFormat2,
517 kType,
518 true);
488 519
489 framebuffer_->AttachTexture( 520 framebuffer_->AttachTexture(
490 GL_COLOR_ATTACHMENT0, texture2, kTarget2, kLevel2); 521 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2);
491 EXPECT_EQ(static_cast<GLenum>(kFormat2), 522 EXPECT_EQ(static_cast<GLenum>(kFormat2),
492 framebuffer_->GetColorAttachmentFormat()); 523 framebuffer_->GetColorAttachmentFormat());
493 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 524 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
494 framebuffer_->IsPossiblyComplete()); 525 framebuffer_->IsPossiblyComplete());
495 EXPECT_TRUE(framebuffer_->IsCleared()); 526 EXPECT_TRUE(framebuffer_->IsCleared());
496 527
497 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 528 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
498 ASSERT_TRUE(attachment != NULL); 529 ASSERT_TRUE(attachment != NULL);
499 EXPECT_EQ(kWidth2, attachment->width()); 530 EXPECT_EQ(kWidth2, attachment->width());
500 EXPECT_EQ(kHeight2, attachment->height()); 531 EXPECT_EQ(kHeight2, attachment->height());
501 EXPECT_EQ(kSamples2, attachment->samples()); 532 EXPECT_EQ(kSamples2, attachment->samples());
502 EXPECT_EQ(kFormat2, attachment->internal_format()); 533 EXPECT_EQ(kFormat2, attachment->internal_format());
503 EXPECT_TRUE(attachment->cleared()); 534 EXPECT_TRUE(attachment->cleared());
504 535
505 // Check changing attachment 536 // Check changing attachment
506 texture_manager_.SetLevelInfo( 537 texture_manager_.SetLevelInfo(texture2.get(),
507 texture2, GL_TEXTURE_2D, kLevel3, 538 GL_TEXTURE_2D,
508 kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType, false); 539 kLevel3,
540 kFormat3,
541 kWidth3,
542 kHeight3,
543 kDepth,
544 kBorder,
545 kFormat3,
546 kType,
547 false);
509 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 548 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
510 ASSERT_TRUE(attachment != NULL); 549 ASSERT_TRUE(attachment != NULL);
511 EXPECT_EQ(kWidth3, attachment->width()); 550 EXPECT_EQ(kWidth3, attachment->width());
512 EXPECT_EQ(kHeight3, attachment->height()); 551 EXPECT_EQ(kHeight3, attachment->height());
513 EXPECT_EQ(kSamples3, attachment->samples()); 552 EXPECT_EQ(kSamples3, attachment->samples());
514 EXPECT_EQ(kFormat3, attachment->internal_format()); 553 EXPECT_EQ(kFormat3, attachment->internal_format());
515 EXPECT_FALSE(attachment->cleared()); 554 EXPECT_FALSE(attachment->cleared());
516 EXPECT_EQ(static_cast<GLenum>(kFormat3), 555 EXPECT_EQ(static_cast<GLenum>(kFormat3),
517 framebuffer_->GetColorAttachmentFormat()); 556 framebuffer_->GetColorAttachmentFormat());
518 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 557 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
519 framebuffer_->IsPossiblyComplete()); 558 framebuffer_->IsPossiblyComplete());
520 EXPECT_FALSE(framebuffer_->IsCleared()); 559 EXPECT_FALSE(framebuffer_->IsCleared());
521 560
522 // Set to size 0 561 // Set to size 0
523 texture_manager_.SetLevelInfo( 562 texture_manager_.SetLevelInfo(texture2.get(),
524 texture2, GL_TEXTURE_2D, kLevel3, 563 GL_TEXTURE_2D,
525 kFormat3, 0, 0, kDepth, kBorder, kFormat3, kType, false); 564 kLevel3,
565 kFormat3,
566 0,
567 0,
568 kDepth,
569 kBorder,
570 kFormat3,
571 kType,
572 false);
526 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 573 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
527 framebuffer_->IsPossiblyComplete()); 574 framebuffer_->IsPossiblyComplete());
528 575
529 // Check removing it. 576 // Check removing it.
530 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0); 577 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0);
531 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 578 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL);
532 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); 579 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
533 580
534 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 581 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
535 framebuffer_->IsPossiblyComplete()); 582 framebuffer_->IsPossiblyComplete());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 const GLuint kTextureClient1Id = 33; 622 const GLuint kTextureClient1Id = 33;
576 const GLuint kTextureService1Id = 333; 623 const GLuint kTextureService1Id = 333;
577 const GLuint kTextureClient2Id = 34; 624 const GLuint kTextureClient2Id = 34;
578 const GLuint kTextureService2Id = 334; 625 const GLuint kTextureService2Id = 334;
579 const GLenum kTarget1 = GL_TEXTURE_2D; 626 const GLenum kTarget1 = GL_TEXTURE_2D;
580 const GLint kLevel1 = 0; 627 const GLint kLevel1 = 0;
581 628
582 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id); 629 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id);
583 scoped_refptr<TextureRef> texture1( 630 scoped_refptr<TextureRef> texture1(
584 texture_manager_.GetTexture(kTextureClient1Id)); 631 texture_manager_.GetTexture(kTextureClient1Id));
585 ASSERT_TRUE(texture1 != NULL); 632 ASSERT_TRUE(texture1.get() != NULL);
586 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); 633 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
587 scoped_refptr<TextureRef> texture2( 634 scoped_refptr<TextureRef> texture2(
588 texture_manager_.GetTexture(kTextureClient2Id)); 635 texture_manager_.GetTexture(kTextureClient2Id));
589 ASSERT_TRUE(texture2 != NULL); 636 ASSERT_TRUE(texture2.get() != NULL);
590 637
591 // Attach to 2 attachment points. 638 // Attach to 2 attachment points.
592 framebuffer_->AttachTexture( 639 framebuffer_->AttachTexture(
593 GL_COLOR_ATTACHMENT0, texture1, kTarget1, kLevel1); 640 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1);
594 framebuffer_->AttachTexture( 641 framebuffer_->AttachTexture(
595 GL_DEPTH_ATTACHMENT, texture1, kTarget1, kLevel1); 642 GL_DEPTH_ATTACHMENT, texture1.get(), kTarget1, kLevel1);
596 // Check they were attached. 643 // Check they were attached.
597 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); 644 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL);
598 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); 645 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL);
599 // Unbind unattached texture. 646 // Unbind unattached texture.
600 framebuffer_->UnbindTexture(kTarget1, texture2); 647 framebuffer_->UnbindTexture(kTarget1, texture2.get());
601 // Should be no-op. 648 // Should be no-op.
602 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); 649 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL);
603 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); 650 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL);
604 // Unbind texture. 651 // Unbind texture.
605 framebuffer_->UnbindTexture(kTarget1, texture1); 652 framebuffer_->UnbindTexture(kTarget1, texture1.get());
606 // Check they were detached 653 // Check they were detached
607 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 654 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL);
608 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) == NULL); 655 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) == NULL);
609 } 656 }
610 657
611 TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) { 658 TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) {
612 const GLuint kRenderbufferClient1Id = 33; 659 const GLuint kRenderbufferClient1Id = 33;
613 const GLuint kRenderbufferService1Id = 333; 660 const GLuint kRenderbufferService1Id = 333;
614 const GLuint kTextureClient2Id = 34; 661 const GLuint kTextureClient2Id = 34;
615 const GLuint kTextureService2Id = 334; 662 const GLuint kTextureService2Id = 334;
616 const GLenum kTarget1 = GL_TEXTURE_2D; 663 const GLenum kTarget1 = GL_TEXTURE_2D;
617 const GLint kLevel1 = 0; 664 const GLint kLevel1 = 0;
618 665
619 renderbuffer_manager_.CreateRenderbuffer( 666 renderbuffer_manager_.CreateRenderbuffer(
620 kRenderbufferClient1Id, kRenderbufferService1Id); 667 kRenderbufferClient1Id, kRenderbufferService1Id);
621 Renderbuffer* renderbuffer1 = 668 Renderbuffer* renderbuffer1 =
622 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id); 669 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id);
623 ASSERT_TRUE(renderbuffer1 != NULL); 670 ASSERT_TRUE(renderbuffer1 != NULL);
624 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); 671 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
625 scoped_refptr<TextureRef> texture2( 672 scoped_refptr<TextureRef> texture2(
626 texture_manager_.GetTexture(kTextureClient2Id)); 673 texture_manager_.GetTexture(kTextureClient2Id));
627 ASSERT_TRUE(texture2 != NULL); 674 ASSERT_TRUE(texture2.get() != NULL);
628 675
629 // Check MarkAsComlete marks as complete. 676 // Check MarkAsComlete marks as complete.
630 manager_.MarkAsComplete(framebuffer_); 677 manager_.MarkAsComplete(framebuffer_);
631 EXPECT_TRUE(manager_.IsComplete(framebuffer_)); 678 EXPECT_TRUE(manager_.IsComplete(framebuffer_));
632 679
633 // Check at attaching marks as not complete. 680 // Check at attaching marks as not complete.
634 framebuffer_->AttachTexture( 681 framebuffer_->AttachTexture(
635 GL_COLOR_ATTACHMENT0, texture2, kTarget1, kLevel1); 682 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget1, kLevel1);
636 EXPECT_FALSE(manager_.IsComplete(framebuffer_)); 683 EXPECT_FALSE(manager_.IsComplete(framebuffer_));
637 manager_.MarkAsComplete(framebuffer_); 684 manager_.MarkAsComplete(framebuffer_);
638 EXPECT_TRUE(manager_.IsComplete(framebuffer_)); 685 EXPECT_TRUE(manager_.IsComplete(framebuffer_));
639 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer1); 686 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer1);
640 EXPECT_FALSE(manager_.IsComplete(framebuffer_)); 687 EXPECT_FALSE(manager_.IsComplete(framebuffer_));
641 688
642 // Check MarkAttachmentsAsCleared marks as complete. 689 // Check MarkAttachmentsAsCleared marks as complete.
643 manager_.MarkAttachmentsAsCleared( 690 manager_.MarkAttachmentsAsCleared(
644 framebuffer_, &renderbuffer_manager_, &texture_manager_); 691 framebuffer_, &renderbuffer_manager_, &texture_manager_);
645 EXPECT_TRUE(manager_.IsComplete(framebuffer_)); 692 EXPECT_TRUE(manager_.IsComplete(framebuffer_));
646 693
647 // Check Unbind marks as not complete. 694 // Check Unbind marks as not complete.
648 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer1); 695 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer1);
649 EXPECT_FALSE(manager_.IsComplete(framebuffer_)); 696 EXPECT_FALSE(manager_.IsComplete(framebuffer_));
650 manager_.MarkAsComplete(framebuffer_); 697 manager_.MarkAsComplete(framebuffer_);
651 EXPECT_TRUE(manager_.IsComplete(framebuffer_)); 698 EXPECT_TRUE(manager_.IsComplete(framebuffer_));
652 framebuffer_->UnbindTexture(kTarget1, texture2); 699 framebuffer_->UnbindTexture(kTarget1, texture2.get());
653 EXPECT_FALSE(manager_.IsComplete(framebuffer_)); 700 EXPECT_FALSE(manager_.IsComplete(framebuffer_));
654 } 701 }
655 702
656 TEST_F(FramebufferInfoTest, GetStatus) { 703 TEST_F(FramebufferInfoTest, GetStatus) {
657 const GLuint kRenderbufferClient1Id = 33; 704 const GLuint kRenderbufferClient1Id = 33;
658 const GLuint kRenderbufferService1Id = 333; 705 const GLuint kRenderbufferService1Id = 333;
659 const GLuint kTextureClient2Id = 34; 706 const GLuint kTextureClient2Id = 34;
660 const GLuint kTextureService2Id = 334; 707 const GLuint kTextureService2Id = 334;
661 const GLenum kTarget1 = GL_TEXTURE_2D; 708 const GLenum kTarget1 = GL_TEXTURE_2D;
662 const GLint kLevel1 = 0; 709 const GLint kLevel1 = 0;
663 710
664 renderbuffer_manager_.CreateRenderbuffer( 711 renderbuffer_manager_.CreateRenderbuffer(
665 kRenderbufferClient1Id, kRenderbufferService1Id); 712 kRenderbufferClient1Id, kRenderbufferService1Id);
666 Renderbuffer* renderbuffer1 = 713 Renderbuffer* renderbuffer1 =
667 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id); 714 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id);
668 ASSERT_TRUE(renderbuffer1 != NULL); 715 ASSERT_TRUE(renderbuffer1 != NULL);
669 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); 716 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id);
670 scoped_refptr<TextureRef> texture2( 717 scoped_refptr<TextureRef> texture2(
671 texture_manager_.GetTexture(kTextureClient2Id)); 718 texture_manager_.GetTexture(kTextureClient2Id));
672 ASSERT_TRUE(texture2 != NULL); 719 ASSERT_TRUE(texture2.get() != NULL);
673 texture_manager_.SetTarget(texture2, GL_TEXTURE_2D); 720 texture_manager_.SetTarget(texture2.get(), GL_TEXTURE_2D);
674 721
675 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 722 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
676 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 723 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
677 .RetiresOnSaturation(); 724 .RetiresOnSaturation();
678 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); 725 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER);
679 726
680 // Check a second call for the same type does not call anything 727 // Check a second call for the same type does not call anything
681 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) { 728 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) {
682 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 729 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
683 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 730 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
684 .RetiresOnSaturation(); 731 .RetiresOnSaturation();
685 } 732 }
686 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); 733 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER);
687 734
688 // Check changing the attachments calls CheckFramebufferStatus. 735 // Check changing the attachments calls CheckFramebufferStatus.
689 framebuffer_->AttachTexture( 736 framebuffer_->AttachTexture(
690 GL_COLOR_ATTACHMENT0, texture2, kTarget1, kLevel1); 737 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget1, kLevel1);
691 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 738 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
692 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 739 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)).RetiresOnSaturation();
693 .RetiresOnSaturation();
694 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); 740 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER);
695 741
696 // Check a second call for the same type does not call anything. 742 // Check a second call for the same type does not call anything.
697 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) { 743 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) {
698 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 744 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
699 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 745 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
700 .RetiresOnSaturation(); 746 .RetiresOnSaturation();
701 } 747 }
702 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); 748 framebuffer_->GetStatus(&texture_manager_, GL_FRAMEBUFFER);
703 749
(...skipping 20 matching lines...) Expand all
724 770
725 // Check a second call for the same type does not call anything. 771 // Check a second call for the same type does not call anything.
726 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) { 772 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) {
727 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) 773 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER))
728 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 774 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
729 .RetiresOnSaturation(); 775 .RetiresOnSaturation();
730 } 776 }
731 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); 777 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
732 778
733 // Check changing the format calls CheckFramebuffferStatus. 779 // Check changing the format calls CheckFramebuffferStatus.
734 TestHelper::SetTexParameterWithExpectations( 780 TestHelper::SetTexParameterWithExpectations(gl_.get(),
735 gl_.get(), error_state_.get(), &texture_manager_, 781 error_state_.get(),
736 texture2, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE, GL_NO_ERROR); 782 &texture_manager_,
783 texture2.get(),
784 GL_TEXTURE_WRAP_S,
785 GL_CLAMP_TO_EDGE,
786 GL_NO_ERROR);
737 787
738 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) 788 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER))
739 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) 789 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT))
740 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 790 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
741 .RetiresOnSaturation(); 791 .RetiresOnSaturation();
742 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); 792 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
743 793
744 // Check since it did not return FRAMEBUFFER_COMPLETE that it calls 794 // Check since it did not return FRAMEBUFFER_COMPLETE that it calls
745 // CheckFramebufferStatus 795 // CheckFramebufferStatus
746 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); 796 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
747 797
748 // Check putting it back does not call CheckFramebufferStatus. 798 // Check putting it back does not call CheckFramebufferStatus.
749 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) { 799 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) {
750 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) 800 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER))
751 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 801 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
752 .RetiresOnSaturation(); 802 .RetiresOnSaturation();
753 } 803 }
754 TestHelper::SetTexParameterWithExpectations( 804 TestHelper::SetTexParameterWithExpectations(gl_.get(),
755 gl_.get(), error_state_.get(), &texture_manager_, 805 error_state_.get(),
756 texture2, GL_TEXTURE_WRAP_S, GL_REPEAT, GL_NO_ERROR); 806 &texture_manager_,
807 texture2.get(),
808 GL_TEXTURE_WRAP_S,
809 GL_REPEAT,
810 GL_NO_ERROR);
757 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); 811 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
758 812
759 // Check Unbinding does not call CheckFramebufferStatus 813 // Check Unbinding does not call CheckFramebufferStatus
760 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer1); 814 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer1);
761 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) { 815 if (!framebuffer_->AllowFramebufferComboCompleteMapForTesting()) {
762 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) 816 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER))
763 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 817 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
764 .RetiresOnSaturation(); 818 .RetiresOnSaturation();
765 } 819 }
766 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); 820 framebuffer_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER);
767 } 821 }
768 822
769 } // namespace gles2 823 } // namespace gles2
770 } // namespace gpu 824 } // namespace gpu
771 825
772 826
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698