| 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 12522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12533 const char* function_name, | 12533 const char* function_name, |
| 12534 GLenum target, | 12534 GLenum target, |
| 12535 TextureRef* source_texture_ref, | 12535 TextureRef* source_texture_ref, |
| 12536 TextureRef* dest_texture_ref, | 12536 TextureRef* dest_texture_ref, |
| 12537 GLenum dest_internal_format) { | 12537 GLenum dest_internal_format) { |
| 12538 if (!source_texture_ref || !dest_texture_ref) { | 12538 if (!source_texture_ref || !dest_texture_ref) { |
| 12539 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); | 12539 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); |
| 12540 return false; | 12540 return false; |
| 12541 } | 12541 } |
| 12542 | 12542 |
| 12543 if (GL_TEXTURE_2D != target) { | |
| 12544 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | |
| 12545 "invalid texture target"); | |
| 12546 return false; | |
| 12547 } | |
| 12548 | |
| 12549 Texture* source_texture = source_texture_ref->texture(); | 12543 Texture* source_texture = source_texture_ref->texture(); |
| 12550 Texture* dest_texture = dest_texture_ref->texture(); | 12544 Texture* dest_texture = dest_texture_ref->texture(); |
| 12551 if (source_texture == dest_texture) { | 12545 if (source_texture == dest_texture) { |
| 12552 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 12546 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 12553 "source and destination textures are the same"); | 12547 "source and destination textures are the same"); |
| 12554 return false; | 12548 return false; |
| 12555 } | 12549 } |
| 12556 | 12550 |
| 12557 if (dest_texture->target() != GL_TEXTURE_2D || | 12551 GLenum binding_target = GLES2Util::GLTextureTargetToBindingTarget(target); |
| 12558 (source_texture->target() != GL_TEXTURE_2D && | 12552 if (dest_texture->target() != binding_target || |
| 12559 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && | 12553 (GL_TEXTURE_2D != binding_target && |
| 12560 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { | 12554 GL_TEXTURE_CUBE_MAP != binding_target)) { |
| 12555 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 12556 "invalid texture target"); |
| 12557 return false; |
| 12558 } |
| 12559 |
| 12560 if (source_texture->target() != GL_TEXTURE_2D && |
| 12561 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && |
| 12562 source_texture->target() != GL_TEXTURE_EXTERNAL_OES) { |
| 12561 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 12563 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 12562 "invalid texture target binding"); | 12564 "invalid texture target binding"); |
| 12563 return false; | 12565 return false; |
| 12564 } | 12566 } |
| 12565 | 12567 |
| 12566 GLenum source_type = 0; | 12568 GLenum source_type = 0; |
| 12567 GLenum source_internal_format = 0; | 12569 GLenum source_internal_format = 0; |
| 12568 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | 12570 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
| 12569 &source_internal_format); | 12571 &source_internal_format); |
| 12570 | 12572 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12722 copy_texture_CHROMIUM_->Initialize(this); | 12724 copy_texture_CHROMIUM_->Initialize(this); |
| 12723 RestoreCurrentFramebufferBindings(); | 12725 RestoreCurrentFramebufferBindings(); |
| 12724 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) | 12726 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) |
| 12725 return; | 12727 return; |
| 12726 } | 12728 } |
| 12727 | 12729 |
| 12728 GLenum dest_type_previous = dest_type; | 12730 GLenum dest_type_previous = dest_type; |
| 12729 GLenum dest_internal_format = internal_format; | 12731 GLenum dest_internal_format = internal_format; |
| 12730 int dest_width = 0; | 12732 int dest_width = 0; |
| 12731 int dest_height = 0; | 12733 int dest_height = 0; |
| 12732 bool dest_level_defined = dest_texture->GetLevelSize( | 12734 bool dest_level_defined = |
| 12733 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); | 12735 dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr); |
| 12734 | 12736 |
| 12735 if (dest_level_defined) { | 12737 if (dest_level_defined) { |
| 12736 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous, | 12738 dest_texture->GetLevelType(target, 0, &dest_type_previous, |
| 12737 &dest_internal_format); | 12739 &dest_internal_format); |
| 12738 } | 12740 } |
| 12739 | 12741 |
| 12740 // Resize the destination texture to the dimensions of the source texture. | 12742 // Resize the destination texture to the dimensions of the source texture. |
| 12741 if (!dest_level_defined || dest_width != source_width || | 12743 if (!dest_level_defined || dest_width != source_width || |
| 12742 dest_height != source_height || | 12744 dest_height != source_height || |
| 12743 dest_internal_format != internal_format || | 12745 dest_internal_format != internal_format || |
| 12744 dest_type_previous != dest_type) { | 12746 dest_type_previous != dest_type) { |
| 12745 // Ensure that the glTexImage2D succeeds. | 12747 // Ensure that the glTexImage2D succeeds. |
| 12746 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | 12748 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
| 12747 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 12749 glBindTexture(dest_texture->target(), dest_texture->service_id()); |
| 12748 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height, | 12750 glTexImage2D(target, 0, internal_format, source_width, source_height, 0, |
| 12749 0, internal_format, dest_type, NULL); | 12751 internal_format, dest_type, NULL); |
| 12750 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); | 12752 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); |
| 12751 if (error != GL_NO_ERROR) { | 12753 if (error != GL_NO_ERROR) { |
| 12752 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); | 12754 RestoreCurrentTextureBindings(&state_, dest_texture->target()); |
| 12753 return; | 12755 return; |
| 12754 } | 12756 } |
| 12755 | 12757 |
| 12756 texture_manager()->SetLevelInfo( | 12758 texture_manager()->SetLevelInfo( |
| 12757 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, | 12759 dest_texture_ref, target, 0, internal_format, source_width, |
| 12758 source_height, 1, 0, internal_format, dest_type, | 12760 source_height, 1, 0, internal_format, dest_type, |
| 12759 gfx::Rect(source_width, source_height)); | 12761 gfx::Rect(source_width, source_height)); |
| 12760 } else { | 12762 } else { |
| 12761 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, | 12763 texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true); |
| 12762 true); | |
| 12763 } | 12764 } |
| 12764 | 12765 |
| 12765 ScopedModifyPixels modify(dest_texture_ref); | 12766 ScopedModifyPixels modify(dest_texture_ref); |
| 12766 | 12767 |
| 12767 // Try using GLImage::CopyTexSubImage when possible. | 12768 // Try using GLImage::CopyTexSubImage when possible. |
| 12768 bool unpack_premultiply_alpha_change = | 12769 bool unpack_premultiply_alpha_change = |
| 12769 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 12770 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| 12770 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 12771 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
| 12771 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 12772 glBindTexture(dest_texture->target(), dest_texture->service_id()); |
| 12772 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(0, 0), | 12773 if (image->CopyTexSubImage(target, gfx::Point(0, 0), |
| 12773 gfx::Rect(0, 0, source_width, source_height))) { | 12774 gfx::Rect(0, 0, source_width, source_height))) { |
| 12774 return; | 12775 return; |
| 12775 } | 12776 } |
| 12776 } | 12777 } |
| 12777 | 12778 |
| 12778 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); | 12779 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 12779 | 12780 |
| 12780 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 12781 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 12781 // before presenting. | 12782 // before presenting. |
| 12782 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 12783 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
| 12783 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 12784 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
| 12784 // instead of using kIdentityMatrix crbug.com/226218. | 12785 // instead of using kIdentityMatrix crbug.com/226218. |
| 12785 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 12786 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 12786 this, source_texture->target(), source_texture->service_id(), | 12787 this, source_texture->target(), source_texture->service_id(), target, |
| 12787 dest_texture->service_id(), source_width, source_height, | 12788 dest_texture->service_id(), internal_format, dest_type, source_width, |
| 12788 unpack_flip_y == GL_TRUE, | 12789 source_height, unpack_flip_y == GL_TRUE, |
| 12789 unpack_premultiply_alpha == GL_TRUE, | 12790 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, |
| 12790 unpack_unmultiply_alpha == GL_TRUE, | 12791 &texture_state_, kIdentityMatrix); |
| 12791 kIdentityMatrix); | |
| 12792 } else { | 12792 } else { |
| 12793 copy_texture_CHROMIUM_->DoCopyTexture( | 12793 copy_texture_CHROMIUM_->DoCopyTexture( |
| 12794 this, source_texture->target(), source_texture->service_id(), | 12794 this, source_texture->target(), source_texture->service_id(), |
| 12795 source_internal_format, dest_texture->service_id(), internal_format, | 12795 source_internal_format, target, dest_texture->service_id(), |
| 12796 source_width, source_height, | 12796 internal_format, dest_type, source_width, source_height, |
| 12797 unpack_flip_y == GL_TRUE, | 12797 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
| 12798 unpack_premultiply_alpha == GL_TRUE, | 12798 unpack_unmultiply_alpha == GL_TRUE, &texture_state_); |
| 12799 unpack_unmultiply_alpha == GL_TRUE); | |
| 12800 } | 12799 } |
| 12801 | 12800 |
| 12802 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 12801 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 12803 } | 12802 } |
| 12804 | 12803 |
| 12805 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( | 12804 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| 12806 GLenum target, | 12805 GLenum target, |
| 12807 GLuint source_id, | 12806 GLuint source_id, |
| 12808 GLuint dest_id, | 12807 GLuint dest_id, |
| 12809 GLint xoffset, | 12808 GLint xoffset, |
| 12810 GLint yoffset, | 12809 GLint yoffset, |
| 12811 GLint x, | 12810 GLint x, |
| 12812 GLint y, | 12811 GLint y, |
| 12813 GLsizei width, | 12812 GLsizei width, |
| 12814 GLsizei height, | 12813 GLsizei height, |
| 12815 GLboolean unpack_flip_y, | 12814 GLboolean unpack_flip_y, |
| 12816 GLboolean unpack_premultiply_alpha, | 12815 GLboolean unpack_premultiply_alpha, |
| 12817 GLboolean unpack_unmultiply_alpha) { | 12816 GLboolean unpack_unmultiply_alpha) { |
| 12818 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); | 12817 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); |
| 12819 | 12818 |
| 12820 TextureRef* source_texture_ref = GetTexture(source_id); | 12819 TextureRef* source_texture_ref = GetTexture(source_id); |
| 12821 TextureRef* dest_texture_ref = GetTexture(dest_id); | 12820 TextureRef* dest_texture_ref = GetTexture(dest_id); |
| 12822 Texture* source_texture = source_texture_ref->texture(); | 12821 Texture* source_texture = source_texture_ref->texture(); |
| 12823 Texture* dest_texture = dest_texture_ref->texture(); | 12822 Texture* dest_texture = dest_texture_ref->texture(); |
| 12823 GLenum source_type = 0; |
| 12824 GLenum source_internal_format = 0; |
| 12825 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
| 12826 &source_internal_format); |
| 12824 int source_width = 0; | 12827 int source_width = 0; |
| 12825 int source_height = 0; | 12828 int source_height = 0; |
| 12826 gfx::GLImage* image = | 12829 gfx::GLImage* image = |
| 12827 source_texture->GetLevelImage(source_texture->target(), 0); | 12830 source_texture->GetLevelImage(source_texture->target(), 0); |
| 12828 if (image) { | 12831 if (image) { |
| 12829 gfx::Size size = image->GetSize(); | 12832 gfx::Size size = image->GetSize(); |
| 12830 source_width = size.width(); | 12833 source_width = size.width(); |
| 12831 source_height = size.height(); | 12834 source_height = size.height(); |
| 12832 if (source_width <= 0 || source_height <= 0) { | 12835 if (source_width <= 0 || source_height <= 0) { |
| 12833 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12836 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12834 "invalid image size"); | 12837 "invalid image size"); |
| 12835 return; | 12838 return; |
| 12836 } | 12839 } |
| 12837 } else { | 12840 } else { |
| 12838 if (!source_texture->GetLevelSize(source_texture->target(), 0, | 12841 if (!source_texture->GetLevelSize(source_texture->target(), 0, |
| 12839 &source_width, &source_height, nullptr)) { | 12842 &source_width, &source_height, nullptr)) { |
| 12840 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12843 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12841 "source texture has no level 0"); | 12844 "source texture has no level 0"); |
| 12842 return; | 12845 return; |
| 12843 } | 12846 } |
| 12844 | 12847 |
| 12848 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, |
| 12849 width, height, 1, source_type)) { |
| 12850 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12851 "source texture bad dimensions."); |
| 12852 return; |
| 12853 } |
| 12854 |
| 12845 // Check that this type of texture is allowed. | 12855 // Check that this type of texture is allowed. |
| 12846 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, | 12856 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
| 12847 source_width, source_height, 1)) { | 12857 source_width, source_height, 1)) { |
| 12848 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12858 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12849 "source texture bad dimensions"); | 12859 "source texture bad dimensions"); |
| 12850 return; | 12860 return; |
| 12851 } | 12861 } |
| 12852 } | 12862 } |
| 12853 | 12863 |
| 12854 GLenum source_type = 0; | |
| 12855 GLenum source_internal_format = 0; | |
| 12856 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | |
| 12857 &source_internal_format); | |
| 12858 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, | |
| 12859 width, height, 1, source_type)) { | |
| 12860 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | |
| 12861 "source texture bad dimensions."); | |
| 12862 return; | |
| 12863 } | |
| 12864 | |
| 12865 GLenum dest_type = 0; | 12864 GLenum dest_type = 0; |
| 12866 GLenum dest_internal_format = 0; | 12865 GLenum dest_internal_format = 0; |
| 12867 bool dest_level_defined = dest_texture->GetLevelType( | 12866 bool dest_level_defined = |
| 12868 dest_texture->target(), 0, &dest_type, &dest_internal_format); | 12867 dest_texture->GetLevelType(target, 0, &dest_type, &dest_internal_format); |
| 12869 if (!dest_level_defined) { | 12868 if (!dest_level_defined) { |
| 12870 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", | 12869 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", |
| 12871 "destination texture is not defined"); | 12870 "destination texture is not defined"); |
| 12872 return; | 12871 return; |
| 12873 } | 12872 } |
| 12874 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, | 12873 if (!dest_texture->ValidForTexture(target, 0, xoffset, yoffset, 0, width, |
| 12875 yoffset, 0, width, height, 1, dest_type)) { | 12874 height, 1, dest_type)) { |
| 12876 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 12875 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| 12877 "destination texture bad dimensions."); | 12876 "destination texture bad dimensions."); |
| 12878 return; | 12877 return; |
| 12879 } | 12878 } |
| 12880 | 12879 |
| 12881 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, | 12880 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, |
| 12882 source_texture_ref, dest_texture_ref, | 12881 source_texture_ref, dest_texture_ref, |
| 12883 dest_internal_format)) { | 12882 dest_internal_format)) { |
| 12884 return; | 12883 return; |
| 12885 } | 12884 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 12898 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM"); | 12897 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM"); |
| 12899 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 12898 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
| 12900 copy_texture_CHROMIUM_->Initialize(this); | 12899 copy_texture_CHROMIUM_->Initialize(this); |
| 12901 RestoreCurrentFramebufferBindings(); | 12900 RestoreCurrentFramebufferBindings(); |
| 12902 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) | 12901 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) |
| 12903 return; | 12902 return; |
| 12904 } | 12903 } |
| 12905 | 12904 |
| 12906 int dest_width = 0; | 12905 int dest_width = 0; |
| 12907 int dest_height = 0; | 12906 int dest_height = 0; |
| 12908 bool ok = dest_texture->GetLevelSize( | 12907 bool ok = |
| 12909 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); | 12908 dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr); |
| 12910 DCHECK(ok); | 12909 DCHECK(ok); |
| 12911 if (xoffset != 0 || yoffset != 0 || width != dest_width || | 12910 if (xoffset != 0 || yoffset != 0 || width != dest_width || |
| 12912 height != dest_height) { | 12911 height != dest_height) { |
| 12913 gfx::Rect cleared_rect; | 12912 gfx::Rect cleared_rect; |
| 12914 if (CombineAdjacentRects(dest_texture->GetLevelClearedRect(target, 0), | 12913 if (CombineAdjacentRects(dest_texture->GetLevelClearedRect(target, 0), |
| 12915 gfx::Rect(xoffset, yoffset, width, height), | 12914 gfx::Rect(xoffset, yoffset, width, height), |
| 12916 &cleared_rect)) { | 12915 &cleared_rect)) { |
| 12917 DCHECK_GE(cleared_rect.size().GetArea(), | 12916 DCHECK_GE(cleared_rect.size().GetArea(), |
| 12918 dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); | 12917 dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); |
| 12919 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, | 12918 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, |
| 12920 cleared_rect); | 12919 cleared_rect); |
| 12921 } else { | 12920 } else { |
| 12922 // Otherwise clear part of texture level that is not already cleared. | 12921 // Otherwise clear part of texture level that is not already cleared. |
| 12923 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, | 12922 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, |
| 12924 0)) { | 12923 0)) { |
| 12925 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", | 12924 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", |
| 12926 "destination texture dimensions too big"); | 12925 "destination texture dimensions too big"); |
| 12927 return; | 12926 return; |
| 12928 } | 12927 } |
| 12929 } | 12928 } |
| 12930 } else { | 12929 } else { |
| 12931 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, | 12930 texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true); |
| 12932 true); | |
| 12933 } | 12931 } |
| 12934 | 12932 |
| 12935 ScopedModifyPixels modify(dest_texture_ref); | 12933 ScopedModifyPixels modify(dest_texture_ref); |
| 12936 | 12934 |
| 12937 // Try using GLImage::CopyTexSubImage when possible. | 12935 // Try using GLImage::CopyTexSubImage when possible. |
| 12938 bool unpack_premultiply_alpha_change = | 12936 bool unpack_premultiply_alpha_change = |
| 12939 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 12937 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| 12940 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 12938 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
| 12941 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 12939 glBindTexture(dest_texture->target(), dest_texture->service_id()); |
| 12942 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), | 12940 if (image->CopyTexSubImage(target, gfx::Point(xoffset, yoffset), |
| 12943 gfx::Rect(x, y, width, height))) { | 12941 gfx::Rect(x, y, width, height))) { |
| 12944 return; | 12942 return; |
| 12945 } | 12943 } |
| 12946 } | 12944 } |
| 12947 | 12945 |
| 12948 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); | 12946 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 12949 | 12947 |
| 12950 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. | 12948 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. |
| 12951 // crbug.com/226218. | 12949 // crbug.com/226218. |
| 12952 copy_texture_CHROMIUM_->DoCopySubTexture( | 12950 copy_texture_CHROMIUM_->DoCopySubTexture( |
| 12953 this, source_texture->target(), source_texture->service_id(), | 12951 this, source_texture->target(), source_texture->service_id(), |
| 12954 source_internal_format, dest_texture->service_id(), dest_internal_format, | 12952 source_internal_format, target, dest_texture->service_id(), |
| 12955 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 12953 dest_internal_format, dest_type, xoffset, yoffset, x, y, width, height, |
| 12956 source_width, source_height, | 12954 dest_width, dest_height, source_width, source_height, |
| 12957 unpack_flip_y == GL_TRUE, | 12955 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
| 12958 unpack_premultiply_alpha == GL_TRUE, | 12956 unpack_unmultiply_alpha == GL_TRUE, &texture_state_); |
| 12959 unpack_unmultiply_alpha == GL_TRUE); | |
| 12960 | 12957 |
| 12961 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 12958 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 12962 } | 12959 } |
| 12963 | 12960 |
| 12964 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, | 12961 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, |
| 12965 GLuint source_id, | 12962 GLuint source_id, |
| 12966 GLuint dest_id) { | 12963 GLuint dest_id) { |
| 12967 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); | 12964 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); |
| 12968 | 12965 |
| 12969 TextureRef* source_texture_ref = GetTexture(source_id); | 12966 TextureRef* source_texture_ref = GetTexture(source_id); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13118 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 13115 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 13119 gfx::Rect(source_width, source_height)); | 13116 gfx::Rect(source_width, source_height)); |
| 13120 | 13117 |
| 13121 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 13118 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 13122 // before presenting. | 13119 // before presenting. |
| 13123 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | 13120 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
| 13124 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 13121 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
| 13125 // instead of using kIdentityMatrix crbug.com/226218. | 13122 // instead of using kIdentityMatrix crbug.com/226218. |
| 13126 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 13123 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 13127 this, source_texture->target(), source_texture->service_id(), | 13124 this, source_texture->target(), source_texture->service_id(), |
| 13128 dest_texture->service_id(), source_width, source_height, | 13125 GL_TEXTURE_2D, dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE, |
| 13129 false, false, false, kIdentityMatrix); | 13126 source_width, source_height, false, false, false, &texture_state_, |
| 13127 kIdentityMatrix); |
| 13130 } else { | 13128 } else { |
| 13131 copy_texture_CHROMIUM_->DoCopyTexture( | 13129 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13132 this, source_texture->target(), source_texture->service_id(), | 13130 this, source_texture->target(), source_texture->service_id(), |
| 13133 source_internal_format, dest_texture->service_id(), GL_RGBA, | 13131 source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(), |
| 13134 source_width, source_height, false, false, false); | 13132 GL_RGBA, GL_UNSIGNED_BYTE, source_width, source_height, false, false, |
| 13133 false, &texture_state_); |
| 13135 } | 13134 } |
| 13136 | 13135 |
| 13137 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 13136 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 13138 } | 13137 } |
| 13139 | 13138 |
| 13140 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, | 13139 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, |
| 13141 GLuint source_id, | 13140 GLuint source_id, |
| 13142 GLuint dest_id, | 13141 GLuint dest_id, |
| 13143 GLint xoffset, | 13142 GLint xoffset, |
| 13144 GLint yoffset, | 13143 GLint yoffset, |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13312 | 13311 |
| 13313 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | 13312 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); |
| 13314 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, | 13313 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, |
| 13315 GL_UNSIGNED_BYTE, NULL); | 13314 GL_UNSIGNED_BYTE, NULL); |
| 13316 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); | 13315 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); |
| 13317 if (error != GL_NO_ERROR) | 13316 if (error != GL_NO_ERROR) |
| 13318 return; | 13317 return; |
| 13319 | 13318 |
| 13320 copy_texture_CHROMIUM_->DoCopyTexture( | 13319 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13321 this, dest_texture->target(), dest_texture->service_id(), | 13320 this, dest_texture->target(), dest_texture->service_id(), |
| 13322 dest_internal_format, tmp_service_id, GL_RGBA, | 13321 dest_internal_format, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, |
| 13323 dest_width, dest_height, false, false, false); | 13322 GL_UNSIGNED_BYTE, dest_width, dest_height, false, false, false, |
| 13323 &texture_state_); |
| 13324 | 13324 |
| 13325 // Redefine destination texture to use RGBA. | 13325 // Redefine destination texture to use RGBA. |
| 13326 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); | 13326 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| 13327 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | 13327 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); |
| 13328 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, | 13328 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, |
| 13329 GL_UNSIGNED_BYTE, NULL); | 13329 GL_UNSIGNED_BYTE, NULL); |
| 13330 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); | 13330 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); |
| 13331 if (error != GL_NO_ERROR) | 13331 if (error != GL_NO_ERROR) |
| 13332 return; | 13332 return; |
| 13333 | 13333 |
| 13334 texture_manager()->SetLevelInfo( | 13334 texture_manager()->SetLevelInfo( |
| 13335 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, | 13335 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, |
| 13336 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); | 13336 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); |
| 13337 | 13337 |
| 13338 copy_texture_CHROMIUM_->DoCopyTexture( | 13338 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13339 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, | 13339 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, GL_TEXTURE_2D, |
| 13340 dest_texture->service_id(), GL_RGBA, | 13340 dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE, dest_width, |
| 13341 dest_width, dest_height, false, false, false); | 13341 dest_height, false, false, false, &texture_state_); |
| 13342 | 13342 |
| 13343 glDeleteTextures(1, &tmp_service_id); | 13343 glDeleteTextures(1, &tmp_service_id); |
| 13344 } | 13344 } |
| 13345 | 13345 |
| 13346 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. | 13346 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. |
| 13347 // crbug.com/226218. | 13347 // crbug.com/226218. |
| 13348 copy_texture_CHROMIUM_->DoCopySubTexture( | 13348 copy_texture_CHROMIUM_->DoCopySubTexture( |
| 13349 this, source_texture->target(), source_texture->service_id(), | 13349 this, source_texture->target(), source_texture->service_id(), |
| 13350 source_internal_format, dest_texture->service_id(), GL_RGBA, | 13350 source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(), |
| 13351 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 13351 GL_RGBA, GL_UNSIGNED_BYTE, xoffset, yoffset, x, y, width, height, |
| 13352 source_width, source_height, false, false, false); | 13352 dest_width, dest_height, source_width, source_height, false, false, false, |
| 13353 &texture_state_); |
| 13353 | 13354 |
| 13354 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 13355 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
| 13355 } | 13356 } |
| 13356 | 13357 |
| 13357 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 13358 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
| 13358 switch (internalformat) { | 13359 switch (internalformat) { |
| 13359 case GL_R8: | 13360 case GL_R8: |
| 13360 return GL_UNSIGNED_BYTE; | 13361 return GL_UNSIGNED_BYTE; |
| 13361 case GL_R8_SNORM: | 13362 case GL_R8_SNORM: |
| 13362 return GL_BYTE; | 13363 return GL_BYTE; |
| (...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14798 return error::kNoError; | 14799 return error::kNoError; |
| 14799 } | 14800 } |
| 14800 | 14801 |
| 14801 // Include the auto-generated part of this file. We split this because it means | 14802 // Include the auto-generated part of this file. We split this because it means |
| 14802 // we can easily edit the non-auto generated parts right here in this file | 14803 // we can easily edit the non-auto generated parts right here in this file |
| 14803 // instead of having to edit some template or the code generator. | 14804 // instead of having to edit some template or the code generator. |
| 14804 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 14805 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 14805 | 14806 |
| 14806 } // namespace gles2 | 14807 } // namespace gles2 |
| 14807 } // namespace gpu | 14808 } // namespace gpu |
| OLD | NEW |