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_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 12482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12493 const char* function_name, | 12493 const char* function_name, |
12494 GLenum target, | 12494 GLenum target, |
12495 TextureRef* source_texture_ref, | 12495 TextureRef* source_texture_ref, |
12496 TextureRef* dest_texture_ref, | 12496 TextureRef* dest_texture_ref, |
12497 GLenum dest_internal_format) { | 12497 GLenum dest_internal_format) { |
12498 if (!source_texture_ref || !dest_texture_ref) { | 12498 if (!source_texture_ref || !dest_texture_ref) { |
12499 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); | 12499 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); |
12500 return false; | 12500 return false; |
12501 } | 12501 } |
12502 | 12502 |
12503 if (GL_TEXTURE_2D != target) { | |
12504 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | |
12505 "invalid texture target"); | |
12506 return false; | |
12507 } | |
12508 | |
12509 Texture* source_texture = source_texture_ref->texture(); | 12503 Texture* source_texture = source_texture_ref->texture(); |
12510 Texture* dest_texture = dest_texture_ref->texture(); | 12504 Texture* dest_texture = dest_texture_ref->texture(); |
12511 if (source_texture == dest_texture) { | 12505 if (source_texture == dest_texture) { |
12512 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 12506 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
12513 "source and destination textures are the same"); | 12507 "source and destination textures are the same"); |
12514 return false; | 12508 return false; |
12515 } | 12509 } |
12516 | 12510 |
12517 if (dest_texture->target() != GL_TEXTURE_2D || | 12511 GLenum binding_target = GLES2Util::GLTextureTargetToBindingTarget(target); |
12518 (source_texture->target() != GL_TEXTURE_2D && | 12512 if (dest_texture->target() != binding_target || |
12519 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && | 12513 (GL_TEXTURE_2D != binding_target && |
12520 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { | 12514 GL_TEXTURE_CUBE_MAP != binding_target)) { |
| 12515 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 12516 "invalid texture target"); |
| 12517 return false; |
| 12518 } |
| 12519 |
| 12520 if (source_texture->target() != GL_TEXTURE_2D && |
| 12521 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && |
| 12522 source_texture->target() != GL_TEXTURE_EXTERNAL_OES) { |
12521 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 12523 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
12522 "invalid texture target binding"); | 12524 "invalid texture target binding"); |
12523 return false; | 12525 return false; |
12524 } | 12526 } |
12525 | 12527 |
12526 GLenum source_type = 0; | 12528 GLenum source_type = 0; |
12527 GLenum source_internal_format = 0; | 12529 GLenum source_internal_format = 0; |
12528 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | 12530 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
12529 &source_internal_format); | 12531 &source_internal_format); |
12530 | 12532 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12682 copy_texture_CHROMIUM_->Initialize(this); | 12684 copy_texture_CHROMIUM_->Initialize(this); |
12683 RestoreCurrentFramebufferBindings(); | 12685 RestoreCurrentFramebufferBindings(); |
12684 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) | 12686 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) |
12685 return; | 12687 return; |
12686 } | 12688 } |
12687 | 12689 |
12688 GLenum dest_type_previous = dest_type; | 12690 GLenum dest_type_previous = dest_type; |
12689 GLenum dest_internal_format = internal_format; | 12691 GLenum dest_internal_format = internal_format; |
12690 int dest_width = 0; | 12692 int dest_width = 0; |
12691 int dest_height = 0; | 12693 int dest_height = 0; |
12692 bool dest_level_defined = dest_texture->GetLevelSize( | 12694 bool dest_level_defined = |
12693 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); | 12695 dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr); |
12694 | 12696 |
12695 if (dest_level_defined) { | 12697 if (dest_level_defined) { |
12696 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous, | 12698 dest_texture->GetLevelType(target, 0, &dest_type_previous, |
12697 &dest_internal_format); | 12699 &dest_internal_format); |
12698 } | 12700 } |
12699 | 12701 |
12700 // Resize the destination texture to the dimensions of the source texture. | 12702 // Resize the destination texture to the dimensions of the source texture. |
12701 if (!dest_level_defined || dest_width != source_width || | 12703 if (!dest_level_defined || dest_width != source_width || |
12702 dest_height != source_height || | 12704 dest_height != source_height || |
12703 dest_internal_format != internal_format || | 12705 dest_internal_format != internal_format || |
12704 dest_type_previous != dest_type) { | 12706 dest_type_previous != dest_type) { |
12705 // Ensure that the glTexImage2D succeeds. | 12707 // Ensure that the glTexImage2D succeeds. |
12706 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 12708 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
12707 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 12709 glBindTexture(dest_texture->target(), dest_texture->service_id()); |
12708 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height, | 12710 glTexImage2D(target, 0, internal_format, source_width, source_height, 0, |
12709 0, internal_format, dest_type, NULL); | 12711 internal_format, dest_type, NULL); |
12710 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); | 12712 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); |
12711 if (error != GL_NO_ERROR) { | 12713 if (error != GL_NO_ERROR) { |
12712 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); | 12714 RestoreCurrentTextureBindings(&state_, dest_texture->target()); |
12713 return; | 12715 return; |
12714 } | 12716 } |
12715 | 12717 |
12716 texture_manager()->SetLevelInfo( | 12718 texture_manager()->SetLevelInfo( |
12717 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, | 12719 dest_texture_ref, target, 0, internal_format, source_width, |
12718 source_height, 1, 0, internal_format, dest_type, | 12720 source_height, 1, 0, internal_format, dest_type, |
12719 gfx::Rect(source_width, source_height)); | 12721 gfx::Rect(source_width, source_height)); |
12720 } else { | 12722 } else { |
12721 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, | 12723 texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true); |
12722 true); | |
12723 } | 12724 } |
12724 | 12725 |
12725 ScopedModifyPixels modify(dest_texture_ref); | 12726 ScopedModifyPixels modify(dest_texture_ref); |
12726 | 12727 |
12727 // Try using GLImage::CopyTexSubImage when possible. | 12728 // Try using GLImage::CopyTexSubImage when possible. |
12728 bool unpack_premultiply_alpha_change = | 12729 bool unpack_premultiply_alpha_change = |
12729 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 12730 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
12730 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 12731 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
12731 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 12732 glBindTexture(dest_texture->target(), dest_texture->service_id()); |
12732 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(0, 0), | 12733 if (image->CopyTexSubImage(target, gfx::Point(0, 0), |
12733 gfx::Rect(0, 0, source_width, source_height))) { | 12734 gfx::Rect(0, 0, source_width, source_height))) { |
12734 return; | 12735 return; |
12735 } | 12736 } |
12736 } | 12737 } |
12737 | 12738 |
12738 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); | 12739 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); |
12739 | 12740 |
12740 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 12741 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
12741 // before presenting. | 12742 // before presenting. |
12742 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 12743 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
12743 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 12744 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
12744 // instead of using kIdentityMatrix crbug.com/226218. | 12745 // instead of using kIdentityMatrix crbug.com/226218. |
12745 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 12746 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
12746 this, source_texture->target(), source_texture->service_id(), | 12747 this, source_texture->target(), source_texture->service_id(), target, |
12747 dest_texture->service_id(), source_width, source_height, | 12748 dest_texture->service_id(), internal_format, dest_type, source_width, |
12748 unpack_flip_y == GL_TRUE, | 12749 source_height, unpack_flip_y == GL_TRUE, |
12749 unpack_premultiply_alpha == GL_TRUE, | 12750 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, |
12750 unpack_unmultiply_alpha == GL_TRUE, | 12751 &texture_state_, kIdentityMatrix); |
12751 kIdentityMatrix); | |
12752 } else { | 12752 } else { |
12753 copy_texture_CHROMIUM_->DoCopyTexture( | 12753 copy_texture_CHROMIUM_->DoCopyTexture( |
12754 this, source_texture->target(), source_texture->service_id(), | 12754 this, source_texture->target(), source_texture->service_id(), |
12755 source_internal_format, dest_texture->service_id(), internal_format, | 12755 source_internal_format, target, dest_texture->service_id(), |
12756 source_width, source_height, | 12756 internal_format, dest_type, source_width, source_height, |
12757 unpack_flip_y == GL_TRUE, | 12757 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
12758 unpack_premultiply_alpha == GL_TRUE, | 12758 unpack_unmultiply_alpha == GL_TRUE, &texture_state_); |
12759 unpack_unmultiply_alpha == GL_TRUE); | |
12760 } | 12759 } |
12761 | 12760 |
12762 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 12761 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
12763 } | 12762 } |
12764 | 12763 |
12765 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( | 12764 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
12766 GLenum target, | 12765 GLenum target, |
12767 GLuint source_id, | 12766 GLuint source_id, |
12768 GLuint dest_id, | 12767 GLuint dest_id, |
12769 GLint xoffset, | 12768 GLint xoffset, |
12770 GLint yoffset, | 12769 GLint yoffset, |
12771 GLint x, | 12770 GLint x, |
12772 GLint y, | 12771 GLint y, |
12773 GLsizei width, | 12772 GLsizei width, |
12774 GLsizei height, | 12773 GLsizei height, |
12775 GLboolean unpack_flip_y, | 12774 GLboolean unpack_flip_y, |
12776 GLboolean unpack_premultiply_alpha, | 12775 GLboolean unpack_premultiply_alpha, |
12777 GLboolean unpack_unmultiply_alpha) { | 12776 GLboolean unpack_unmultiply_alpha) { |
12778 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); | 12777 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); |
12779 | 12778 |
12780 TextureRef* source_texture_ref = GetTexture(source_id); | 12779 TextureRef* source_texture_ref = GetTexture(source_id); |
12781 TextureRef* dest_texture_ref = GetTexture(dest_id); | 12780 TextureRef* dest_texture_ref = GetTexture(dest_id); |
12782 Texture* source_texture = source_texture_ref->texture(); | 12781 Texture* source_texture = source_texture_ref->texture(); |
12783 Texture* dest_texture = dest_texture_ref->texture(); | 12782 Texture* dest_texture = dest_texture_ref->texture(); |
| 12783 GLenum source_type = 0; |
| 12784 GLenum source_internal_format = 0; |
| 12785 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
| 12786 &source_internal_format); |
12784 int source_width = 0; | 12787 int source_width = 0; |
12785 int source_height = 0; | 12788 int source_height = 0; |
12786 gfx::GLImage* image = | 12789 gfx::GLImage* image = |
12787 source_texture->GetLevelImage(source_texture->target(), 0); | 12790 source_texture->GetLevelImage(source_texture->target(), 0); |
12788 if (image) { | 12791 if (image) { |
12789 gfx::Size size = image->GetSize(); | 12792 gfx::Size size = image->GetSize(); |
12790 source_width = size.width(); | 12793 source_width = size.width(); |
12791 source_height = size.height(); | 12794 source_height = size.height(); |
12792 if (source_width <= 0 || source_height <= 0) { | 12795 if (source_width <= 0 || source_height <= 0) { |
12793 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12796 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
12794 "invalid image size"); | 12797 "invalid image size"); |
12795 return; | 12798 return; |
12796 } | 12799 } |
12797 } else { | 12800 } else { |
12798 if (!source_texture->GetLevelSize(source_texture->target(), 0, | 12801 if (!source_texture->GetLevelSize(source_texture->target(), 0, |
12799 &source_width, &source_height, nullptr)) { | 12802 &source_width, &source_height, nullptr)) { |
12800 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12803 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
12801 "source texture has no level 0"); | 12804 "source texture has no level 0"); |
12802 return; | 12805 return; |
12803 } | 12806 } |
12804 | 12807 |
| 12808 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, |
| 12809 width, height, 1, source_type)) { |
| 12810 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12811 "source texture bad dimensions."); |
| 12812 return; |
| 12813 } |
| 12814 |
12805 // Check that this type of texture is allowed. | 12815 // Check that this type of texture is allowed. |
12806 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, | 12816 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
12807 source_width, source_height, 1)) { | 12817 source_width, source_height, 1)) { |
12808 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12818 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
12809 "source texture bad dimensions"); | 12819 "source texture bad dimensions"); |
12810 return; | 12820 return; |
12811 } | 12821 } |
12812 } | 12822 } |
12813 | 12823 |
12814 GLenum source_type = 0; | |
12815 GLenum source_internal_format = 0; | |
12816 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | |
12817 &source_internal_format); | |
12818 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, | |
12819 width, height, 1, source_type)) { | |
12820 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | |
12821 "source texture bad dimensions."); | |
12822 return; | |
12823 } | |
12824 | |
12825 GLenum dest_type = 0; | 12824 GLenum dest_type = 0; |
12826 GLenum dest_internal_format = 0; | 12825 GLenum dest_internal_format = 0; |
12827 bool dest_level_defined = dest_texture->GetLevelType( | 12826 bool dest_level_defined = |
12828 dest_texture->target(), 0, &dest_type, &dest_internal_format); | 12827 dest_texture->GetLevelType(target, 0, &dest_type, &dest_internal_format); |
12829 if (!dest_level_defined) { | 12828 if (!dest_level_defined) { |
12830 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", | 12829 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", |
12831 "destination texture is not defined"); | 12830 "destination texture is not defined"); |
12832 return; | 12831 return; |
12833 } | 12832 } |
12834 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, | 12833 if (!dest_texture->ValidForTexture(target, 0, xoffset, yoffset, 0, width, |
12835 yoffset, 0, width, height, 1, dest_type)) { | 12834 height, 1, dest_type)) { |
12836 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12835 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
12837 "destination texture bad dimensions."); | 12836 "destination texture bad dimensions."); |
12838 return; | 12837 return; |
12839 } | 12838 } |
12840 | 12839 |
12841 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, | 12840 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, |
12842 source_texture_ref, dest_texture_ref, | 12841 source_texture_ref, dest_texture_ref, |
12843 dest_internal_format)) { | 12842 dest_internal_format)) { |
12844 return; | 12843 return; |
12845 } | 12844 } |
(...skipping 12 matching lines...) Expand all Loading... |
12858 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM"); | 12857 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM"); |
12859 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 12858 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
12860 copy_texture_CHROMIUM_->Initialize(this); | 12859 copy_texture_CHROMIUM_->Initialize(this); |
12861 RestoreCurrentFramebufferBindings(); | 12860 RestoreCurrentFramebufferBindings(); |
12862 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) | 12861 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) |
12863 return; | 12862 return; |
12864 } | 12863 } |
12865 | 12864 |
12866 int dest_width = 0; | 12865 int dest_width = 0; |
12867 int dest_height = 0; | 12866 int dest_height = 0; |
12868 bool ok = dest_texture->GetLevelSize( | 12867 bool ok = |
12869 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); | 12868 dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr); |
12870 DCHECK(ok); | 12869 DCHECK(ok); |
12871 if (xoffset != 0 || yoffset != 0 || width != dest_width || | 12870 if (xoffset != 0 || yoffset != 0 || width != dest_width || |
12872 height != dest_height) { | 12871 height != dest_height) { |
12873 gfx::Rect cleared_rect; | 12872 gfx::Rect cleared_rect; |
12874 if (CombineAdjacentRects(dest_texture->GetLevelClearedRect(target, 0), | 12873 if (CombineAdjacentRects(dest_texture->GetLevelClearedRect(target, 0), |
12875 gfx::Rect(xoffset, yoffset, width, height), | 12874 gfx::Rect(xoffset, yoffset, width, height), |
12876 &cleared_rect)) { | 12875 &cleared_rect)) { |
12877 DCHECK_GE(cleared_rect.size().GetArea(), | 12876 DCHECK_GE(cleared_rect.size().GetArea(), |
12878 dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); | 12877 dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); |
12879 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, | 12878 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, |
12880 cleared_rect); | 12879 cleared_rect); |
12881 } else { | 12880 } else { |
12882 // Otherwise clear part of texture level that is not already cleared. | 12881 // Otherwise clear part of texture level that is not already cleared. |
12883 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, | 12882 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, |
12884 0)) { | 12883 0)) { |
12885 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", | 12884 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", |
12886 "destination texture dimensions too big"); | 12885 "destination texture dimensions too big"); |
12887 return; | 12886 return; |
12888 } | 12887 } |
12889 } | 12888 } |
12890 } else { | 12889 } else { |
12891 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, | 12890 texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true); |
12892 true); | |
12893 } | 12891 } |
12894 | 12892 |
12895 ScopedModifyPixels modify(dest_texture_ref); | 12893 ScopedModifyPixels modify(dest_texture_ref); |
12896 | 12894 |
12897 // Try using GLImage::CopyTexSubImage when possible. | 12895 // Try using GLImage::CopyTexSubImage when possible. |
12898 bool unpack_premultiply_alpha_change = | 12896 bool unpack_premultiply_alpha_change = |
12899 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 12897 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
12900 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 12898 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
12901 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 12899 glBindTexture(dest_texture->target(), dest_texture->service_id()); |
12902 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), | 12900 if (image->CopyTexSubImage(target, gfx::Point(xoffset, yoffset), |
12903 gfx::Rect(x, y, width, height))) { | 12901 gfx::Rect(x, y, width, height))) { |
12904 return; | 12902 return; |
12905 } | 12903 } |
12906 } | 12904 } |
12907 | 12905 |
12908 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); | 12906 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); |
12909 | 12907 |
12910 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. | 12908 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. |
12911 // crbug.com/226218. | 12909 // crbug.com/226218. |
12912 copy_texture_CHROMIUM_->DoCopySubTexture( | 12910 copy_texture_CHROMIUM_->DoCopySubTexture( |
12913 this, source_texture->target(), source_texture->service_id(), | 12911 this, source_texture->target(), source_texture->service_id(), |
12914 source_internal_format, dest_texture->service_id(), dest_internal_format, | 12912 source_internal_format, target, dest_texture->service_id(), |
12915 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 12913 dest_internal_format, dest_type, xoffset, yoffset, x, y, width, height, |
12916 source_width, source_height, | 12914 dest_width, dest_height, source_width, source_height, |
12917 unpack_flip_y == GL_TRUE, | 12915 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
12918 unpack_premultiply_alpha == GL_TRUE, | 12916 unpack_unmultiply_alpha == GL_TRUE, &texture_state_); |
12919 unpack_unmultiply_alpha == GL_TRUE); | |
12920 | 12917 |
12921 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 12918 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
12922 } | 12919 } |
12923 | 12920 |
12924 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, | 12921 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, |
12925 GLuint source_id, | 12922 GLuint source_id, |
12926 GLuint dest_id) { | 12923 GLuint dest_id) { |
12927 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); | 12924 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); |
12928 | 12925 |
12929 TextureRef* source_texture_ref = GetTexture(source_id); | 12926 TextureRef* source_texture_ref = GetTexture(source_id); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13078 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 13075 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
13079 gfx::Rect(source_width, source_height)); | 13076 gfx::Rect(source_width, source_height)); |
13080 | 13077 |
13081 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 13078 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
13082 // before presenting. | 13079 // before presenting. |
13083 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 13080 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
13084 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 13081 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
13085 // instead of using kIdentityMatrix crbug.com/226218. | 13082 // instead of using kIdentityMatrix crbug.com/226218. |
13086 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 13083 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
13087 this, source_texture->target(), source_texture->service_id(), | 13084 this, source_texture->target(), source_texture->service_id(), |
13088 dest_texture->service_id(), source_width, source_height, | 13085 GL_TEXTURE_2D, dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE, |
13089 false, false, false, kIdentityMatrix); | 13086 source_width, source_height, false, false, false, &texture_state_, |
| 13087 kIdentityMatrix); |
13090 } else { | 13088 } else { |
13091 copy_texture_CHROMIUM_->DoCopyTexture( | 13089 copy_texture_CHROMIUM_->DoCopyTexture( |
13092 this, source_texture->target(), source_texture->service_id(), | 13090 this, source_texture->target(), source_texture->service_id(), |
13093 source_internal_format, dest_texture->service_id(), GL_RGBA, | 13091 source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(), |
13094 source_width, source_height, false, false, false); | 13092 GL_RGBA, GL_UNSIGNED_BYTE, source_width, source_height, false, false, |
| 13093 false, &texture_state_); |
13095 } | 13094 } |
13096 | 13095 |
13097 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 13096 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
13098 } | 13097 } |
13099 | 13098 |
13100 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, | 13099 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, |
13101 GLuint source_id, | 13100 GLuint source_id, |
13102 GLuint dest_id, | 13101 GLuint dest_id, |
13103 GLint xoffset, | 13102 GLint xoffset, |
13104 GLint yoffset, | 13103 GLint yoffset, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13272 | 13271 |
13273 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | 13272 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); |
13274 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, | 13273 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, |
13275 GL_UNSIGNED_BYTE, NULL); | 13274 GL_UNSIGNED_BYTE, NULL); |
13276 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); | 13275 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); |
13277 if (error != GL_NO_ERROR) | 13276 if (error != GL_NO_ERROR) |
13278 return; | 13277 return; |
13279 | 13278 |
13280 copy_texture_CHROMIUM_->DoCopyTexture( | 13279 copy_texture_CHROMIUM_->DoCopyTexture( |
13281 this, dest_texture->target(), dest_texture->service_id(), | 13280 this, dest_texture->target(), dest_texture->service_id(), |
13282 dest_internal_format, tmp_service_id, GL_RGBA, | 13281 dest_internal_format, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, |
13283 dest_width, dest_height, false, false, false); | 13282 GL_UNSIGNED_BYTE, dest_width, dest_height, false, false, false, |
| 13283 &texture_state_); |
13284 | 13284 |
13285 // Redefine destination texture to use RGBA. | 13285 // Redefine destination texture to use RGBA. |
13286 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 13286 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
13287 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | 13287 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); |
13288 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, | 13288 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, |
13289 GL_UNSIGNED_BYTE, NULL); | 13289 GL_UNSIGNED_BYTE, NULL); |
13290 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); | 13290 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); |
13291 if (error != GL_NO_ERROR) | 13291 if (error != GL_NO_ERROR) |
13292 return; | 13292 return; |
13293 | 13293 |
13294 texture_manager()->SetLevelInfo( | 13294 texture_manager()->SetLevelInfo( |
13295 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, | 13295 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, |
13296 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); | 13296 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); |
13297 | 13297 |
13298 copy_texture_CHROMIUM_->DoCopyTexture( | 13298 copy_texture_CHROMIUM_->DoCopyTexture( |
13299 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, | 13299 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, GL_TEXTURE_2D, |
13300 dest_texture->service_id(), GL_RGBA, | 13300 dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE, dest_width, |
13301 dest_width, dest_height, false, false, false); | 13301 dest_height, false, false, false, &texture_state_); |
13302 | 13302 |
13303 glDeleteTextures(1, &tmp_service_id); | 13303 glDeleteTextures(1, &tmp_service_id); |
13304 } | 13304 } |
13305 | 13305 |
13306 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. | 13306 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. |
13307 // crbug.com/226218. | 13307 // crbug.com/226218. |
13308 copy_texture_CHROMIUM_->DoCopySubTexture( | 13308 copy_texture_CHROMIUM_->DoCopySubTexture( |
13309 this, source_texture->target(), source_texture->service_id(), | 13309 this, source_texture->target(), source_texture->service_id(), |
13310 source_internal_format, dest_texture->service_id(), GL_RGBA, | 13310 source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(), |
13311 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 13311 GL_RGBA, GL_UNSIGNED_BYTE, xoffset, yoffset, x, y, width, height, |
13312 source_width, source_height, false, false, false); | 13312 dest_width, dest_height, source_width, source_height, false, false, false, |
| 13313 &texture_state_); |
13313 | 13314 |
13314 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 13315 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
13315 } | 13316 } |
13316 | 13317 |
13317 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 13318 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
13318 switch (internalformat) { | 13319 switch (internalformat) { |
13319 case GL_R8: | 13320 case GL_R8: |
13320 return GL_UNSIGNED_BYTE; | 13321 return GL_UNSIGNED_BYTE; |
13321 case GL_R8_SNORM: | 13322 case GL_R8_SNORM: |
13322 return GL_BYTE; | 13323 return GL_BYTE; |
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14758 return error::kNoError; | 14759 return error::kNoError; |
14759 } | 14760 } |
14760 | 14761 |
14761 // Include the auto-generated part of this file. We split this because it means | 14762 // Include the auto-generated part of this file. We split this because it means |
14762 // we can easily edit the non-auto generated parts right here in this file | 14763 // we can easily edit the non-auto generated parts right here in this file |
14763 // instead of having to edit some template or the code generator. | 14764 // instead of having to edit some template or the code generator. |
14764 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 14765 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
14765 | 14766 |
14766 } // namespace gles2 | 14767 } // namespace gles2 |
14767 } // namespace gpu | 14768 } // namespace gpu |
OLD | NEW |