Chromium Code Reviews| 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 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 #endif | 505 #endif |
| 506 } | 506 } |
| 507 | 507 |
| 508 void DeleteShader(GLuint shader) { | 508 void DeleteShader(GLuint shader) { |
| 509 if (shader) | 509 if (shader) |
| 510 glDeleteShader(shader); | 510 glDeleteShader(shader); |
| 511 } | 511 } |
| 512 | 512 |
| 513 bool BindFramebufferTexture2D(GLenum target, | 513 bool BindFramebufferTexture2D(GLenum target, |
| 514 GLuint texture_id, | 514 GLuint texture_id, |
| 515 GLint level, | |
| 515 GLuint framebuffer) { | 516 GLuint framebuffer) { |
| 516 DCHECK(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE_ARB); | 517 DCHECK(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE_ARB); |
| 517 glActiveTexture(GL_TEXTURE0); | 518 glActiveTexture(GL_TEXTURE0); |
| 518 glBindTexture(target, texture_id); | 519 glBindTexture(target, texture_id); |
| 519 // NVidia drivers require texture settings to be a certain way | 520 // NVidia drivers require texture settings to be a certain way |
| 520 // or they won't report FRAMEBUFFER_COMPLETE. | 521 // or they won't report FRAMEBUFFER_COMPLETE. |
| 522 if (level > 0) | |
| 523 glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, level); | |
|
Zhenyao Mo
2017/01/10 20:11:22
Do we recover this parameter afterwards?
qiankun
2017/01/11 10:58:21
I added the recover in decoder->RestoreTextureStat
| |
| 521 glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 524 glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 522 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 525 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 523 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 526 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 524 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 527 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 525 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer); | 528 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer); |
| 526 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, | 529 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, |
| 527 texture_id, 0); | 530 texture_id, level); |
| 531 DCHECK(glGetError() == GL_NO_ERROR); | |
|
Zhenyao Mo
2017/01/10 20:11:22
This is wrong. It might swallow a GL error from pr
qiankun
2017/01/11 10:58:21
Remove this DCHECK.
| |
| 528 | 532 |
| 529 #ifndef NDEBUG | 533 #ifndef NDEBUG |
| 530 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 534 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
| 531 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { | 535 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { |
| 532 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; | 536 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; |
| 533 return false; | 537 return false; |
| 534 } | 538 } |
| 535 #endif | 539 #endif |
| 536 return true; | 540 return true; |
| 537 } | 541 } |
| 538 | 542 |
| 539 void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder, | 543 void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder, |
| 540 GLenum source_target, | 544 GLenum source_target, |
| 541 GLuint source_id, | 545 GLuint source_id, |
| 546 GLint source_level, | |
| 542 GLenum dest_target, | 547 GLenum dest_target, |
| 543 GLuint dest_id, | 548 GLuint dest_id, |
| 549 GLint dest_level, | |
| 544 GLenum dest_internal_format, | 550 GLenum dest_internal_format, |
| 545 GLsizei width, | 551 GLsizei width, |
| 546 GLsizei height, | 552 GLsizei height, |
| 547 GLuint framebuffer) { | 553 GLuint framebuffer) { |
| 548 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), source_target); | 554 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), source_target); |
| 549 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), dest_target); | 555 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), dest_target); |
| 550 if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) { | 556 DCHECK(source_level == 0 || decoder->GetFeatureInfo()->IsES3Capable()); |
| 557 if (BindFramebufferTexture2D(source_target, source_id, source_level, | |
| 558 framebuffer)) { | |
| 551 glBindTexture(dest_target, dest_id); | 559 glBindTexture(dest_target, dest_id); |
| 552 glTexParameterf(dest_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 560 glTexParameterf(dest_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 553 glTexParameterf(dest_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 561 glTexParameterf(dest_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 554 glTexParameteri(dest_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 562 glTexParameteri(dest_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 555 glTexParameteri(dest_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 563 glTexParameteri(dest_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 556 glCopyTexImage2D(dest_target, 0 /* level */, dest_internal_format, | 564 glCopyTexImage2D(dest_target, dest_level, dest_internal_format, 0 /* x */, |
| 557 0 /* x */, 0 /* y */, width, height, 0 /* border */); | 565 0 /* y */, width, height, 0 /* border */); |
| 558 } | 566 } |
| 559 | 567 |
| 560 decoder->RestoreTextureState(source_id); | 568 decoder->RestoreTextureState(source_id); |
| 561 decoder->RestoreTextureState(dest_id); | 569 decoder->RestoreTextureState(dest_id); |
| 562 decoder->RestoreTextureUnitBindings(0); | 570 decoder->RestoreTextureUnitBindings(0); |
| 563 decoder->RestoreActiveTexture(); | 571 decoder->RestoreActiveTexture(); |
| 564 decoder->RestoreFramebufferBindings(); | 572 decoder->RestoreFramebufferBindings(); |
| 565 } | 573 } |
| 566 | 574 |
| 567 void DoCopyTexSubImage2D(const gpu::gles2::GLES2Decoder* decoder, | 575 void DoCopyTexSubImage2D(const gpu::gles2::GLES2Decoder* decoder, |
| 568 GLenum source_target, | 576 GLenum source_target, |
| 569 GLuint source_id, | 577 GLuint source_id, |
| 578 GLint source_level, | |
| 570 GLenum dest_target, | 579 GLenum dest_target, |
| 571 GLuint dest_id, | 580 GLuint dest_id, |
| 581 GLint dest_level, | |
| 572 GLint xoffset, | 582 GLint xoffset, |
| 573 GLint yoffset, | 583 GLint yoffset, |
| 574 GLint source_x, | 584 GLint source_x, |
| 575 GLint source_y, | 585 GLint source_y, |
| 576 GLsizei source_width, | 586 GLsizei source_width, |
| 577 GLsizei source_height, | 587 GLsizei source_height, |
| 578 GLuint framebuffer) { | 588 GLuint framebuffer) { |
| 579 DCHECK(source_target == GL_TEXTURE_2D || | 589 DCHECK(source_target == GL_TEXTURE_2D || |
| 580 source_target == GL_TEXTURE_RECTANGLE_ARB); | 590 source_target == GL_TEXTURE_RECTANGLE_ARB); |
| 581 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), dest_target); | 591 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), dest_target); |
| 582 if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) { | 592 DCHECK(source_level == 0 || decoder->GetFeatureInfo()->IsES3Capable()); |
| 593 if (BindFramebufferTexture2D(source_target, source_id, source_level, | |
| 594 framebuffer)) { | |
| 583 glBindTexture(dest_target, dest_id); | 595 glBindTexture(dest_target, dest_id); |
| 584 glTexParameterf(dest_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 596 glTexParameterf(dest_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 585 glTexParameterf(dest_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 597 glTexParameterf(dest_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 586 glTexParameteri(dest_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 598 glTexParameteri(dest_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 587 glTexParameteri(dest_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 599 glTexParameteri(dest_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 588 glCopyTexSubImage2D(dest_target, 0 /* level */, xoffset, yoffset, | 600 glCopyTexSubImage2D(dest_target, dest_level, xoffset, yoffset, source_x, |
| 589 source_x, source_y, source_width, source_height); | 601 source_y, source_width, source_height); |
| 590 } | 602 } |
| 591 | 603 |
| 592 decoder->RestoreTextureState(source_id); | 604 decoder->RestoreTextureState(source_id); |
| 593 decoder->RestoreTextureState(dest_id); | 605 decoder->RestoreTextureState(dest_id); |
| 594 decoder->RestoreTextureUnitBindings(0); | 606 decoder->RestoreTextureUnitBindings(0); |
| 595 decoder->RestoreActiveTexture(); | 607 decoder->RestoreActiveTexture(); |
| 596 decoder->RestoreFramebufferBindings(); | 608 decoder->RestoreFramebufferBindings(); |
| 597 } | 609 } |
| 598 | 610 |
| 599 } // namespace | 611 } // namespace |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 } | 694 } |
| 683 | 695 |
| 684 glDeleteBuffersARB(1, &buffer_id_); | 696 glDeleteBuffersARB(1, &buffer_id_); |
| 685 buffer_id_ = 0; | 697 buffer_id_ = 0; |
| 686 } | 698 } |
| 687 | 699 |
| 688 void CopyTextureCHROMIUMResourceManager::DoCopyTexture( | 700 void CopyTextureCHROMIUMResourceManager::DoCopyTexture( |
| 689 const gles2::GLES2Decoder* decoder, | 701 const gles2::GLES2Decoder* decoder, |
| 690 GLenum source_target, | 702 GLenum source_target, |
| 691 GLuint source_id, | 703 GLuint source_id, |
| 704 GLint source_level, | |
| 692 GLenum source_internal_format, | 705 GLenum source_internal_format, |
| 693 GLenum dest_target, | 706 GLenum dest_target, |
| 694 GLuint dest_id, | 707 GLuint dest_id, |
| 708 GLint dest_level, | |
| 695 GLenum dest_internal_format, | 709 GLenum dest_internal_format, |
| 696 GLsizei width, | 710 GLsizei width, |
| 697 GLsizei height, | 711 GLsizei height, |
| 698 bool flip_y, | 712 bool flip_y, |
| 699 bool premultiply_alpha, | 713 bool premultiply_alpha, |
| 700 bool unpremultiply_alpha, | 714 bool unpremultiply_alpha, |
| 701 CopyTextureMethod method) { | 715 CopyTextureMethod method) { |
| 702 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; | 716 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
| 703 | 717 |
| 704 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, | 718 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, |
| 705 // so restrict this to GL_TEXTURE_2D. | 719 // so restrict this to GL_TEXTURE_2D. |
| 706 if (source_target == GL_TEXTURE_2D && dest_target == GL_TEXTURE_2D && | 720 if (source_target == GL_TEXTURE_2D && dest_target == GL_TEXTURE_2D && |
| 707 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) { | 721 !flip_y && !premultiply_alpha_change && method == DIRECT_COPY) { |
| 708 DoCopyTexImage2D(decoder, | 722 DoCopyTexImage2D(decoder, source_target, source_id, source_level, |
| 709 source_target, | 723 dest_target, dest_id, dest_level, dest_internal_format, |
| 710 source_id, | 724 width, height, framebuffer_); |
| 711 dest_target, | |
| 712 dest_id, | |
| 713 dest_internal_format, | |
| 714 width, | |
| 715 height, | |
| 716 framebuffer_); | |
| 717 return; | 725 return; |
| 718 } | 726 } |
| 719 | 727 |
| 720 GLuint dest_texture = dest_id; | 728 GLuint dest_texture = dest_id; |
| 721 GLuint intermediate_texture = 0; | 729 GLuint intermediate_texture = 0; |
| 730 GLint original_dest_level = dest_level; | |
| 722 if (method == DRAW_AND_COPY) { | 731 if (method == DRAW_AND_COPY) { |
| 723 GLenum adjusted_internal_format = | 732 GLenum adjusted_internal_format = |
| 724 getIntermediateFormat(dest_internal_format); | 733 getIntermediateFormat(dest_internal_format); |
| 725 glGenTextures(1, &intermediate_texture); | 734 glGenTextures(1, &intermediate_texture); |
| 726 glBindTexture(dest_target, intermediate_texture); | 735 glBindTexture(dest_target, intermediate_texture); |
| 727 GLenum format = TextureManager::ExtractFormatFromStorageFormat( | 736 GLenum format = TextureManager::ExtractFormatFromStorageFormat( |
| 728 adjusted_internal_format); | 737 adjusted_internal_format); |
| 729 GLenum type = | 738 GLenum type = |
| 730 TextureManager::ExtractTypeFromStorageFormat(adjusted_internal_format); | 739 TextureManager::ExtractTypeFromStorageFormat(adjusted_internal_format); |
| 731 | 740 |
| 732 glTexImage2D(dest_target, 0, adjusted_internal_format, width, height, 0, | 741 glTexImage2D(dest_target, 0, adjusted_internal_format, width, height, 0, |
| 733 format, type, nullptr); | 742 format, type, nullptr); |
| 734 dest_texture = intermediate_texture; | 743 dest_texture = intermediate_texture; |
| 744 dest_level = 0; | |
| 735 dest_internal_format = adjusted_internal_format; | 745 dest_internal_format = adjusted_internal_format; |
| 736 } | 746 } |
| 737 // Use kIdentityMatrix if no transform passed in. | 747 // Use kIdentityMatrix if no transform passed in. |
| 738 DoCopyTextureWithTransform( | 748 DoCopyTextureWithTransform( |
| 739 decoder, source_target, source_id, source_internal_format, dest_target, | 749 decoder, source_target, source_id, source_level, source_internal_format, |
| 740 dest_texture, dest_internal_format, width, height, flip_y, | 750 dest_target, dest_texture, dest_level, dest_internal_format, width, |
| 741 premultiply_alpha, unpremultiply_alpha, kIdentityMatrix); | 751 height, flip_y, premultiply_alpha, unpremultiply_alpha, kIdentityMatrix); |
| 742 | 752 |
| 743 if (method == DRAW_AND_COPY) { | 753 if (method == DRAW_AND_COPY) { |
| 744 DoCopyTexImage2D(decoder, dest_target, intermediate_texture, dest_target, | 754 source_level = 0; |
| 745 dest_id, dest_internal_format, width, height, | 755 dest_level = original_dest_level; |
| 746 framebuffer_); | 756 DoCopyTexImage2D(decoder, dest_target, intermediate_texture, source_level, |
| 757 dest_target, dest_id, dest_level, dest_internal_format, | |
| 758 width, height, framebuffer_); | |
| 747 glDeleteTextures(1, &intermediate_texture); | 759 glDeleteTextures(1, &intermediate_texture); |
| 748 } | 760 } |
| 749 } | 761 } |
| 750 | 762 |
| 751 void CopyTextureCHROMIUMResourceManager::DoCopySubTexture( | 763 void CopyTextureCHROMIUMResourceManager::DoCopySubTexture( |
| 752 const gles2::GLES2Decoder* decoder, | 764 const gles2::GLES2Decoder* decoder, |
| 753 GLenum source_target, | 765 GLenum source_target, |
| 754 GLuint source_id, | 766 GLuint source_id, |
| 767 GLint source_level, | |
| 755 GLenum source_internal_format, | 768 GLenum source_internal_format, |
| 756 GLenum dest_target, | 769 GLenum dest_target, |
| 757 GLuint dest_id, | 770 GLuint dest_id, |
| 771 GLint dest_level, | |
| 758 GLenum dest_internal_format, | 772 GLenum dest_internal_format, |
| 759 GLint xoffset, | 773 GLint xoffset, |
| 760 GLint yoffset, | 774 GLint yoffset, |
| 761 GLint x, | 775 GLint x, |
| 762 GLint y, | 776 GLint y, |
| 763 GLsizei width, | 777 GLsizei width, |
| 764 GLsizei height, | 778 GLsizei height, |
| 765 GLsizei dest_width, | 779 GLsizei dest_width, |
| 766 GLsizei dest_height, | 780 GLsizei dest_height, |
| 767 GLsizei source_width, | 781 GLsizei source_width, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 778 // https://bugs.freedesktop.org/show_bug.cgi?id=98478 crbug.com/535198 | 792 // https://bugs.freedesktop.org/show_bug.cgi?id=98478 crbug.com/535198 |
| 779 use_gl_copy_tex_sub_image_2d = false; | 793 use_gl_copy_tex_sub_image_2d = false; |
| 780 #endif | 794 #endif |
| 781 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; | 795 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
| 782 | 796 |
| 783 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, | 797 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, |
| 784 // so restrict this to GL_TEXTURE_2D. | 798 // so restrict this to GL_TEXTURE_2D. |
| 785 if (use_gl_copy_tex_sub_image_2d && source_target == GL_TEXTURE_2D && | 799 if (use_gl_copy_tex_sub_image_2d && source_target == GL_TEXTURE_2D && |
| 786 dest_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && | 800 dest_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && |
| 787 method == DIRECT_COPY) { | 801 method == DIRECT_COPY) { |
| 788 DoCopyTexSubImage2D(decoder, source_target, source_id, dest_target, dest_id, | 802 DoCopyTexSubImage2D(decoder, source_target, source_id, source_level, |
| 789 xoffset, yoffset, x, y, width, height, framebuffer_); | 803 dest_target, dest_id, dest_level, xoffset, yoffset, x, |
| 804 y, width, height, framebuffer_); | |
| 790 return; | 805 return; |
| 791 } | 806 } |
| 792 | 807 |
| 793 GLint dest_xoffset = xoffset; | 808 GLint dest_xoffset = xoffset; |
| 794 GLint dest_yoffset = yoffset; | 809 GLint dest_yoffset = yoffset; |
| 795 GLuint dest_texture = dest_id; | 810 GLuint dest_texture = dest_id; |
| 811 GLint original_dest_level = dest_level; | |
| 796 GLuint intermediate_texture = 0; | 812 GLuint intermediate_texture = 0; |
| 797 if (method == DRAW_AND_COPY) { | 813 if (method == DRAW_AND_COPY) { |
| 798 GLenum adjusted_internal_format = | 814 GLenum adjusted_internal_format = |
| 799 getIntermediateFormat(dest_internal_format); | 815 getIntermediateFormat(dest_internal_format); |
| 800 glGenTextures(1, &intermediate_texture); | 816 glGenTextures(1, &intermediate_texture); |
| 801 glBindTexture(dest_target, intermediate_texture); | 817 glBindTexture(dest_target, intermediate_texture); |
| 802 GLenum format = TextureManager::ExtractFormatFromStorageFormat( | 818 GLenum format = TextureManager::ExtractFormatFromStorageFormat( |
| 803 adjusted_internal_format); | 819 adjusted_internal_format); |
| 804 GLenum type = | 820 GLenum type = |
| 805 TextureManager::ExtractTypeFromStorageFormat(adjusted_internal_format); | 821 TextureManager::ExtractTypeFromStorageFormat(adjusted_internal_format); |
| 806 | 822 |
| 807 glTexImage2D(dest_target, 0, adjusted_internal_format, width, height, 0, | 823 glTexImage2D(dest_target, 0, adjusted_internal_format, width, height, 0, |
| 808 format, type, nullptr); | 824 format, type, nullptr); |
| 809 dest_texture = intermediate_texture; | 825 dest_texture = intermediate_texture; |
| 826 dest_level = 0; | |
| 810 dest_internal_format = adjusted_internal_format; | 827 dest_internal_format = adjusted_internal_format; |
| 811 dest_xoffset = 0; | 828 dest_xoffset = 0; |
| 812 dest_yoffset = 0; | 829 dest_yoffset = 0; |
| 813 dest_width = width; | 830 dest_width = width; |
| 814 dest_height = height; | 831 dest_height = height; |
| 815 } | 832 } |
| 816 | 833 |
| 817 DoCopySubTextureWithTransform( | 834 DoCopySubTextureWithTransform( |
| 818 decoder, source_target, source_id, source_internal_format, dest_target, | 835 decoder, source_target, source_id, source_level, source_internal_format, |
| 819 dest_texture, dest_internal_format, dest_xoffset, dest_yoffset, x, y, | 836 dest_target, dest_texture, dest_level, dest_internal_format, dest_xoffset, |
| 820 width, height, dest_width, dest_height, source_width, source_height, | 837 dest_yoffset, x, y, width, height, dest_width, dest_height, source_width, |
| 821 flip_y, premultiply_alpha, unpremultiply_alpha, kIdentityMatrix); | 838 source_height, flip_y, premultiply_alpha, unpremultiply_alpha, |
| 839 kIdentityMatrix); | |
| 822 | 840 |
| 823 if (method == DRAW_AND_COPY) { | 841 if (method == DRAW_AND_COPY) { |
| 824 DoCopyTexSubImage2D(decoder, dest_target, intermediate_texture, dest_target, | 842 source_level = 0; |
| 825 dest_id, xoffset, yoffset, 0, 0, width, height, | 843 dest_level = original_dest_level; |
| 826 framebuffer_); | 844 DoCopyTexSubImage2D(decoder, dest_target, intermediate_texture, |
| 845 source_level, dest_target, dest_id, dest_level, xoffset, | |
| 846 yoffset, 0, 0, width, height, framebuffer_); | |
| 827 glDeleteTextures(1, &intermediate_texture); | 847 glDeleteTextures(1, &intermediate_texture); |
| 828 } | 848 } |
| 829 } | 849 } |
| 830 | 850 |
| 831 void CopyTextureCHROMIUMResourceManager::DoCopySubTextureWithTransform( | 851 void CopyTextureCHROMIUMResourceManager::DoCopySubTextureWithTransform( |
| 832 const gles2::GLES2Decoder* decoder, | 852 const gles2::GLES2Decoder* decoder, |
| 833 GLenum source_target, | 853 GLenum source_target, |
| 834 GLuint source_id, | 854 GLuint source_id, |
| 855 GLint source_level, | |
| 835 GLenum source_internal_format, | 856 GLenum source_internal_format, |
| 836 GLenum dest_target, | 857 GLenum dest_target, |
| 837 GLuint dest_id, | 858 GLuint dest_id, |
| 859 GLint dest_level, | |
| 838 GLenum dest_internal_format, | 860 GLenum dest_internal_format, |
| 839 GLint xoffset, | 861 GLint xoffset, |
| 840 GLint yoffset, | 862 GLint yoffset, |
| 841 GLint x, | 863 GLint x, |
| 842 GLint y, | 864 GLint y, |
| 843 GLsizei width, | 865 GLsizei width, |
| 844 GLsizei height, | 866 GLsizei height, |
| 845 GLsizei dest_width, | 867 GLsizei dest_width, |
| 846 GLsizei dest_height, | 868 GLsizei dest_height, |
| 847 GLsizei source_width, | 869 GLsizei source_width, |
| 848 GLsizei source_height, | 870 GLsizei source_height, |
| 849 bool flip_y, | 871 bool flip_y, |
| 850 bool premultiply_alpha, | 872 bool premultiply_alpha, |
| 851 bool unpremultiply_alpha, | 873 bool unpremultiply_alpha, |
| 852 const GLfloat transform_matrix[16]) { | 874 const GLfloat transform_matrix[16]) { |
| 853 DoCopyTextureInternal( | 875 DoCopyTextureInternal( |
| 854 decoder, source_target, source_id, source_internal_format, dest_target, | 876 decoder, source_target, source_id, source_level, source_internal_format, |
| 855 dest_id, dest_internal_format, xoffset, yoffset, x, y, width, height, | 877 dest_target, dest_id, dest_level, dest_internal_format, xoffset, yoffset, |
| 856 dest_width, dest_height, source_width, source_height, flip_y, | 878 x, y, width, height, dest_width, dest_height, source_width, source_height, |
| 857 premultiply_alpha, unpremultiply_alpha, transform_matrix); | 879 flip_y, premultiply_alpha, unpremultiply_alpha, transform_matrix); |
| 858 } | 880 } |
| 859 | 881 |
| 860 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( | 882 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( |
| 861 const gles2::GLES2Decoder* decoder, | 883 const gles2::GLES2Decoder* decoder, |
| 862 GLenum source_target, | 884 GLenum source_target, |
| 863 GLuint source_id, | 885 GLuint source_id, |
| 886 GLint source_level, | |
| 864 GLenum source_format, | 887 GLenum source_format, |
| 865 GLenum dest_target, | 888 GLenum dest_target, |
| 866 GLuint dest_id, | 889 GLuint dest_id, |
| 890 GLint dest_level, | |
| 867 GLenum dest_format, | 891 GLenum dest_format, |
| 868 GLsizei width, | 892 GLsizei width, |
| 869 GLsizei height, | 893 GLsizei height, |
| 870 bool flip_y, | 894 bool flip_y, |
| 871 bool premultiply_alpha, | 895 bool premultiply_alpha, |
| 872 bool unpremultiply_alpha, | 896 bool unpremultiply_alpha, |
| 873 const GLfloat transform_matrix[16]) { | 897 const GLfloat transform_matrix[16]) { |
| 874 GLsizei dest_width = width; | 898 GLsizei dest_width = width; |
| 875 GLsizei dest_height = height; | 899 GLsizei dest_height = height; |
| 876 DoCopyTextureInternal( | 900 DoCopyTextureInternal(decoder, source_target, source_id, source_level, |
| 877 decoder, source_target, source_id, source_format, dest_target, dest_id, | 901 source_format, dest_target, dest_id, dest_level, |
| 878 dest_format, 0, 0, 0, 0, width, height, dest_width, dest_height, width, | 902 dest_format, 0, 0, 0, 0, width, height, dest_width, |
| 879 height, flip_y, premultiply_alpha, unpremultiply_alpha, transform_matrix); | 903 dest_height, width, height, flip_y, premultiply_alpha, |
| 904 unpremultiply_alpha, transform_matrix); | |
| 880 } | 905 } |
| 881 | 906 |
| 882 void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal( | 907 void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal( |
| 883 const gles2::GLES2Decoder* decoder, | 908 const gles2::GLES2Decoder* decoder, |
| 884 GLenum source_target, | 909 GLenum source_target, |
| 885 GLuint source_id, | 910 GLuint source_id, |
| 911 GLint source_level, | |
| 886 GLenum source_format, | 912 GLenum source_format, |
| 887 GLenum dest_target, | 913 GLenum dest_target, |
| 888 GLuint dest_id, | 914 GLuint dest_id, |
| 915 GLint dest_level, | |
| 889 GLenum dest_format, | 916 GLenum dest_format, |
| 890 GLint xoffset, | 917 GLint xoffset, |
| 891 GLint yoffset, | 918 GLint yoffset, |
| 892 GLint x, | 919 GLint x, |
| 893 GLint y, | 920 GLint y, |
| 894 GLsizei width, | 921 GLsizei width, |
| 895 GLsizei height, | 922 GLsizei height, |
| 896 GLsizei dest_width, | 923 GLsizei dest_width, |
| 897 GLsizei dest_height, | 924 GLsizei dest_height, |
| 898 GLsizei source_width, | 925 GLsizei source_width, |
| 899 GLsizei source_height, | 926 GLsizei source_height, |
| 900 bool flip_y, | 927 bool flip_y, |
| 901 bool premultiply_alpha, | 928 bool premultiply_alpha, |
| 902 bool unpremultiply_alpha, | 929 bool unpremultiply_alpha, |
| 903 const GLfloat transform_matrix[16]) { | 930 const GLfloat transform_matrix[16]) { |
| 904 DCHECK(source_target == GL_TEXTURE_2D || | 931 DCHECK(source_target == GL_TEXTURE_2D || |
| 905 source_target == GL_TEXTURE_RECTANGLE_ARB || | 932 source_target == GL_TEXTURE_RECTANGLE_ARB || |
| 906 source_target == GL_TEXTURE_EXTERNAL_OES); | 933 source_target == GL_TEXTURE_EXTERNAL_OES); |
| 907 DCHECK(dest_target == GL_TEXTURE_2D || | 934 DCHECK(dest_target == GL_TEXTURE_2D || |
| 908 dest_target == GL_TEXTURE_RECTANGLE_ARB); | 935 dest_target == GL_TEXTURE_RECTANGLE_ARB); |
| 936 DCHECK_GE(source_level, 0); | |
| 937 DCHECK_GE(dest_level, 0); | |
| 909 DCHECK_GE(xoffset, 0); | 938 DCHECK_GE(xoffset, 0); |
| 910 DCHECK_LE(xoffset + width, dest_width); | 939 DCHECK_LE(xoffset + width, dest_width); |
| 911 DCHECK_GE(yoffset, 0); | 940 DCHECK_GE(yoffset, 0); |
| 912 DCHECK_LE(yoffset + height, dest_height); | 941 DCHECK_LE(yoffset + height, dest_height); |
| 913 if (dest_width == 0 || dest_height == 0 || source_width == 0 || | 942 if (dest_width == 0 || dest_height == 0 || source_width == 0 || |
| 914 source_height == 0) { | 943 source_height == 0) { |
| 915 return; | 944 return; |
| 916 } | 945 } |
| 917 | 946 |
| 918 if (!initialized_) { | 947 if (!initialized_) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 // So everything is the same but the sign of A is flipped. | 1079 // So everything is the same but the sign of A is flipped. |
| 1051 GLfloat m_x = source_target == GL_TEXTURE_RECTANGLE_ARB ? source_width : 1; | 1080 GLfloat m_x = source_target == GL_TEXTURE_RECTANGLE_ARB ? source_width : 1; |
| 1052 GLfloat m_y = source_target == GL_TEXTURE_RECTANGLE_ARB ? source_height : 1; | 1081 GLfloat m_y = source_target == GL_TEXTURE_RECTANGLE_ARB ? source_height : 1; |
| 1053 GLfloat sign_a = flip_y ? -1 : 1; | 1082 GLfloat sign_a = flip_y ? -1 : 1; |
| 1054 glUniform2f(info->vertex_source_mult_handle, width / 2.f * m_x / source_width, | 1083 glUniform2f(info->vertex_source_mult_handle, width / 2.f * m_x / source_width, |
| 1055 height / 2.f * m_y / source_height * sign_a); | 1084 height / 2.f * m_y / source_height * sign_a); |
| 1056 glUniform2f(info->vertex_source_add_handle, | 1085 glUniform2f(info->vertex_source_add_handle, |
| 1057 (x + width / 2.f) * m_x / source_width, | 1086 (x + width / 2.f) * m_x / source_width, |
| 1058 (y + height / 2.f) * m_y / source_height); | 1087 (y + height / 2.f) * m_y / source_height); |
| 1059 | 1088 |
| 1060 if (BindFramebufferTexture2D(dest_target, dest_id, framebuffer_)) { | 1089 DCHECK(dest_level == 0 || decoder->GetFeatureInfo()->IsES3Capable()); |
| 1090 if (BindFramebufferTexture2D(dest_target, dest_id, dest_level, | |
| 1091 framebuffer_)) { | |
| 1061 #ifndef NDEBUG | 1092 #ifndef NDEBUG |
| 1062 // glValidateProgram of MACOSX validates FBO unlike other platforms, so | 1093 // glValidateProgram of MACOSX validates FBO unlike other platforms, so |
| 1063 // glValidateProgram must be called after FBO binding. crbug.com/463439 | 1094 // glValidateProgram must be called after FBO binding. crbug.com/463439 |
| 1064 glValidateProgram(info->program); | 1095 glValidateProgram(info->program); |
| 1065 GLint validation_status; | 1096 GLint validation_status; |
| 1066 glGetProgramiv(info->program, GL_VALIDATE_STATUS, &validation_status); | 1097 glGetProgramiv(info->program, GL_VALIDATE_STATUS, &validation_status); |
| 1067 if (GL_TRUE != validation_status) { | 1098 if (GL_TRUE != validation_status) { |
| 1068 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader."; | 1099 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader."; |
| 1069 return; | 1100 return; |
| 1070 } | 1101 } |
| 1071 #endif | 1102 #endif |
| 1072 | 1103 |
| 1073 glUniform1i(info->sampler_handle, 0); | 1104 glUniform1i(info->sampler_handle, 0); |
| 1074 | 1105 |
| 1075 glBindTexture(source_target, source_id); | 1106 glBindTexture(source_target, source_id); |
| 1107 DCHECK(source_level == 0 || decoder->GetFeatureInfo()->IsES3Capable()); | |
| 1108 if (source_level > 0) | |
| 1109 glTexParameteri(source_target, GL_TEXTURE_BASE_LEVEL, source_level); | |
| 1076 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 1110 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 1077 glTexParameterf(source_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 1111 glTexParameterf(source_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 1078 glTexParameteri(source_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 1112 glTexParameteri(source_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1079 glTexParameteri(source_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 1113 glTexParameteri(source_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1080 | 1114 |
| 1081 glDisable(GL_DEPTH_TEST); | 1115 glDisable(GL_DEPTH_TEST); |
| 1082 glDisable(GL_STENCIL_TEST); | 1116 glDisable(GL_STENCIL_TEST); |
| 1083 glDisable(GL_CULL_FACE); | 1117 glDisable(GL_CULL_FACE); |
| 1084 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 1118 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 1085 glDepthMask(GL_FALSE); | 1119 glDepthMask(GL_FALSE); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1103 decoder->RestoreTextureUnitBindings(0); | 1137 decoder->RestoreTextureUnitBindings(0); |
| 1104 decoder->RestoreActiveTexture(); | 1138 decoder->RestoreActiveTexture(); |
| 1105 decoder->RestoreProgramBindings(); | 1139 decoder->RestoreProgramBindings(); |
| 1106 decoder->RestoreBufferBindings(); | 1140 decoder->RestoreBufferBindings(); |
| 1107 decoder->RestoreFramebufferBindings(); | 1141 decoder->RestoreFramebufferBindings(); |
| 1108 decoder->RestoreGlobalState(); | 1142 decoder->RestoreGlobalState(); |
| 1109 } | 1143 } |
| 1110 | 1144 |
| 1111 } // namespace gles2 | 1145 } // namespace gles2 |
| 1112 } // namespace gpu | 1146 } // namespace gpu |
| OLD | NEW |