| OLD | NEW |
| 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 // This file is here so other GLES2 related files can have a common set of | 5 // This file is here so other GLES2 related files can have a common set of |
| 6 // includes where appropriate. | 6 // includes where appropriate. |
| 7 | 7 |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 case GL_UNSIGNED_BYTE: | 494 case GL_UNSIGNED_BYTE: |
| 495 case GL_BYTE: | 495 case GL_BYTE: |
| 496 return 1; | 496 return 1; |
| 497 default: | 497 default: |
| 498 return 0; | 498 return 0; |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // anonymous namespace | 502 } // anonymous namespace |
| 503 | 503 |
| 504 uint32 GLES2Util::ComputeImageGroupSize(int format, int type) { | 504 uint32_t GLES2Util::ComputeImageGroupSize(int format, int type) { |
| 505 int bytes_per_element = BytesPerElement(type); | 505 int bytes_per_element = BytesPerElement(type); |
| 506 DCHECK_GE(8, bytes_per_element); | 506 DCHECK_GE(8, bytes_per_element); |
| 507 int elements_per_group = ElementsPerGroup(format, type); | 507 int elements_per_group = ElementsPerGroup(format, type); |
| 508 DCHECK_GE(4, elements_per_group); | 508 DCHECK_GE(4, elements_per_group); |
| 509 return bytes_per_element * elements_per_group; | 509 return bytes_per_element * elements_per_group; |
| 510 } | 510 } |
| 511 | 511 |
| 512 bool GLES2Util::ComputeImageRowSizeHelper( | 512 bool GLES2Util::ComputeImageRowSizeHelper(int width, |
| 513 int width, uint32 bytes_per_group, int alignment, | 513 uint32_t bytes_per_group, |
| 514 uint32* rt_unpadded_row_size, uint32* rt_padded_row_size) { | 514 int alignment, |
| 515 uint32_t* rt_unpadded_row_size, |
| 516 uint32_t* rt_padded_row_size) { |
| 515 DCHECK(alignment == 1 || alignment == 2 || | 517 DCHECK(alignment == 1 || alignment == 2 || |
| 516 alignment == 4 || alignment == 8); | 518 alignment == 4 || alignment == 8); |
| 517 uint32 unpadded_row_size; | 519 uint32_t unpadded_row_size; |
| 518 if (!SafeMultiplyUint32(width, bytes_per_group, &unpadded_row_size)) { | 520 if (!SafeMultiplyUint32(width, bytes_per_group, &unpadded_row_size)) { |
| 519 return false; | 521 return false; |
| 520 } | 522 } |
| 521 uint32 temp; | 523 uint32_t temp; |
| 522 if (!SafeAddUint32(unpadded_row_size, alignment - 1, &temp)) { | 524 if (!SafeAddUint32(unpadded_row_size, alignment - 1, &temp)) { |
| 523 return false; | 525 return false; |
| 524 } | 526 } |
| 525 uint32 padded_row_size = (temp / alignment) * alignment; | 527 uint32_t padded_row_size = (temp / alignment) * alignment; |
| 526 if (rt_unpadded_row_size) | 528 if (rt_unpadded_row_size) |
| 527 *rt_unpadded_row_size = unpadded_row_size; | 529 *rt_unpadded_row_size = unpadded_row_size; |
| 528 if (rt_padded_row_size) | 530 if (rt_padded_row_size) |
| 529 *rt_padded_row_size = padded_row_size; | 531 *rt_padded_row_size = padded_row_size; |
| 530 return true; | 532 return true; |
| 531 } | 533 } |
| 532 | 534 |
| 533 bool GLES2Util::ComputeImagePaddedRowSize( | 535 bool GLES2Util::ComputeImagePaddedRowSize(int width, |
| 534 int width, int format, int type, int alignment, uint32* padded_row_size) { | 536 int format, |
| 535 uint32 bytes_per_group = ComputeImageGroupSize(format, type); | 537 int type, |
| 538 int alignment, |
| 539 uint32_t* padded_row_size) { |
| 540 uint32_t bytes_per_group = ComputeImageGroupSize(format, type); |
| 536 return ComputeImageRowSizeHelper( | 541 return ComputeImageRowSizeHelper( |
| 537 width, bytes_per_group, alignment, nullptr, padded_row_size); | 542 width, bytes_per_group, alignment, nullptr, padded_row_size); |
| 538 } | 543 } |
| 539 | 544 |
| 540 // Returns the amount of data glTexImage*D or glTexSubImage*D will access. | 545 // Returns the amount of data glTexImage*D or glTexSubImage*D will access. |
| 541 bool GLES2Util::ComputeImageDataSizes( | 546 bool GLES2Util::ComputeImageDataSizes(int width, |
| 542 int width, int height, int depth, int format, int type, | 547 int height, |
| 543 int alignment, uint32* size, uint32* opt_unpadded_row_size, | 548 int depth, |
| 544 uint32* opt_padded_row_size) { | 549 int format, |
| 550 int type, |
| 551 int alignment, |
| 552 uint32_t* size, |
| 553 uint32_t* opt_unpadded_row_size, |
| 554 uint32_t* opt_padded_row_size) { |
| 545 PixelStoreParams params; | 555 PixelStoreParams params; |
| 546 params.alignment = alignment; | 556 params.alignment = alignment; |
| 547 return ComputeImageDataSizesES3( | 557 return ComputeImageDataSizesES3( |
| 548 width, height, depth, format, type, params, | 558 width, height, depth, format, type, params, |
| 549 size, opt_unpadded_row_size, opt_padded_row_size, nullptr); | 559 size, opt_unpadded_row_size, opt_padded_row_size, nullptr); |
| 550 } | 560 } |
| 551 | 561 |
| 552 bool GLES2Util::ComputeImageDataSizesES3( | 562 bool GLES2Util::ComputeImageDataSizesES3( |
| 553 int width, int height, int depth, int format, int type, | 563 int width, int height, int depth, int format, int type, |
| 554 const PixelStoreParams& params, | 564 const PixelStoreParams& params, |
| 555 uint32_t* size, uint32_t* opt_unpadded_row_size, | 565 uint32_t* size, uint32_t* opt_unpadded_row_size, |
| 556 uint32_t* opt_padded_row_size, uint32_t* opt_skip_size) { | 566 uint32_t* opt_padded_row_size, uint32_t* opt_skip_size) { |
| 557 DCHECK(width >= 0 && height >= 0 && depth >= 0); | 567 DCHECK(width >= 0 && height >= 0 && depth >= 0); |
| 558 | 568 |
| 559 uint32 bytes_per_group = ComputeImageGroupSize(format, type); | 569 uint32_t bytes_per_group = ComputeImageGroupSize(format, type); |
| 560 | 570 |
| 561 uint32 unpadded_row_size; | 571 uint32_t unpadded_row_size; |
| 562 uint32 padded_row_size; | 572 uint32_t padded_row_size; |
| 563 if (!ComputeImageRowSizeHelper(width, bytes_per_group, params.alignment, | 573 if (!ComputeImageRowSizeHelper(width, bytes_per_group, params.alignment, |
| 564 &unpadded_row_size, &padded_row_size)) { | 574 &unpadded_row_size, &padded_row_size)) { |
| 565 return false; | 575 return false; |
| 566 } | 576 } |
| 567 if (params.row_length > 0 && | 577 if (params.row_length > 0 && |
| 568 !ComputeImageRowSizeHelper(params.row_length, bytes_per_group, | 578 !ComputeImageRowSizeHelper(params.row_length, bytes_per_group, |
| 569 params.alignment, nullptr, &padded_row_size)) { | 579 params.alignment, nullptr, &padded_row_size)) { |
| 570 // Here we re-compute the padded_row_size, but the unpadded_row_size | 580 // Here we re-compute the padded_row_size, but the unpadded_row_size |
| 571 // isn't affected. That is, the last row isn't affected by ROW_LENGTH. | 581 // isn't affected. That is, the last row isn't affected by ROW_LENGTH. |
| 572 return false; | 582 return false; |
| 573 } | 583 } |
| 574 | 584 |
| 575 int image_height = params.image_height > 0 ? params.image_height : height; | 585 int image_height = params.image_height > 0 ? params.image_height : height; |
| 576 uint32 num_of_rows; | 586 uint32_t num_of_rows; |
| 577 if (depth > 0) { | 587 if (depth > 0) { |
| 578 if (!SafeMultiplyUint32(image_height, depth - 1, &num_of_rows) || | 588 if (!SafeMultiplyUint32(image_height, depth - 1, &num_of_rows) || |
| 579 !SafeAddUint32(num_of_rows, height, &num_of_rows)) { | 589 !SafeAddUint32(num_of_rows, height, &num_of_rows)) { |
| 580 return false; | 590 return false; |
| 581 } | 591 } |
| 582 } else { | 592 } else { |
| 583 num_of_rows = 0; | 593 num_of_rows = 0; |
| 584 } | 594 } |
| 585 | 595 |
| 586 if (num_of_rows > 0) { | 596 if (num_of_rows > 0) { |
| 587 uint32 size_of_all_but_last_row; | 597 uint32_t size_of_all_but_last_row; |
| 588 if (!SafeMultiplyUint32((num_of_rows - 1), padded_row_size, | 598 if (!SafeMultiplyUint32((num_of_rows - 1), padded_row_size, |
| 589 &size_of_all_but_last_row)) { | 599 &size_of_all_but_last_row)) { |
| 590 return false; | 600 return false; |
| 591 } | 601 } |
| 592 if (!SafeAddUint32(size_of_all_but_last_row, unpadded_row_size, size)) { | 602 if (!SafeAddUint32(size_of_all_but_last_row, unpadded_row_size, size)) { |
| 593 return false; | 603 return false; |
| 594 } | 604 } |
| 595 } else { | 605 } else { |
| 596 *size = 0; | 606 *size = 0; |
| 597 } | 607 } |
| 598 | 608 |
| 599 uint32 skip_size = 0; | 609 uint32_t skip_size = 0; |
| 600 if (params.skip_images > 0) { | 610 if (params.skip_images > 0) { |
| 601 uint32 image_size; | 611 uint32_t image_size; |
| 602 if (!SafeMultiplyUint32(image_height, padded_row_size, &image_size)) | 612 if (!SafeMultiplyUint32(image_height, padded_row_size, &image_size)) |
| 603 return false; | 613 return false; |
| 604 if (!SafeMultiplyUint32(image_size, params.skip_images, &skip_size)) | 614 if (!SafeMultiplyUint32(image_size, params.skip_images, &skip_size)) |
| 605 return false; | 615 return false; |
| 606 } | 616 } |
| 607 if (params.skip_rows > 0) { | 617 if (params.skip_rows > 0) { |
| 608 uint32 temp; | 618 uint32_t temp; |
| 609 if (!SafeMultiplyUint32(padded_row_size, params.skip_rows, &temp)) | 619 if (!SafeMultiplyUint32(padded_row_size, params.skip_rows, &temp)) |
| 610 return false; | 620 return false; |
| 611 if (!SafeAddUint32(skip_size, temp, &skip_size)) | 621 if (!SafeAddUint32(skip_size, temp, &skip_size)) |
| 612 return false; | 622 return false; |
| 613 } | 623 } |
| 614 if (params.skip_pixels > 0) { | 624 if (params.skip_pixels > 0) { |
| 615 uint32 temp; | 625 uint32_t temp; |
| 616 if (!SafeMultiplyUint32(bytes_per_group, params.skip_pixels, &temp)) | 626 if (!SafeMultiplyUint32(bytes_per_group, params.skip_pixels, &temp)) |
| 617 return false; | 627 return false; |
| 618 if (!SafeAddUint32(skip_size, temp, &skip_size)) | 628 if (!SafeAddUint32(skip_size, temp, &skip_size)) |
| 619 return false; | 629 return false; |
| 620 } | 630 } |
| 621 uint32 total_size; | 631 uint32_t total_size; |
| 622 if (!SafeAddUint32(*size, skip_size, &total_size)) | 632 if (!SafeAddUint32(*size, skip_size, &total_size)) |
| 623 return false; | 633 return false; |
| 624 | 634 |
| 625 if (opt_padded_row_size) { | 635 if (opt_padded_row_size) { |
| 626 *opt_padded_row_size = padded_row_size; | 636 *opt_padded_row_size = padded_row_size; |
| 627 } | 637 } |
| 628 if (opt_unpadded_row_size) { | 638 if (opt_unpadded_row_size) { |
| 629 *opt_unpadded_row_size = unpadded_row_size; | 639 *opt_unpadded_row_size = unpadded_row_size; |
| 630 } | 640 } |
| 631 if (opt_skip_size) | 641 if (opt_skip_size) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 647 case GL_DEPTH24_STENCIL8_OES: | 657 case GL_DEPTH24_STENCIL8_OES: |
| 648 case GL_RGB8_OES: | 658 case GL_RGB8_OES: |
| 649 case GL_RGBA8_OES: | 659 case GL_RGBA8_OES: |
| 650 case GL_DEPTH_COMPONENT24_OES: | 660 case GL_DEPTH_COMPONENT24_OES: |
| 651 return 4; | 661 return 4; |
| 652 default: | 662 default: |
| 653 return 0; | 663 return 0; |
| 654 } | 664 } |
| 655 } | 665 } |
| 656 | 666 |
| 657 uint32 GLES2Util::GetElementSizeForUniformType(int type) { | 667 uint32_t GLES2Util::GetElementSizeForUniformType(int type) { |
| 658 switch (type) { | 668 switch (type) { |
| 659 case GL_FLOAT: | 669 case GL_FLOAT: |
| 660 case GL_FLOAT_VEC2: | 670 case GL_FLOAT_VEC2: |
| 661 case GL_FLOAT_VEC3: | 671 case GL_FLOAT_VEC3: |
| 662 case GL_FLOAT_VEC4: | 672 case GL_FLOAT_VEC4: |
| 663 case GL_FLOAT_MAT2: | 673 case GL_FLOAT_MAT2: |
| 664 case GL_FLOAT_MAT3: | 674 case GL_FLOAT_MAT3: |
| 665 case GL_FLOAT_MAT4: | 675 case GL_FLOAT_MAT4: |
| 666 return sizeof(GLfloat); | 676 return sizeof(GLfloat); |
| 667 case GL_INT: | 677 case GL_INT: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 case GL_FLOAT_MAT4x2: | 714 case GL_FLOAT_MAT4x2: |
| 705 case GL_FLOAT_MAT3x4: | 715 case GL_FLOAT_MAT3x4: |
| 706 case GL_FLOAT_MAT4x3: | 716 case GL_FLOAT_MAT4x3: |
| 707 return sizeof(GLfloat); | 717 return sizeof(GLfloat); |
| 708 | 718 |
| 709 default: | 719 default: |
| 710 return 0; | 720 return 0; |
| 711 } | 721 } |
| 712 } | 722 } |
| 713 | 723 |
| 714 uint32 GLES2Util::GetElementCountForUniformType(int type) { | 724 uint32_t GLES2Util::GetElementCountForUniformType(int type) { |
| 715 switch (type) { | 725 switch (type) { |
| 716 case GL_FLOAT: | 726 case GL_FLOAT: |
| 717 case GL_INT: | 727 case GL_INT: |
| 718 case GL_BOOL: | 728 case GL_BOOL: |
| 719 case GL_SAMPLER_2D: | 729 case GL_SAMPLER_2D: |
| 720 case GL_SAMPLER_CUBE: | 730 case GL_SAMPLER_CUBE: |
| 721 case GL_SAMPLER_2D_RECT_ARB: // extension. | 731 case GL_SAMPLER_2D_RECT_ARB: // extension. |
| 722 case GL_SAMPLER_EXTERNAL_OES: // extension. | 732 case GL_SAMPLER_EXTERNAL_OES: // extension. |
| 723 return 1; | 733 return 1; |
| 724 case GL_FLOAT_VEC2: | 734 case GL_FLOAT_VEC2: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 return 8; | 779 return 8; |
| 770 case GL_FLOAT_MAT3x4: | 780 case GL_FLOAT_MAT3x4: |
| 771 case GL_FLOAT_MAT4x3: | 781 case GL_FLOAT_MAT4x3: |
| 772 return 12; | 782 return 12; |
| 773 | 783 |
| 774 default: | 784 default: |
| 775 return 0; | 785 return 0; |
| 776 } | 786 } |
| 777 } | 787 } |
| 778 | 788 |
| 779 size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32 type) { | 789 size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32_t type) { |
| 780 switch (type) { | 790 switch (type) { |
| 781 case GL_BYTE: | 791 case GL_BYTE: |
| 782 return sizeof(GLbyte); // NOLINT | 792 return sizeof(GLbyte); // NOLINT |
| 783 case GL_UNSIGNED_BYTE: | 793 case GL_UNSIGNED_BYTE: |
| 784 return sizeof(GLubyte); // NOLINT | 794 return sizeof(GLubyte); // NOLINT |
| 785 case GL_SHORT: | 795 case GL_SHORT: |
| 786 return sizeof(GLshort); // NOLINT | 796 return sizeof(GLshort); // NOLINT |
| 787 case GL_UNSIGNED_SHORT: | 797 case GL_UNSIGNED_SHORT: |
| 788 return sizeof(GLushort); // NOLINT | 798 return sizeof(GLushort); // NOLINT |
| 789 case GL_INT: | 799 case GL_INT: |
| 790 return sizeof(GLint); // NOLINT | 800 return sizeof(GLint); // NOLINT |
| 791 case GL_UNSIGNED_INT: | 801 case GL_UNSIGNED_INT: |
| 792 return sizeof(GLuint); // NOLINT | 802 return sizeof(GLuint); // NOLINT |
| 793 case GL_FLOAT: | 803 case GL_FLOAT: |
| 794 return sizeof(GLfloat); // NOLINT | 804 return sizeof(GLfloat); // NOLINT |
| 795 case GL_FIXED: | 805 case GL_FIXED: |
| 796 return sizeof(GLfixed); // NOLINT | 806 return sizeof(GLfixed); // NOLINT |
| 797 default: | 807 default: |
| 798 return 0; | 808 return 0; |
| 799 } | 809 } |
| 800 } | 810 } |
| 801 | 811 |
| 802 size_t GLES2Util::GetComponentCountForGLTransformType(uint32 type) { | 812 size_t GLES2Util::GetComponentCountForGLTransformType(uint32_t type) { |
| 803 switch (type) { | 813 switch (type) { |
| 804 case GL_TRANSLATE_X_CHROMIUM: | 814 case GL_TRANSLATE_X_CHROMIUM: |
| 805 case GL_TRANSLATE_Y_CHROMIUM: | 815 case GL_TRANSLATE_Y_CHROMIUM: |
| 806 return 1; | 816 return 1; |
| 807 case GL_TRANSLATE_2D_CHROMIUM: | 817 case GL_TRANSLATE_2D_CHROMIUM: |
| 808 return 2; | 818 return 2; |
| 809 case GL_TRANSLATE_3D_CHROMIUM: | 819 case GL_TRANSLATE_3D_CHROMIUM: |
| 810 return 3; | 820 return 3; |
| 811 case GL_AFFINE_2D_CHROMIUM: | 821 case GL_AFFINE_2D_CHROMIUM: |
| 812 case GL_TRANSPOSE_AFFINE_2D_CHROMIUM: | 822 case GL_TRANSPOSE_AFFINE_2D_CHROMIUM: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 826 case GL_OBJECT_LINEAR_CHROMIUM: | 836 case GL_OBJECT_LINEAR_CHROMIUM: |
| 827 return 3; | 837 return 3; |
| 828 case GL_CONSTANT_CHROMIUM: | 838 case GL_CONSTANT_CHROMIUM: |
| 829 return 1; | 839 return 1; |
| 830 case GL_NONE: | 840 case GL_NONE: |
| 831 default: | 841 default: |
| 832 return 0; | 842 return 0; |
| 833 } | 843 } |
| 834 } | 844 } |
| 835 | 845 |
| 836 size_t GLES2Util::GetGLTypeSizeForPathCoordType(uint32 type) { | 846 size_t GLES2Util::GetGLTypeSizeForPathCoordType(uint32_t type) { |
| 837 switch (type) { | 847 switch (type) { |
| 838 case GL_BYTE: | 848 case GL_BYTE: |
| 839 return sizeof(GLbyte); // NOLINT | 849 return sizeof(GLbyte); // NOLINT |
| 840 case GL_UNSIGNED_BYTE: | 850 case GL_UNSIGNED_BYTE: |
| 841 return sizeof(GLubyte); // NOLINT | 851 return sizeof(GLubyte); // NOLINT |
| 842 case GL_SHORT: | 852 case GL_SHORT: |
| 843 return sizeof(GLshort); // NOLINT | 853 return sizeof(GLshort); // NOLINT |
| 844 case GL_UNSIGNED_SHORT: | 854 case GL_UNSIGNED_SHORT: |
| 845 return sizeof(GLushort); // NOLINT | 855 return sizeof(GLushort); // NOLINT |
| 846 case GL_FLOAT: | 856 case GL_FLOAT: |
| 847 return sizeof(GLfloat); // NOLINT | 857 return sizeof(GLfloat); // NOLINT |
| 848 default: | 858 default: |
| 849 return 0; | 859 return 0; |
| 850 } | 860 } |
| 851 } | 861 } |
| 852 | 862 |
| 853 size_t GLES2Util::GetGLTypeSizeForGLPathNameType(uint32 type) { | 863 size_t GLES2Util::GetGLTypeSizeForGLPathNameType(uint32_t type) { |
| 854 switch (type) { | 864 switch (type) { |
| 855 case GL_BYTE: | 865 case GL_BYTE: |
| 856 return sizeof(GLbyte); // NOLINT | 866 return sizeof(GLbyte); // NOLINT |
| 857 case GL_UNSIGNED_BYTE: | 867 case GL_UNSIGNED_BYTE: |
| 858 return sizeof(GLubyte); // NOLINT | 868 return sizeof(GLubyte); // NOLINT |
| 859 case GL_SHORT: | 869 case GL_SHORT: |
| 860 return sizeof(GLshort); // NOLINT | 870 return sizeof(GLshort); // NOLINT |
| 861 case GL_UNSIGNED_SHORT: | 871 case GL_UNSIGNED_SHORT: |
| 862 return sizeof(GLushort); // NOLINT | 872 return sizeof(GLushort); // NOLINT |
| 863 case GL_INT: | 873 case GL_INT: |
| 864 return sizeof(GLint); // NOLINT | 874 return sizeof(GLint); // NOLINT |
| 865 case GL_UNSIGNED_INT: | 875 case GL_UNSIGNED_INT: |
| 866 return sizeof(GLuint); // NOLINT | 876 return sizeof(GLuint); // NOLINT |
| 867 default: | 877 default: |
| 868 return 0; | 878 return 0; |
| 869 } | 879 } |
| 870 } | 880 } |
| 871 | 881 |
| 872 uint32 GLES2Util::GLErrorToErrorBit(uint32 error) { | 882 uint32_t GLES2Util::GLErrorToErrorBit(uint32_t error) { |
| 873 switch (error) { | 883 switch (error) { |
| 874 case GL_INVALID_ENUM: | 884 case GL_INVALID_ENUM: |
| 875 return gl_error_bit::kInvalidEnum; | 885 return gl_error_bit::kInvalidEnum; |
| 876 case GL_INVALID_VALUE: | 886 case GL_INVALID_VALUE: |
| 877 return gl_error_bit::kInvalidValue; | 887 return gl_error_bit::kInvalidValue; |
| 878 case GL_INVALID_OPERATION: | 888 case GL_INVALID_OPERATION: |
| 879 return gl_error_bit::kInvalidOperation; | 889 return gl_error_bit::kInvalidOperation; |
| 880 case GL_OUT_OF_MEMORY: | 890 case GL_OUT_OF_MEMORY: |
| 881 return gl_error_bit::kOutOfMemory; | 891 return gl_error_bit::kOutOfMemory; |
| 882 case GL_INVALID_FRAMEBUFFER_OPERATION: | 892 case GL_INVALID_FRAMEBUFFER_OPERATION: |
| 883 return gl_error_bit::kInvalidFrameBufferOperation; | 893 return gl_error_bit::kInvalidFrameBufferOperation; |
| 884 case GL_CONTEXT_LOST_KHR: | 894 case GL_CONTEXT_LOST_KHR: |
| 885 return gl_error_bit::kContextLost; | 895 return gl_error_bit::kContextLost; |
| 886 default: | 896 default: |
| 887 NOTREACHED(); | 897 NOTREACHED(); |
| 888 return gl_error_bit::kNoError; | 898 return gl_error_bit::kNoError; |
| 889 } | 899 } |
| 890 } | 900 } |
| 891 | 901 |
| 892 uint32 GLES2Util::GLErrorBitToGLError(uint32 error_bit) { | 902 uint32_t GLES2Util::GLErrorBitToGLError(uint32_t error_bit) { |
| 893 switch (error_bit) { | 903 switch (error_bit) { |
| 894 case gl_error_bit::kInvalidEnum: | 904 case gl_error_bit::kInvalidEnum: |
| 895 return GL_INVALID_ENUM; | 905 return GL_INVALID_ENUM; |
| 896 case gl_error_bit::kInvalidValue: | 906 case gl_error_bit::kInvalidValue: |
| 897 return GL_INVALID_VALUE; | 907 return GL_INVALID_VALUE; |
| 898 case gl_error_bit::kInvalidOperation: | 908 case gl_error_bit::kInvalidOperation: |
| 899 return GL_INVALID_OPERATION; | 909 return GL_INVALID_OPERATION; |
| 900 case gl_error_bit::kOutOfMemory: | 910 case gl_error_bit::kOutOfMemory: |
| 901 return GL_OUT_OF_MEMORY; | 911 return GL_OUT_OF_MEMORY; |
| 902 case gl_error_bit::kInvalidFrameBufferOperation: | 912 case gl_error_bit::kInvalidFrameBufferOperation: |
| 903 return GL_INVALID_FRAMEBUFFER_OPERATION; | 913 return GL_INVALID_FRAMEBUFFER_OPERATION; |
| 904 case gl_error_bit::kContextLost: | 914 case gl_error_bit::kContextLost: |
| 905 return GL_CONTEXT_LOST_KHR; | 915 return GL_CONTEXT_LOST_KHR; |
| 906 default: | 916 default: |
| 907 NOTREACHED(); | 917 NOTREACHED(); |
| 908 return GL_NO_ERROR; | 918 return GL_NO_ERROR; |
| 909 } | 919 } |
| 910 } | 920 } |
| 911 | 921 |
| 912 uint32 GLES2Util::IndexToGLFaceTarget(int index) { | 922 uint32_t GLES2Util::IndexToGLFaceTarget(int index) { |
| 913 static uint32 faces[] = { | 923 static uint32_t faces[] = { |
| 914 GL_TEXTURE_CUBE_MAP_POSITIVE_X, | 924 GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
| 915 GL_TEXTURE_CUBE_MAP_NEGATIVE_X, | 925 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, |
| 916 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, | 926 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, |
| 917 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, | |
| 918 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, | |
| 919 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, | |
| 920 }; | 927 }; |
| 921 return faces[index]; | 928 return faces[index]; |
| 922 } | 929 } |
| 923 | 930 |
| 924 size_t GLES2Util::GLTargetToFaceIndex(uint32 target) { | 931 size_t GLES2Util::GLTargetToFaceIndex(uint32_t target) { |
| 925 switch (target) { | 932 switch (target) { |
| 926 case GL_TEXTURE_2D: | 933 case GL_TEXTURE_2D: |
| 927 case GL_TEXTURE_EXTERNAL_OES: | 934 case GL_TEXTURE_EXTERNAL_OES: |
| 928 case GL_TEXTURE_RECTANGLE_ARB: | 935 case GL_TEXTURE_RECTANGLE_ARB: |
| 929 case GL_TEXTURE_3D: | 936 case GL_TEXTURE_3D: |
| 930 case GL_TEXTURE_2D_ARRAY: | 937 case GL_TEXTURE_2D_ARRAY: |
| 931 return 0; | 938 return 0; |
| 932 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: | 939 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 933 return 0; | 940 return 0; |
| 934 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | 941 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 935 return 1; | 942 return 1; |
| 936 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | 943 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 937 return 2; | 944 return 2; |
| 938 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | 945 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 939 return 3; | 946 return 3; |
| 940 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | 947 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 941 return 4; | 948 return 4; |
| 942 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | 949 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 943 return 5; | 950 return 5; |
| 944 default: | 951 default: |
| 945 NOTREACHED(); | 952 NOTREACHED(); |
| 946 return 0; | 953 return 0; |
| 947 } | 954 } |
| 948 } | 955 } |
| 949 | 956 |
| 950 uint32 GLES2Util::GetGLReadPixelsImplementationFormat( | 957 uint32_t GLES2Util::GetGLReadPixelsImplementationFormat( |
| 951 uint32 internal_format) { | 958 uint32_t internal_format) { |
| 952 switch (internal_format) { | 959 switch (internal_format) { |
| 953 case GL_R8: | 960 case GL_R8: |
| 954 case GL_R16F: | 961 case GL_R16F: |
| 955 case GL_R32F: | 962 case GL_R32F: |
| 956 return GL_RED; | 963 return GL_RED; |
| 957 case GL_R8UI: | 964 case GL_R8UI: |
| 958 case GL_R8I: | 965 case GL_R8I: |
| 959 case GL_R16UI: | 966 case GL_R16UI: |
| 960 case GL_R16I: | 967 case GL_R16I: |
| 961 case GL_R32UI: | 968 case GL_R32UI: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 985 case GL_RGBA16UI: | 992 case GL_RGBA16UI: |
| 986 case GL_RGBA16I: | 993 case GL_RGBA16I: |
| 987 case GL_RGBA32UI: | 994 case GL_RGBA32UI: |
| 988 case GL_RGBA32I: | 995 case GL_RGBA32I: |
| 989 return GL_RGBA_INTEGER; | 996 return GL_RGBA_INTEGER; |
| 990 default: | 997 default: |
| 991 return GL_RGBA; | 998 return GL_RGBA; |
| 992 } | 999 } |
| 993 } | 1000 } |
| 994 | 1001 |
| 995 uint32 GLES2Util::GetGLReadPixelsImplementationType( | 1002 uint32_t GLES2Util::GetGLReadPixelsImplementationType(uint32_t internal_format, |
| 996 uint32 internal_format, uint32 texture_type) { | 1003 uint32_t texture_type) { |
| 997 switch (internal_format) { | 1004 switch (internal_format) { |
| 998 case GL_R16UI: | 1005 case GL_R16UI: |
| 999 case GL_RG16UI: | 1006 case GL_RG16UI: |
| 1000 case GL_RGBA16UI: | 1007 case GL_RGBA16UI: |
| 1001 case GL_RGB10_A2: | 1008 case GL_RGB10_A2: |
| 1002 case GL_RGB10_A2UI: | 1009 case GL_RGB10_A2UI: |
| 1003 return GL_UNSIGNED_SHORT; | 1010 return GL_UNSIGNED_SHORT; |
| 1004 case GL_R32UI: | 1011 case GL_R32UI: |
| 1005 case GL_RG32UI: | 1012 case GL_RG32UI: |
| 1006 case GL_RGBA32UI: | 1013 case GL_RGBA32UI: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 // GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, and | 1048 // GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, and |
| 1042 // GL_UNSIGNED_INT_2_10_10_10_REV. | 1049 // GL_UNSIGNED_INT_2_10_10_10_REV. |
| 1043 default: | 1050 default: |
| 1044 return GL_UNSIGNED_BYTE; | 1051 return GL_UNSIGNED_BYTE; |
| 1045 } | 1052 } |
| 1046 default: | 1053 default: |
| 1047 return GL_UNSIGNED_BYTE; | 1054 return GL_UNSIGNED_BYTE; |
| 1048 } | 1055 } |
| 1049 } | 1056 } |
| 1050 | 1057 |
| 1051 uint32 GLES2Util::GetChannelsForFormat(int format) { | 1058 uint32_t GLES2Util::GetChannelsForFormat(int format) { |
| 1052 switch (format) { | 1059 switch (format) { |
| 1053 case GL_ALPHA: | 1060 case GL_ALPHA: |
| 1054 case GL_ALPHA16F_EXT: | 1061 case GL_ALPHA16F_EXT: |
| 1055 case GL_ALPHA32F_EXT: | 1062 case GL_ALPHA32F_EXT: |
| 1056 return kAlpha; | 1063 return kAlpha; |
| 1057 case GL_LUMINANCE: | 1064 case GL_LUMINANCE: |
| 1058 return kRGB; | 1065 return kRGB; |
| 1059 case GL_LUMINANCE_ALPHA: | 1066 case GL_LUMINANCE_ALPHA: |
| 1060 return kRGBA; | 1067 return kRGBA; |
| 1061 case GL_RGB: | 1068 case GL_RGB: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 case GL_RG16UI: | 1136 case GL_RG16UI: |
| 1130 case GL_RG16I: | 1137 case GL_RG16I: |
| 1131 case GL_RG32UI: | 1138 case GL_RG32UI: |
| 1132 case GL_RG32I: | 1139 case GL_RG32I: |
| 1133 return kRed | kGreen; | 1140 return kRed | kGreen; |
| 1134 default: | 1141 default: |
| 1135 return 0x0000; | 1142 return 0x0000; |
| 1136 } | 1143 } |
| 1137 } | 1144 } |
| 1138 | 1145 |
| 1139 uint32 GLES2Util::GetChannelsNeededForAttachmentType( | 1146 uint32_t GLES2Util::GetChannelsNeededForAttachmentType( |
| 1140 int type, uint32 max_color_attachments) { | 1147 int type, |
| 1148 uint32_t max_color_attachments) { |
| 1141 switch (type) { | 1149 switch (type) { |
| 1142 case GL_DEPTH_ATTACHMENT: | 1150 case GL_DEPTH_ATTACHMENT: |
| 1143 return kDepth; | 1151 return kDepth; |
| 1144 case GL_STENCIL_ATTACHMENT: | 1152 case GL_STENCIL_ATTACHMENT: |
| 1145 return kStencil; | 1153 return kStencil; |
| 1146 default: | 1154 default: |
| 1147 if (type >= GL_COLOR_ATTACHMENT0 && | 1155 if (type >= GL_COLOR_ATTACHMENT0 && |
| 1148 type < static_cast<int>( | 1156 type < static_cast<int>( |
| 1149 GL_COLOR_ATTACHMENT0 + max_color_attachments)) { | 1157 GL_COLOR_ATTACHMENT0 + max_color_attachments)) { |
| 1150 return kRGBA; | 1158 return kRGBA; |
| 1151 } | 1159 } |
| 1152 return 0x0000; | 1160 return 0x0000; |
| 1153 } | 1161 } |
| 1154 } | 1162 } |
| 1155 | 1163 |
| 1156 std::string GLES2Util::GetStringEnum(uint32 value) { | 1164 std::string GLES2Util::GetStringEnum(uint32_t value) { |
| 1157 const EnumToString* entry = enum_to_string_table_; | 1165 const EnumToString* entry = enum_to_string_table_; |
| 1158 const EnumToString* end = entry + enum_to_string_table_len_; | 1166 const EnumToString* end = entry + enum_to_string_table_len_; |
| 1159 for (;entry < end; ++entry) { | 1167 for (;entry < end; ++entry) { |
| 1160 if (value == entry->value) { | 1168 if (value == entry->value) { |
| 1161 return entry->name; | 1169 return entry->name; |
| 1162 } | 1170 } |
| 1163 } | 1171 } |
| 1164 std::stringstream ss; | 1172 std::stringstream ss; |
| 1165 ss.fill('0'); | 1173 ss.fill('0'); |
| 1166 ss.width(value < 0x10000 ? 4 : 8); | 1174 ss.width(value < 0x10000 ? 4 : 8); |
| 1167 ss << std::hex << value; | 1175 ss << std::hex << value; |
| 1168 return "0x" + ss.str(); | 1176 return "0x" + ss.str(); |
| 1169 } | 1177 } |
| 1170 | 1178 |
| 1171 std::string GLES2Util::GetStringError(uint32 value) { | 1179 std::string GLES2Util::GetStringError(uint32_t value) { |
| 1172 static EnumToString string_table[] = { | 1180 static EnumToString string_table[] = { |
| 1173 { GL_NONE, "GL_NONE" }, | 1181 { GL_NONE, "GL_NONE" }, |
| 1174 }; | 1182 }; |
| 1175 return GLES2Util::GetQualifiedEnumString( | 1183 return GLES2Util::GetQualifiedEnumString( |
| 1176 string_table, arraysize(string_table), value); | 1184 string_table, arraysize(string_table), value); |
| 1177 } | 1185 } |
| 1178 | 1186 |
| 1179 std::string GLES2Util::GetStringBool(uint32 value) { | 1187 std::string GLES2Util::GetStringBool(uint32_t value) { |
| 1180 return value ? "GL_TRUE" : "GL_FALSE"; | 1188 return value ? "GL_TRUE" : "GL_FALSE"; |
| 1181 } | 1189 } |
| 1182 | 1190 |
| 1183 std::string GLES2Util::GetQualifiedEnumString( | 1191 std::string GLES2Util::GetQualifiedEnumString(const EnumToString* table, |
| 1184 const EnumToString* table, size_t count, uint32 value) { | 1192 size_t count, |
| 1193 uint32_t value) { |
| 1185 for (const EnumToString* end = table + count; table < end; ++table) { | 1194 for (const EnumToString* end = table + count; table < end; ++table) { |
| 1186 if (table->value == value) { | 1195 if (table->value == value) { |
| 1187 return table->name; | 1196 return table->name; |
| 1188 } | 1197 } |
| 1189 } | 1198 } |
| 1190 return GetStringEnum(value); | 1199 return GetStringEnum(value); |
| 1191 } | 1200 } |
| 1192 | 1201 |
| 1193 GLSLArrayName::GLSLArrayName(const std::string& name) : element_index_(-1) { | 1202 GLSLArrayName::GLSLArrayName(const std::string& name) : element_index_(-1) { |
| 1194 if (name.size() < 4) | 1203 if (name.size() < 4) |
| 1195 return; | 1204 return; |
| 1196 if (name[name.size() - 1] != ']') | 1205 if (name[name.size() - 1] != ']') |
| 1197 return; | 1206 return; |
| 1198 | 1207 |
| 1199 size_t open_pos = name.find_last_of('['); | 1208 size_t open_pos = name.find_last_of('['); |
| 1200 if (open_pos >= name.size() - 2) | 1209 if (open_pos >= name.size() - 2) |
| 1201 return; | 1210 return; |
| 1202 | 1211 |
| 1203 base::CheckedNumeric<int> index = 0; | 1212 base::CheckedNumeric<int> index = 0; |
| 1204 size_t last = name.size() - 1; | 1213 size_t last = name.size() - 1; |
| 1205 for (size_t pos = open_pos + 1; pos < last; ++pos) { | 1214 for (size_t pos = open_pos + 1; pos < last; ++pos) { |
| 1206 int8 digit = name[pos] - '0'; | 1215 int8_t digit = name[pos] - '0'; |
| 1207 if (digit < 0 || digit > 9) | 1216 if (digit < 0 || digit > 9) |
| 1208 return; | 1217 return; |
| 1209 index = index * 10 + digit; | 1218 index = index * 10 + digit; |
| 1210 } | 1219 } |
| 1211 if (!index.IsValid()) | 1220 if (!index.IsValid()) |
| 1212 return; | 1221 return; |
| 1213 element_index_ = index.ValueOrDie(); | 1222 element_index_ = index.ValueOrDie(); |
| 1214 base_name_ = name.substr(0, open_pos); | 1223 base_name_ = name.substr(0, open_pos); |
| 1215 } | 1224 } |
| 1216 | 1225 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 } | 1344 } |
| 1336 } | 1345 } |
| 1337 | 1346 |
| 1338 namespace { | 1347 namespace { |
| 1339 | 1348 |
| 1340 // WebGraphicsContext3DCommandBufferImpl configuration attributes. Those in | 1349 // WebGraphicsContext3DCommandBufferImpl configuration attributes. Those in |
| 1341 // the 16-bit range are the same as used by EGL. Those outside the 16-bit range | 1350 // the 16-bit range are the same as used by EGL. Those outside the 16-bit range |
| 1342 // are unique to Chromium. Attributes are matched using a closest fit algorithm. | 1351 // are unique to Chromium. Attributes are matched using a closest fit algorithm. |
| 1343 | 1352 |
| 1344 // From <EGL/egl.h>. | 1353 // From <EGL/egl.h>. |
| 1345 const int32 kAlphaSize = 0x3021; // EGL_ALPHA_SIZE | 1354 #include <stddef.h> |
| 1346 const int32 kBlueSize = 0x3022; // EGL_BLUE_SIZE | 1355 #include <stdint.h> |
| 1347 const int32 kGreenSize = 0x3023; // EGL_GREEN_SIZE | 1356 const int32_t kAlphaSize = 0x3021; // EGL_ALPHA_SIZE |
| 1348 const int32 kRedSize = 0x3024; // EGL_RED_SIZE | 1357 const int32_t kBlueSize = 0x3022; // EGL_BLUE_SIZE |
| 1349 const int32 kDepthSize = 0x3025; // EGL_DEPTH_SIZE | 1358 const int32_t kGreenSize = 0x3023; // EGL_GREEN_SIZE |
| 1350 const int32 kStencilSize = 0x3026; // EGL_STENCIL_SIZE | 1359 const int32_t kRedSize = 0x3024; // EGL_RED_SIZE |
| 1351 const int32 kSamples = 0x3031; // EGL_SAMPLES | 1360 const int32_t kDepthSize = 0x3025; // EGL_DEPTH_SIZE |
| 1352 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS | 1361 const int32_t kStencilSize = 0x3026; // EGL_STENCIL_SIZE |
| 1353 const int32 kNone = 0x3038; // EGL_NONE | 1362 const int32_t kSamples = 0x3031; // EGL_SAMPLES |
| 1354 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR | 1363 const int32_t kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
| 1355 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED | 1364 const int32_t kNone = 0x3038; // EGL_NONE |
| 1356 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED | 1365 const int32_t kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
| 1366 const int32_t kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
| 1367 const int32_t kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
| 1357 | 1368 |
| 1358 // Chromium only. | 1369 // Chromium only. |
| 1359 const int32 kBindGeneratesResource = 0x10000; | 1370 const int32_t kBindGeneratesResource = 0x10000; |
| 1360 const int32 kFailIfMajorPerfCaveat = 0x10001; | 1371 const int32_t kFailIfMajorPerfCaveat = 0x10001; |
| 1361 const int32 kLoseContextWhenOutOfMemory = 0x10002; | 1372 const int32_t kLoseContextWhenOutOfMemory = 0x10002; |
| 1362 const int32 kContextType = 0x10003; | 1373 const int32_t kContextType = 0x10003; |
| 1363 | 1374 |
| 1364 } // namespace | 1375 } // namespace |
| 1365 | 1376 |
| 1366 ContextCreationAttribHelper::ContextCreationAttribHelper() | 1377 ContextCreationAttribHelper::ContextCreationAttribHelper() |
| 1367 : alpha_size(-1), | 1378 : alpha_size(-1), |
| 1368 blue_size(-1), | 1379 blue_size(-1), |
| 1369 green_size(-1), | 1380 green_size(-1), |
| 1370 red_size(-1), | 1381 red_size(-1), |
| 1371 depth_size(-1), | 1382 depth_size(-1), |
| 1372 stencil_size(-1), | 1383 stencil_size(-1), |
| 1373 samples(-1), | 1384 samples(-1), |
| 1374 sample_buffers(-1), | 1385 sample_buffers(-1), |
| 1375 buffer_preserved(true), | 1386 buffer_preserved(true), |
| 1376 bind_generates_resource(true), | 1387 bind_generates_resource(true), |
| 1377 fail_if_major_perf_caveat(false), | 1388 fail_if_major_perf_caveat(false), |
| 1378 lose_context_when_out_of_memory(false), | 1389 lose_context_when_out_of_memory(false), |
| 1379 context_type(CONTEXT_TYPE_OPENGLES2) {} | 1390 context_type(CONTEXT_TYPE_OPENGLES2) {} |
| 1380 | 1391 |
| 1381 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { | 1392 void ContextCreationAttribHelper::Serialize( |
| 1393 std::vector<int32_t>* attribs) const { |
| 1382 if (alpha_size != -1) { | 1394 if (alpha_size != -1) { |
| 1383 attribs->push_back(kAlphaSize); | 1395 attribs->push_back(kAlphaSize); |
| 1384 attribs->push_back(alpha_size); | 1396 attribs->push_back(alpha_size); |
| 1385 } | 1397 } |
| 1386 if (blue_size != -1) { | 1398 if (blue_size != -1) { |
| 1387 attribs->push_back(kBlueSize); | 1399 attribs->push_back(kBlueSize); |
| 1388 attribs->push_back(blue_size); | 1400 attribs->push_back(blue_size); |
| 1389 } | 1401 } |
| 1390 if (green_size != -1) { | 1402 if (green_size != -1) { |
| 1391 attribs->push_back(kGreenSize); | 1403 attribs->push_back(kGreenSize); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1417 attribs->push_back(bind_generates_resource ? 1 : 0); | 1429 attribs->push_back(bind_generates_resource ? 1 : 0); |
| 1418 attribs->push_back(kFailIfMajorPerfCaveat); | 1430 attribs->push_back(kFailIfMajorPerfCaveat); |
| 1419 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); | 1431 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); |
| 1420 attribs->push_back(kLoseContextWhenOutOfMemory); | 1432 attribs->push_back(kLoseContextWhenOutOfMemory); |
| 1421 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); | 1433 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); |
| 1422 attribs->push_back(kContextType); | 1434 attribs->push_back(kContextType); |
| 1423 attribs->push_back(context_type); | 1435 attribs->push_back(context_type); |
| 1424 attribs->push_back(kNone); | 1436 attribs->push_back(kNone); |
| 1425 } | 1437 } |
| 1426 | 1438 |
| 1427 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { | 1439 bool ContextCreationAttribHelper::Parse(const std::vector<int32_t>& attribs) { |
| 1428 for (size_t i = 0; i < attribs.size(); i += 2) { | 1440 for (size_t i = 0; i < attribs.size(); i += 2) { |
| 1429 const int32 attrib = attribs[i]; | 1441 const int32_t attrib = attribs[i]; |
| 1430 if (i + 1 >= attribs.size()) { | 1442 if (i + 1 >= attribs.size()) { |
| 1431 if (attrib == kNone) { | 1443 if (attrib == kNone) { |
| 1432 return true; | 1444 return true; |
| 1433 } | 1445 } |
| 1434 | 1446 |
| 1435 DLOG(ERROR) << "Missing value after context creation attribute: " | 1447 DLOG(ERROR) << "Missing value after context creation attribute: " |
| 1436 << attrib; | 1448 << attrib; |
| 1437 return false; | 1449 return false; |
| 1438 } | 1450 } |
| 1439 | 1451 |
| 1440 const int32 value = attribs[i+1]; | 1452 const int32_t value = attribs[i + 1]; |
| 1441 switch (attrib) { | 1453 switch (attrib) { |
| 1442 case kAlphaSize: | 1454 case kAlphaSize: |
| 1443 alpha_size = value; | 1455 alpha_size = value; |
| 1444 break; | 1456 break; |
| 1445 case kBlueSize: | 1457 case kBlueSize: |
| 1446 blue_size = value; | 1458 blue_size = value; |
| 1447 break; | 1459 break; |
| 1448 case kGreenSize: | 1460 case kGreenSize: |
| 1449 green_size = value; | 1461 green_size = value; |
| 1450 break; | 1462 break; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 } | 1500 } |
| 1489 | 1501 |
| 1490 return true; | 1502 return true; |
| 1491 } | 1503 } |
| 1492 | 1504 |
| 1493 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1505 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
| 1494 | 1506 |
| 1495 } // namespace gles2 | 1507 } // namespace gles2 |
| 1496 } // namespace gpu | 1508 } // namespace gpu |
| 1497 | 1509 |
| OLD | NEW |