OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 return true; | 557 return true; |
558 } | 558 } |
559 | 559 |
560 // GAPIGL functions. | 560 // GAPIGL functions. |
561 | 561 |
562 // Destroys a texture resource. | 562 // Destroys a texture resource. |
563 BufferSyncInterface::ParseError GAPIGL::DestroyTexture(ResourceID id) { | 563 BufferSyncInterface::ParseError GAPIGL::DestroyTexture(ResourceID id) { |
564 // Dirty effect, because this texture id may be used. | 564 // Dirty effect, because this texture id may be used. |
565 DirtyEffect(); | 565 DirtyEffect(); |
566 return textures_.Destroy(id) ? | 566 return textures_.Destroy(id) ? |
567 BufferSyncInterface::PARSE_NO_ERROR : | 567 BufferSyncInterface::kParseNoError : |
568 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 568 BufferSyncInterface::kParseInvalidArguments; |
569 } | 569 } |
570 | 570 |
571 // Creates a 2D texture resource. | 571 // Creates a 2D texture resource. |
572 BufferSyncInterface::ParseError GAPIGL::CreateTexture2D( | 572 BufferSyncInterface::ParseError GAPIGL::CreateTexture2D( |
573 ResourceID id, | 573 ResourceID id, |
574 unsigned int width, | 574 unsigned int width, |
575 unsigned int height, | 575 unsigned int height, |
576 unsigned int levels, | 576 unsigned int levels, |
577 texture::Format format, | 577 texture::Format format, |
578 unsigned int flags) { | 578 unsigned int flags) { |
579 Texture2DGL *texture = Texture2DGL::Create(width, height, levels, format, | 579 Texture2DGL *texture = Texture2DGL::Create(width, height, levels, format, |
580 flags); | 580 flags); |
581 if (!texture) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 581 if (!texture) return BufferSyncInterface::kParseInvalidArguments; |
582 // Dirty effect, because this texture id may be used. | 582 // Dirty effect, because this texture id may be used. |
583 DirtyEffect(); | 583 DirtyEffect(); |
584 textures_.Assign(id, texture); | 584 textures_.Assign(id, texture); |
585 return BufferSyncInterface::PARSE_NO_ERROR; | 585 return BufferSyncInterface::kParseNoError; |
586 } | 586 } |
587 | 587 |
588 // Creates a 3D texture resource. | 588 // Creates a 3D texture resource. |
589 BufferSyncInterface::ParseError GAPIGL::CreateTexture3D( | 589 BufferSyncInterface::ParseError GAPIGL::CreateTexture3D( |
590 ResourceID id, | 590 ResourceID id, |
591 unsigned int width, | 591 unsigned int width, |
592 unsigned int height, | 592 unsigned int height, |
593 unsigned int depth, | 593 unsigned int depth, |
594 unsigned int levels, | 594 unsigned int levels, |
595 texture::Format format, | 595 texture::Format format, |
596 unsigned int flags) { | 596 unsigned int flags) { |
597 Texture3DGL *texture = Texture3DGL::Create(width, height, depth, levels, | 597 Texture3DGL *texture = Texture3DGL::Create(width, height, depth, levels, |
598 format, flags); | 598 format, flags); |
599 if (!texture) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 599 if (!texture) return BufferSyncInterface::kParseInvalidArguments; |
600 // Dirty effect, because this texture id may be used. | 600 // Dirty effect, because this texture id may be used. |
601 DirtyEffect(); | 601 DirtyEffect(); |
602 textures_.Assign(id, texture); | 602 textures_.Assign(id, texture); |
603 return BufferSyncInterface::PARSE_NO_ERROR; | 603 return BufferSyncInterface::kParseNoError; |
604 } | 604 } |
605 | 605 |
606 // Creates a cube map texture resource. | 606 // Creates a cube map texture resource. |
607 BufferSyncInterface::ParseError GAPIGL::CreateTextureCube( | 607 BufferSyncInterface::ParseError GAPIGL::CreateTextureCube( |
608 ResourceID id, | 608 ResourceID id, |
609 unsigned int side, | 609 unsigned int side, |
610 unsigned int levels, | 610 unsigned int levels, |
611 texture::Format format, | 611 texture::Format format, |
612 unsigned int flags) { | 612 unsigned int flags) { |
613 TextureCubeGL *texture = TextureCubeGL::Create(side, levels, format, flags); | 613 TextureCubeGL *texture = TextureCubeGL::Create(side, levels, format, flags); |
614 if (!texture) return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 614 if (!texture) return BufferSyncInterface::kParseInvalidArguments; |
615 // Dirty effect, because this texture id may be used. | 615 // Dirty effect, because this texture id may be used. |
616 DirtyEffect(); | 616 DirtyEffect(); |
617 textures_.Assign(id, texture); | 617 textures_.Assign(id, texture); |
618 return BufferSyncInterface::PARSE_NO_ERROR; | 618 return BufferSyncInterface::kParseNoError; |
619 } | 619 } |
620 | 620 |
621 // Copies the data into a texture resource. | 621 // Copies the data into a texture resource. |
622 BufferSyncInterface::ParseError GAPIGL::SetTextureData( | 622 BufferSyncInterface::ParseError GAPIGL::SetTextureData( |
623 ResourceID id, | 623 ResourceID id, |
624 unsigned int x, | 624 unsigned int x, |
625 unsigned int y, | 625 unsigned int y, |
626 unsigned int z, | 626 unsigned int z, |
627 unsigned int width, | 627 unsigned int width, |
628 unsigned int height, | 628 unsigned int height, |
629 unsigned int depth, | 629 unsigned int depth, |
630 unsigned int level, | 630 unsigned int level, |
631 texture::Face face, | 631 texture::Face face, |
632 unsigned int row_pitch, | 632 unsigned int row_pitch, |
633 unsigned int slice_pitch, | 633 unsigned int slice_pitch, |
634 unsigned int size, | 634 unsigned int size, |
635 const void *data) { | 635 const void *data) { |
636 TextureGL *texture = textures_.Get(id); | 636 TextureGL *texture = textures_.Get(id); |
637 if (!texture) | 637 if (!texture) |
638 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 638 return BufferSyncInterface::kParseInvalidArguments; |
639 Volume volume = {x, y, z, width, height, depth}; | 639 Volume volume = {x, y, z, width, height, depth}; |
640 // Dirty effect: SetData may need to call glBindTexture which will mess up the | 640 // Dirty effect: SetData may need to call glBindTexture which will mess up the |
641 // sampler parameters. | 641 // sampler parameters. |
642 DirtyEffect(); | 642 DirtyEffect(); |
643 return texture->SetData(volume, level, face, row_pitch, slice_pitch, | 643 return texture->SetData(volume, level, face, row_pitch, slice_pitch, |
644 size, data) ? | 644 size, data) ? |
645 BufferSyncInterface::PARSE_NO_ERROR : | 645 BufferSyncInterface::kParseNoError : |
646 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 646 BufferSyncInterface::kParseInvalidArguments; |
647 } | 647 } |
648 | 648 |
649 // Copies the data from a texture resource. | 649 // Copies the data from a texture resource. |
650 BufferSyncInterface::ParseError GAPIGL::GetTextureData( | 650 BufferSyncInterface::ParseError GAPIGL::GetTextureData( |
651 ResourceID id, | 651 ResourceID id, |
652 unsigned int x, | 652 unsigned int x, |
653 unsigned int y, | 653 unsigned int y, |
654 unsigned int z, | 654 unsigned int z, |
655 unsigned int width, | 655 unsigned int width, |
656 unsigned int height, | 656 unsigned int height, |
657 unsigned int depth, | 657 unsigned int depth, |
658 unsigned int level, | 658 unsigned int level, |
659 texture::Face face, | 659 texture::Face face, |
660 unsigned int row_pitch, | 660 unsigned int row_pitch, |
661 unsigned int slice_pitch, | 661 unsigned int slice_pitch, |
662 unsigned int size, | 662 unsigned int size, |
663 void *data) { | 663 void *data) { |
664 TextureGL *texture = textures_.Get(id); | 664 TextureGL *texture = textures_.Get(id); |
665 if (!texture) | 665 if (!texture) |
666 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 666 return BufferSyncInterface::kParseInvalidArguments; |
667 Volume volume = {x, y, z, width, height, depth}; | 667 Volume volume = {x, y, z, width, height, depth}; |
668 // Dirty effect: GetData may need to call glBindTexture which will mess up the | 668 // Dirty effect: GetData may need to call glBindTexture which will mess up the |
669 // sampler parameters. | 669 // sampler parameters. |
670 DirtyEffect(); | 670 DirtyEffect(); |
671 return texture->GetData(volume, level, face, row_pitch, slice_pitch, | 671 return texture->GetData(volume, level, face, row_pitch, slice_pitch, |
672 size, data) ? | 672 size, data) ? |
673 BufferSyncInterface::PARSE_NO_ERROR : | 673 BufferSyncInterface::kParseNoError : |
674 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 674 BufferSyncInterface::kParseInvalidArguments; |
675 } | 675 } |
676 | 676 |
677 } // namespace command_buffer | 677 } // namespace command_buffer |
678 } // namespace o3d | 678 } // namespace o3d |
OLD | NEW |