Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1304103005: Revert of gpu: support GL_TEXTURE_CUBE_MAP destination target to Copy(Sub)TextureCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12504 matching lines...) Expand 10 before | Expand all | Expand 10 after
12515 const char* function_name, 12515 const char* function_name,
12516 GLenum target, 12516 GLenum target,
12517 TextureRef* source_texture_ref, 12517 TextureRef* source_texture_ref,
12518 TextureRef* dest_texture_ref, 12518 TextureRef* dest_texture_ref,
12519 GLenum dest_internal_format) { 12519 GLenum dest_internal_format) {
12520 if (!source_texture_ref || !dest_texture_ref) { 12520 if (!source_texture_ref || !dest_texture_ref) {
12521 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); 12521 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
12522 return false; 12522 return false;
12523 } 12523 }
12524 12524
12525 if (GL_TEXTURE_2D != target) {
12526 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
12527 "invalid texture target");
12528 return false;
12529 }
12530
12525 Texture* source_texture = source_texture_ref->texture(); 12531 Texture* source_texture = source_texture_ref->texture();
12526 Texture* dest_texture = dest_texture_ref->texture(); 12532 Texture* dest_texture = dest_texture_ref->texture();
12527 if (source_texture == dest_texture) { 12533 if (source_texture == dest_texture) {
12528 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 12534 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
12529 "source and destination textures are the same"); 12535 "source and destination textures are the same");
12530 return false; 12536 return false;
12531 } 12537 }
12532 12538
12533 GLenum binding_target = GLES2Util::GLTextureTargetToBindingTarget(target); 12539 if (dest_texture->target() != GL_TEXTURE_2D ||
12534 if (dest_texture->target() != binding_target || 12540 (source_texture->target() != GL_TEXTURE_2D &&
12535 (GL_TEXTURE_2D != binding_target && 12541 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
12536 GL_TEXTURE_CUBE_MAP != binding_target)) { 12542 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
12537 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
12538 "invalid texture target");
12539 return false;
12540 }
12541
12542 if (source_texture->target() != GL_TEXTURE_2D &&
12543 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
12544 source_texture->target() != GL_TEXTURE_EXTERNAL_OES) {
12545 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, 12543 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
12546 "invalid texture target binding"); 12544 "invalid texture target binding");
12547 return false; 12545 return false;
12548 } 12546 }
12549 12547
12550 GLenum source_type = 0; 12548 GLenum source_type = 0;
12551 GLenum source_internal_format = 0; 12549 GLenum source_internal_format = 0;
12552 source_texture->GetLevelType(source_texture->target(), 0, &source_type, 12550 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
12553 &source_internal_format); 12551 &source_internal_format);
12554 12552
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
12707 copy_texture_CHROMIUM_->Initialize(this); 12705 copy_texture_CHROMIUM_->Initialize(this);
12708 RestoreCurrentFramebufferBindings(); 12706 RestoreCurrentFramebufferBindings();
12709 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 12707 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
12710 return; 12708 return;
12711 } 12709 }
12712 12710
12713 GLenum dest_type_previous = dest_type; 12711 GLenum dest_type_previous = dest_type;
12714 GLenum dest_internal_format = internal_format; 12712 GLenum dest_internal_format = internal_format;
12715 int dest_width = 0; 12713 int dest_width = 0;
12716 int dest_height = 0; 12714 int dest_height = 0;
12717 bool dest_level_defined = 12715 bool dest_level_defined = dest_texture->GetLevelSize(
12718 dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr); 12716 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr);
12719 12717
12720 if (dest_level_defined) { 12718 if (dest_level_defined) {
12721 dest_texture->GetLevelType(target, 0, &dest_type_previous, 12719 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous,
12722 &dest_internal_format); 12720 &dest_internal_format);
12723 } 12721 }
12724 12722
12725 // Resize the destination texture to the dimensions of the source texture. 12723 // Resize the destination texture to the dimensions of the source texture.
12726 if (!dest_level_defined || dest_width != source_width || 12724 if (!dest_level_defined || dest_width != source_width ||
12727 dest_height != source_height || 12725 dest_height != source_height ||
12728 dest_internal_format != internal_format || 12726 dest_internal_format != internal_format ||
12729 dest_type_previous != dest_type) { 12727 dest_type_previous != dest_type) {
12730 // Ensure that the glTexImage2D succeeds. 12728 // Ensure that the glTexImage2D succeeds.
12731 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 12729 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
12732 glBindTexture(dest_texture->target(), dest_texture->service_id()); 12730 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
12733 glTexImage2D(target, 0, internal_format, source_width, source_height, 0, 12731 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height,
12734 internal_format, dest_type, NULL); 12732 0, internal_format, dest_type, NULL);
12735 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); 12733 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM");
12736 if (error != GL_NO_ERROR) { 12734 if (error != GL_NO_ERROR) {
12737 RestoreCurrentTextureBindings(&state_, dest_texture->target()); 12735 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D);
12738 return; 12736 return;
12739 } 12737 }
12740 12738
12741 texture_manager()->SetLevelInfo( 12739 texture_manager()->SetLevelInfo(
12742 dest_texture_ref, target, 0, internal_format, source_width, 12740 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width,
12743 source_height, 1, 0, internal_format, dest_type, 12741 source_height, 1, 0, internal_format, dest_type,
12744 gfx::Rect(source_width, source_height)); 12742 gfx::Rect(source_width, source_height));
12745 } else { 12743 } else {
12746 texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true); 12744 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
12745 true);
12747 } 12746 }
12748 12747
12749 ScopedModifyPixels modify(dest_texture_ref); 12748 ScopedModifyPixels modify(dest_texture_ref);
12750 12749
12751 // Try using GLImage::CopyTexSubImage when possible. 12750 // Try using GLImage::CopyTexSubImage when possible.
12752 bool unpack_premultiply_alpha_change = 12751 bool unpack_premultiply_alpha_change =
12753 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 12752 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
12754 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 12753 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
12755 glBindTexture(dest_texture->target(), dest_texture->service_id()); 12754 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
12756 if (image->CopyTexSubImage(target, gfx::Point(0, 0), 12755 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(0, 0),
12757 gfx::Rect(0, 0, source_width, source_height))) { 12756 gfx::Rect(0, 0, source_width, source_height))) {
12758 return; 12757 return;
12759 } 12758 }
12760 } 12759 }
12761 12760
12762 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); 12761 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
12763 12762
12764 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 12763 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
12765 // before presenting. 12764 // before presenting.
12766 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 12765 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
12767 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 12766 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
12768 // instead of using kIdentityMatrix crbug.com/226218. 12767 // instead of using kIdentityMatrix crbug.com/226218.
12769 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 12768 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
12770 this, source_texture->target(), source_texture->service_id(), target, 12769 this, source_texture->target(), source_texture->service_id(),
12771 dest_texture->service_id(), internal_format, dest_type, source_width, 12770 dest_texture->service_id(), source_width, source_height,
12772 source_height, unpack_flip_y == GL_TRUE, 12771 unpack_flip_y == GL_TRUE,
12773 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, 12772 unpack_premultiply_alpha == GL_TRUE,
12774 &texture_state_, kIdentityMatrix); 12773 unpack_unmultiply_alpha == GL_TRUE,
12774 kIdentityMatrix);
12775 } else { 12775 } else {
12776 copy_texture_CHROMIUM_->DoCopyTexture( 12776 copy_texture_CHROMIUM_->DoCopyTexture(
12777 this, source_texture->target(), source_texture->service_id(), 12777 this, source_texture->target(), source_texture->service_id(),
12778 source_internal_format, target, dest_texture->service_id(), 12778 source_internal_format, dest_texture->service_id(), internal_format,
12779 internal_format, dest_type, source_width, source_height, 12779 source_width, source_height,
12780 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 12780 unpack_flip_y == GL_TRUE,
12781 unpack_unmultiply_alpha == GL_TRUE, &texture_state_); 12781 unpack_premultiply_alpha == GL_TRUE,
12782 unpack_unmultiply_alpha == GL_TRUE);
12782 } 12783 }
12783 12784
12784 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 12785 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
12785 } 12786 }
12786 12787
12787 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 12788 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
12788 GLenum target, 12789 GLenum target,
12789 GLuint source_id, 12790 GLuint source_id,
12790 GLuint dest_id, 12791 GLuint dest_id,
12791 GLint xoffset, 12792 GLint xoffset,
12792 GLint yoffset, 12793 GLint yoffset,
12793 GLint x, 12794 GLint x,
12794 GLint y, 12795 GLint y,
12795 GLsizei width, 12796 GLsizei width,
12796 GLsizei height, 12797 GLsizei height,
12797 GLboolean unpack_flip_y, 12798 GLboolean unpack_flip_y,
12798 GLboolean unpack_premultiply_alpha, 12799 GLboolean unpack_premultiply_alpha,
12799 GLboolean unpack_unmultiply_alpha) { 12800 GLboolean unpack_unmultiply_alpha) {
12800 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); 12801 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM");
12801 12802
12802 TextureRef* source_texture_ref = GetTexture(source_id); 12803 TextureRef* source_texture_ref = GetTexture(source_id);
12803 TextureRef* dest_texture_ref = GetTexture(dest_id); 12804 TextureRef* dest_texture_ref = GetTexture(dest_id);
12804 Texture* source_texture = source_texture_ref->texture(); 12805 Texture* source_texture = source_texture_ref->texture();
12805 Texture* dest_texture = dest_texture_ref->texture(); 12806 Texture* dest_texture = dest_texture_ref->texture();
12806 GLenum source_type = 0;
12807 GLenum source_internal_format = 0;
12808 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
12809 &source_internal_format);
12810 int source_width = 0; 12807 int source_width = 0;
12811 int source_height = 0; 12808 int source_height = 0;
12812 gfx::GLImage* image = 12809 gfx::GLImage* image =
12813 source_texture->GetLevelImage(source_texture->target(), 0); 12810 source_texture->GetLevelImage(source_texture->target(), 0);
12814 if (image) { 12811 if (image) {
12815 gfx::Size size = image->GetSize(); 12812 gfx::Size size = image->GetSize();
12816 source_width = size.width(); 12813 source_width = size.width();
12817 source_height = size.height(); 12814 source_height = size.height();
12818 if (source_width <= 0 || source_height <= 0) { 12815 if (source_width <= 0 || source_height <= 0) {
12819 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 12816 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
12820 "invalid image size"); 12817 "invalid image size");
12821 return; 12818 return;
12822 } 12819 }
12823 } else { 12820 } else {
12824 if (!source_texture->GetLevelSize(source_texture->target(), 0, 12821 if (!source_texture->GetLevelSize(source_texture->target(), 0,
12825 &source_width, &source_height, nullptr)) { 12822 &source_width, &source_height, nullptr)) {
12826 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 12823 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
12827 "source texture has no level 0"); 12824 "source texture has no level 0");
12828 return; 12825 return;
12829 } 12826 }
12830 12827
12831 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0,
12832 width, height, 1, source_type)) {
12833 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
12834 "source texture bad dimensions.");
12835 return;
12836 }
12837
12838 // Check that this type of texture is allowed. 12828 // Check that this type of texture is allowed.
12839 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, 12829 if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
12840 source_width, source_height, 1)) { 12830 source_width, source_height, 1)) {
12841 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 12831 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
12842 "source texture bad dimensions"); 12832 "source texture bad dimensions");
12843 return; 12833 return;
12844 } 12834 }
12845 } 12835 }
12846 12836
12837 GLenum source_type = 0;
12838 GLenum source_internal_format = 0;
12839 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
12840 &source_internal_format);
12841 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0,
12842 width, height, 1, source_type)) {
12843 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
12844 "source texture bad dimensions.");
12845 return;
12846 }
12847
12847 GLenum dest_type = 0; 12848 GLenum dest_type = 0;
12848 GLenum dest_internal_format = 0; 12849 GLenum dest_internal_format = 0;
12849 bool dest_level_defined = 12850 bool dest_level_defined = dest_texture->GetLevelType(
12850 dest_texture->GetLevelType(target, 0, &dest_type, &dest_internal_format); 12851 dest_texture->target(), 0, &dest_type, &dest_internal_format);
12851 if (!dest_level_defined) { 12852 if (!dest_level_defined) {
12852 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", 12853 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM",
12853 "destination texture is not defined"); 12854 "destination texture is not defined");
12854 return; 12855 return;
12855 } 12856 }
12856 if (!dest_texture->ValidForTexture(target, 0, xoffset, yoffset, 0, width, 12857 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset,
12857 height, 1, dest_type)) { 12858 yoffset, 0, width, height, 1, dest_type)) {
12858 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 12859 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
12859 "destination texture bad dimensions."); 12860 "destination texture bad dimensions.");
12860 return; 12861 return;
12861 } 12862 }
12862 12863
12863 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, 12864 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target,
12864 source_texture_ref, dest_texture_ref, 12865 source_texture_ref, dest_texture_ref,
12865 dest_internal_format)) { 12866 dest_internal_format)) {
12866 return; 12867 return;
12867 } 12868 }
(...skipping 12 matching lines...) Expand all
12880 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM"); 12881 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM");
12881 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 12882 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
12882 copy_texture_CHROMIUM_->Initialize(this); 12883 copy_texture_CHROMIUM_->Initialize(this);
12883 RestoreCurrentFramebufferBindings(); 12884 RestoreCurrentFramebufferBindings();
12884 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) 12885 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR)
12885 return; 12886 return;
12886 } 12887 }
12887 12888
12888 int dest_width = 0; 12889 int dest_width = 0;
12889 int dest_height = 0; 12890 int dest_height = 0;
12890 bool ok = 12891 bool ok = dest_texture->GetLevelSize(
12891 dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr); 12892 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr);
12892 DCHECK(ok); 12893 DCHECK(ok);
12893 if (xoffset != 0 || yoffset != 0 || width != dest_width || 12894 if (xoffset != 0 || yoffset != 0 || width != dest_width ||
12894 height != dest_height) { 12895 height != dest_height) {
12895 gfx::Rect cleared_rect; 12896 gfx::Rect cleared_rect;
12896 if (CombineAdjacentRects(dest_texture->GetLevelClearedRect(target, 0), 12897 if (CombineAdjacentRects(dest_texture->GetLevelClearedRect(target, 0),
12897 gfx::Rect(xoffset, yoffset, width, height), 12898 gfx::Rect(xoffset, yoffset, width, height),
12898 &cleared_rect)) { 12899 &cleared_rect)) {
12899 DCHECK_GE(cleared_rect.size().GetArea(), 12900 DCHECK_GE(cleared_rect.size().GetArea(),
12900 dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); 12901 dest_texture->GetLevelClearedRect(target, 0).size().GetArea());
12901 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, 12902 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0,
12902 cleared_rect); 12903 cleared_rect);
12903 } else { 12904 } else {
12904 // Otherwise clear part of texture level that is not already cleared. 12905 // Otherwise clear part of texture level that is not already cleared.
12905 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, 12906 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target,
12906 0)) { 12907 0)) {
12907 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", 12908 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
12908 "destination texture dimensions too big"); 12909 "destination texture dimensions too big");
12909 return; 12910 return;
12910 } 12911 }
12911 } 12912 }
12912 } else { 12913 } else {
12913 texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true); 12914 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
12915 true);
12914 } 12916 }
12915 12917
12916 ScopedModifyPixels modify(dest_texture_ref); 12918 ScopedModifyPixels modify(dest_texture_ref);
12917 12919
12918 // Try using GLImage::CopyTexSubImage when possible. 12920 // Try using GLImage::CopyTexSubImage when possible.
12919 bool unpack_premultiply_alpha_change = 12921 bool unpack_premultiply_alpha_change =
12920 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 12922 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
12921 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 12923 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
12922 glBindTexture(dest_texture->target(), dest_texture->service_id()); 12924 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
12923 if (image->CopyTexSubImage(target, gfx::Point(xoffset, yoffset), 12925 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset),
12924 gfx::Rect(x, y, width, height))) { 12926 gfx::Rect(x, y, width, height))) {
12925 return; 12927 return;
12926 } 12928 }
12927 } 12929 }
12928 12930
12929 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); 12931 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
12930 12932
12931 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 12933 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
12932 // crbug.com/226218. 12934 // crbug.com/226218.
12933 copy_texture_CHROMIUM_->DoCopySubTexture( 12935 copy_texture_CHROMIUM_->DoCopySubTexture(
12934 this, source_texture->target(), source_texture->service_id(), 12936 this, source_texture->target(), source_texture->service_id(),
12935 source_internal_format, target, dest_texture->service_id(), 12937 source_internal_format, dest_texture->service_id(), dest_internal_format,
12936 dest_internal_format, dest_type, xoffset, yoffset, x, y, width, height, 12938 xoffset, yoffset, x, y, width, height, dest_width, dest_height,
12937 dest_width, dest_height, source_width, source_height, 12939 source_width, source_height,
12938 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 12940 unpack_flip_y == GL_TRUE,
12939 unpack_unmultiply_alpha == GL_TRUE, &texture_state_); 12941 unpack_premultiply_alpha == GL_TRUE,
12942 unpack_unmultiply_alpha == GL_TRUE);
12940 12943
12941 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 12944 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
12942 } 12945 }
12943 12946
12944 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, 12947 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
12945 GLuint source_id, 12948 GLuint source_id,
12946 GLuint dest_id) { 12949 GLuint dest_id) {
12947 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); 12950 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM");
12948 12951
12949 TextureRef* source_texture_ref = GetTexture(source_id); 12952 TextureRef* source_texture_ref = GetTexture(source_id);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
13098 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 13101 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
13099 gfx::Rect(source_width, source_height)); 13102 gfx::Rect(source_width, source_height));
13100 13103
13101 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13104 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
13102 // before presenting. 13105 // before presenting.
13103 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 13106 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
13104 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 13107 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13105 // instead of using kIdentityMatrix crbug.com/226218. 13108 // instead of using kIdentityMatrix crbug.com/226218.
13106 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 13109 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13107 this, source_texture->target(), source_texture->service_id(), 13110 this, source_texture->target(), source_texture->service_id(),
13108 GL_TEXTURE_2D, dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE, 13111 dest_texture->service_id(), source_width, source_height,
13109 source_width, source_height, false, false, false, &texture_state_, 13112 false, false, false, kIdentityMatrix);
13110 kIdentityMatrix);
13111 } else { 13113 } else {
13112 copy_texture_CHROMIUM_->DoCopyTexture( 13114 copy_texture_CHROMIUM_->DoCopyTexture(
13113 this, source_texture->target(), source_texture->service_id(), 13115 this, source_texture->target(), source_texture->service_id(),
13114 source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(), 13116 source_internal_format, dest_texture->service_id(), GL_RGBA,
13115 GL_RGBA, GL_UNSIGNED_BYTE, source_width, source_height, false, false, 13117 source_width, source_height, false, false, false);
13116 false, &texture_state_);
13117 } 13118 }
13118 13119
13119 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 13120 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
13120 } 13121 }
13121 13122
13122 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, 13123 void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
13123 GLuint source_id, 13124 GLuint source_id,
13124 GLuint dest_id, 13125 GLuint dest_id,
13125 GLint xoffset, 13126 GLint xoffset,
13126 GLint yoffset, 13127 GLint yoffset,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
13294 13295
13295 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); 13296 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
13296 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, 13297 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA,
13297 GL_UNSIGNED_BYTE, NULL); 13298 GL_UNSIGNED_BYTE, NULL);
13298 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); 13299 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM");
13299 if (error != GL_NO_ERROR) 13300 if (error != GL_NO_ERROR)
13300 return; 13301 return;
13301 13302
13302 copy_texture_CHROMIUM_->DoCopyTexture( 13303 copy_texture_CHROMIUM_->DoCopyTexture(
13303 this, dest_texture->target(), dest_texture->service_id(), 13304 this, dest_texture->target(), dest_texture->service_id(),
13304 dest_internal_format, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, 13305 dest_internal_format, tmp_service_id, GL_RGBA,
13305 GL_UNSIGNED_BYTE, dest_width, dest_height, false, false, false, 13306 dest_width, dest_height, false, false, false);
13306 &texture_state_);
13307 13307
13308 // Redefine destination texture to use RGBA. 13308 // Redefine destination texture to use RGBA.
13309 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 13309 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
13310 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); 13310 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM");
13311 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA, 13311 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 0, GL_RGBA,
13312 GL_UNSIGNED_BYTE, NULL); 13312 GL_UNSIGNED_BYTE, NULL);
13313 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM"); 13313 error = LOCAL_PEEK_GL_ERROR("glCompressedCopySubTextureCHROMIUM");
13314 if (error != GL_NO_ERROR) 13314 if (error != GL_NO_ERROR)
13315 return; 13315 return;
13316 13316
13317 texture_manager()->SetLevelInfo( 13317 texture_manager()->SetLevelInfo(
13318 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height, 13318 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, dest_width, dest_height,
13319 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height)); 13319 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height));
13320 13320
13321 copy_texture_CHROMIUM_->DoCopyTexture( 13321 copy_texture_CHROMIUM_->DoCopyTexture(
13322 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, GL_TEXTURE_2D, 13322 this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA,
13323 dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE, dest_width, 13323 dest_texture->service_id(), GL_RGBA,
13324 dest_height, false, false, false, &texture_state_); 13324 dest_width, dest_height, false, false, false);
13325 13325
13326 glDeleteTextures(1, &tmp_service_id); 13326 glDeleteTextures(1, &tmp_service_id);
13327 } 13327 }
13328 13328
13329 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 13329 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
13330 // crbug.com/226218. 13330 // crbug.com/226218.
13331 copy_texture_CHROMIUM_->DoCopySubTexture( 13331 copy_texture_CHROMIUM_->DoCopySubTexture(
13332 this, source_texture->target(), source_texture->service_id(), 13332 this, source_texture->target(), source_texture->service_id(),
13333 source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(), 13333 source_internal_format, dest_texture->service_id(), GL_RGBA,
13334 GL_RGBA, GL_UNSIGNED_BYTE, xoffset, yoffset, x, y, width, height, 13334 xoffset, yoffset, x, y, width, height, dest_width, dest_height,
13335 dest_width, dest_height, source_width, source_height, false, false, false, 13335 source_width, source_height, false, false, false);
13336 &texture_state_);
13337 13336
13338 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 13337 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
13339 } 13338 }
13340 13339
13341 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 13340 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
13342 switch (internalformat) { 13341 switch (internalformat) {
13343 case GL_R8: 13342 case GL_R8:
13344 return GL_UNSIGNED_BYTE; 13343 return GL_UNSIGNED_BYTE;
13345 case GL_R8_SNORM: 13344 case GL_R8_SNORM:
13346 return GL_BYTE; 13345 return GL_BYTE;
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
14782 return error::kNoError; 14781 return error::kNoError;
14783 } 14782 }
14784 14783
14785 // Include the auto-generated part of this file. We split this because it means 14784 // Include the auto-generated part of this file. We split this because it means
14786 // we can easily edit the non-auto generated parts right here in this file 14785 // we can easily edit the non-auto generated parts right here in this file
14787 // instead of having to edit some template or the code generator. 14786 // instead of having to edit some template or the code generator.
14788 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 14787 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
14789 14788
14790 } // namespace gles2 14789 } // namespace gles2
14791 } // namespace gpu 14790 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698