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

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

Issue 864513004: gpu: introduce glCopySubTextureCHROMIUM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nits Created 5 years, 11 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 <list> 10 #include <list>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 #if defined(OS_WIN) 75 #if defined(OS_WIN)
76 #include "base/win/win_util.h" 76 #include "base/win/win_util.h"
77 #endif 77 #endif
78 78
79 namespace gpu { 79 namespace gpu {
80 namespace gles2 { 80 namespace gles2 {
81 81
82 namespace { 82 namespace {
83 83
84 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; 84 const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
85 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; 85 const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth";
86 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; 86 const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers";
87 static const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod"; 87 const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod";
88
89 GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
Ken Russell (switch to Gerrit) 2015/01/24 01:33:24 Should be const.
dshwang 2015/02/10 18:11:55 Done.
90 0.0f, 1.0f, 0.0f, 0.0f,
91 0.0f, 0.0f, 1.0f, 0.0f,
92 0.0f, 0.0f, 0.0f, 1.0f};
88 93
89 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, 94 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin,
90 GLint rangeMax, 95 GLint rangeMax,
91 GLint precision) { 96 GLint precision) {
92 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16); 97 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16);
93 } 98 }
94 99
95 static void GetShaderPrecisionFormatImpl(GLenum shader_type, 100 static void GetShaderPrecisionFormatImpl(GLenum shader_type,
96 GLenum precision_type, 101 GLenum precision_type,
97 GLint *range, GLint *precision) { 102 GLint *range, GLint *precision) {
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 const void * data); 934 const void * data);
930 935
931 // Wrapper for TexImageIOSurface2DCHROMIUM. 936 // Wrapper for TexImageIOSurface2DCHROMIUM.
932 void DoTexImageIOSurface2DCHROMIUM( 937 void DoTexImageIOSurface2DCHROMIUM(
933 GLenum target, 938 GLenum target,
934 GLsizei width, 939 GLsizei width,
935 GLsizei height, 940 GLsizei height,
936 GLuint io_surface_id, 941 GLuint io_surface_id,
937 GLuint plane); 942 GLuint plane);
938 943
939 void DoCopyTextureCHROMIUM( 944 void DoCopyTextureCHROMIUM(GLenum target,
940 GLenum target, 945 GLuint source_id,
941 GLuint source_id, 946 GLuint dest_id,
942 GLuint target_id, 947 GLint level,
943 GLint level, 948 GLenum internal_format,
944 GLenum internal_format, 949 GLenum dest_type);
945 GLenum dest_type); 950
951 void DoCopySubTextureCHROMIUM(GLenum target,
952 GLuint source_id,
953 GLuint dest_id,
954 GLint level,
955 GLint xoffset,
956 GLint yoffset);
946 957
947 // Wrapper for TexStorage2DEXT. 958 // Wrapper for TexStorage2DEXT.
948 void DoTexStorage2DEXT( 959 void DoTexStorage2DEXT(
949 GLenum target, 960 GLenum target,
950 GLint levels, 961 GLint levels,
951 GLenum internal_format, 962 GLenum internal_format,
952 GLsizei width, 963 GLsizei width,
953 GLsizei height); 964 GLsizei height);
954 965
955 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 966 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 const char* function_name, 1660 const char* function_name,
1650 GLint level, GLsizei width, GLsizei height, GLenum format); 1661 GLint level, GLsizei width, GLsizei height, GLenum format);
1651 bool ValidateCompressedTexFuncData( 1662 bool ValidateCompressedTexFuncData(
1652 const char* function_name, 1663 const char* function_name,
1653 GLsizei width, GLsizei height, GLenum format, size_t size); 1664 GLsizei width, GLsizei height, GLenum format, size_t size);
1654 bool ValidateCompressedTexSubDimensions( 1665 bool ValidateCompressedTexSubDimensions(
1655 const char* function_name, 1666 const char* function_name,
1656 GLenum target, GLint level, GLint xoffset, GLint yoffset, 1667 GLenum target, GLint level, GLint xoffset, GLint yoffset,
1657 GLsizei width, GLsizei height, GLenum format, 1668 GLsizei width, GLsizei height, GLenum format,
1658 Texture* texture); 1669 Texture* texture);
1670 bool ValidateCopyTextureCHROMIUM(const char* function_name,
1671 GLenum target,
1672 TextureRef* source_texture_ref,
1673 TextureRef* dest_texture_ref,
1674 GLint level,
1675 GLenum dest_internal_format);
1659 1676
1660 void RenderWarning(const char* filename, int line, const std::string& msg); 1677 void RenderWarning(const char* filename, int line, const std::string& msg);
1661 void PerformanceWarning( 1678 void PerformanceWarning(
1662 const char* filename, int line, const std::string& msg); 1679 const char* filename, int line, const std::string& msg);
1663 1680
1664 const FeatureInfo::FeatureFlags& features() const { 1681 const FeatureInfo::FeatureFlags& features() const {
1665 return feature_info_->feature_flags(); 1682 return feature_info_->feature_flags();
1666 } 1683 }
1667 1684
1668 const FeatureInfo::Workarounds& workarounds() const { 1685 const FeatureInfo::Workarounds& workarounds() const {
(...skipping 8839 matching lines...) Expand 10 before | Expand all | Expand 10 after
10508 return GL_LUMINANCE_ALPHA; 10525 return GL_LUMINANCE_ALPHA;
10509 case GL_BGRA8_EXT: 10526 case GL_BGRA8_EXT:
10510 return GL_BGRA_EXT; 10527 return GL_BGRA_EXT;
10511 case GL_SRGB8_ALPHA8_EXT: 10528 case GL_SRGB8_ALPHA8_EXT:
10512 return GL_SRGB_ALPHA_EXT; 10529 return GL_SRGB_ALPHA_EXT;
10513 default: 10530 default:
10514 return GL_NONE; 10531 return GL_NONE;
10515 } 10532 }
10516 } 10533 }
10517 10534
10518 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 10535 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
10519 GLenum target, GLuint source_id, GLuint dest_id, GLint level, 10536 const char* function_name,
10520 GLenum internal_format, GLenum dest_type) { 10537 GLenum target,
10521 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 10538 TextureRef* source_texture_ref,
10522 10539 TextureRef* dest_texture_ref,
10523 TextureRef* dest_texture_ref = GetTexture(dest_id); 10540 GLint level,
10524 TextureRef* source_texture_ref = GetTexture(source_id); 10541 GLenum dest_internal_format) {
10525
10526 if (!source_texture_ref || !dest_texture_ref) { 10542 if (!source_texture_ref || !dest_texture_ref) {
10527 LOCAL_SET_GL_ERROR( 10543 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
10528 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); 10544 return false;
10529 return;
10530 } 10545 }
10531 10546
10532 if (GL_TEXTURE_2D != target) { 10547 if (GL_TEXTURE_2D != target) {
10533 LOCAL_SET_GL_ERROR( 10548 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
10534 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid texture target"); 10549 "invalid texture target");
10535 return; 10550 return false;
10551 }
10552
10553 if (level) {
10554 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "level must be 0");
10555 return false;
10536 } 10556 }
10537 10557
10538 Texture* source_texture = source_texture_ref->texture(); 10558 Texture* source_texture = source_texture_ref->texture();
10539 Texture* dest_texture = dest_texture_ref->texture(); 10559 Texture* dest_texture = dest_texture_ref->texture();
10560 if (source_texture == dest_texture) {
10561 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
10562 "source and destination textures are the same");
10563 return false;
10564 }
10565
10540 if (dest_texture->target() != GL_TEXTURE_2D || 10566 if (dest_texture->target() != GL_TEXTURE_2D ||
10541 (source_texture->target() != GL_TEXTURE_2D && 10567 (source_texture->target() != GL_TEXTURE_2D &&
10542 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && 10568 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
10543 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { 10569 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
10544 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, 10570 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
10545 "glCopyTextureCHROMIUM",
10546 "invalid texture target binding"); 10571 "invalid texture target binding");
10547 return; 10572 return false;
10548 } 10573 }
10549 10574
10550 int source_width, source_height, dest_width, dest_height; 10575 GLenum source_type = 0;
10576 GLenum source_internal_format = 0;
10577 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
10578 &source_internal_format);
10551 10579
10580 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA,
10581 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not
10582 // renderable on some platforms.
10583 bool valid_dest_format = dest_internal_format == GL_RGB ||
10584 dest_internal_format == GL_RGBA ||
10585 dest_internal_format == GL_BGRA_EXT;
10586 bool valid_source_format = source_internal_format == GL_ALPHA ||
10587 source_internal_format == GL_RGB ||
10588 source_internal_format == GL_RGBA ||
10589 source_internal_format == GL_LUMINANCE ||
10590 source_internal_format == GL_LUMINANCE_ALPHA ||
10591 source_internal_format == GL_BGRA_EXT;
10592 if (!valid_source_format || !valid_dest_format) {
10593 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
10594 "invalid internal format");
10595 return false;
10596 }
10597 return true;
10598 }
10599
10600 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target,
10601 GLuint source_id,
10602 GLuint dest_id,
10603 GLint level,
10604 GLenum internal_format,
10605 GLenum dest_type) {
10606 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
10607
10608 TextureRef* source_texture_ref = GetTexture(source_id);
10609 TextureRef* dest_texture_ref = GetTexture(dest_id);
10610 Texture* source_texture = source_texture_ref->texture();
10611 Texture* dest_texture = dest_texture_ref->texture();
10612 int source_width = 0;
10613 int source_height = 0;
10552 gfx::GLImage* image = 10614 gfx::GLImage* image =
10553 source_texture->GetLevelImage(source_texture->target(), 0); 10615 source_texture->GetLevelImage(source_texture->target(), 0);
10554 if (image) { 10616 if (image) {
10555 gfx::Size size = image->GetSize(); 10617 gfx::Size size = image->GetSize();
10556 source_width = size.width(); 10618 source_width = size.width();
10557 source_height = size.height(); 10619 source_height = size.height();
10558 if (source_width <= 0 || source_height <= 0) { 10620 if (source_width <= 0 || source_height <= 0) {
10559 LOCAL_SET_GL_ERROR( 10621 LOCAL_SET_GL_ERROR(
10560 GL_INVALID_VALUE, 10622 GL_INVALID_VALUE,
10561 "glCopyTextureChromium", "invalid image size"); 10623 "glCopyTextureChromium", "invalid image size");
(...skipping 10 matching lines...) Expand all
10572 10634
10573 // Check that this type of texture is allowed. 10635 // Check that this type of texture is allowed.
10574 if (!texture_manager()->ValidForTarget( 10636 if (!texture_manager()->ValidForTarget(
10575 source_texture->target(), level, source_width, source_height, 1)) { 10637 source_texture->target(), level, source_width, source_height, 1)) {
10576 LOCAL_SET_GL_ERROR( 10638 LOCAL_SET_GL_ERROR(
10577 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions"); 10639 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions");
10578 return; 10640 return;
10579 } 10641 }
10580 } 10642 }
10581 10643
10582 // Clear the source texture if necessary.
10583 if (!texture_manager()->ClearTextureLevel(
10584 this, source_texture_ref, source_texture->target(), 0)) {
10585 LOCAL_SET_GL_ERROR(
10586 GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", "dimensions too big");
10587 return;
10588 }
10589
10590 GLenum source_type = 0; 10644 GLenum source_type = 0;
10591 GLenum source_internal_format = 0; 10645 GLenum source_internal_format = 0;
10592 source_texture->GetLevelType( 10646 source_texture->GetLevelType(
10593 source_texture->target(), 0, &source_type, &source_internal_format); 10647 source_texture->target(), 0, &source_type, &source_internal_format);
10594 10648
10595 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, 10649 if (dest_texture->IsImmutable()) {
10596 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not 10650 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM",
10597 // renderable on some platforms. 10651 "texture is immutable");
10598 bool valid_dest_format = internal_format == GL_RGB ||
10599 internal_format == GL_RGBA ||
10600 internal_format == GL_BGRA_EXT;
10601 bool valid_source_format = source_internal_format == GL_ALPHA ||
10602 source_internal_format == GL_RGB ||
10603 source_internal_format == GL_RGBA ||
10604 source_internal_format == GL_LUMINANCE ||
10605 source_internal_format == GL_LUMINANCE_ALPHA ||
10606 source_internal_format == GL_BGRA_EXT;
10607 if (!valid_source_format || !valid_dest_format) {
10608 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
10609 "glCopyTextureCHROMIUM",
10610 "invalid internal format");
10611 return; 10652 return;
10612 } 10653 }
10613 10654
10655 if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", target,
10656 source_texture_ref, dest_texture_ref, level,
10657 internal_format)) {
10658 return;
10659 }
10660
10661 // Clear the source texture if necessary.
10662 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
10663 source_texture->target(), 0)) {
10664 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM",
10665 "dimensions too big");
10666 return;
10667 }
10668
10614 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 10669 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
10615 // needed because it takes 10s of milliseconds to initialize. 10670 // needed because it takes 10s of milliseconds to initialize.
10616 if (!copy_texture_CHROMIUM_.get()) { 10671 if (!copy_texture_CHROMIUM_.get()) {
10617 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 10672 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
10618 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 10673 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
10619 copy_texture_CHROMIUM_->Initialize(this); 10674 copy_texture_CHROMIUM_->Initialize(this);
10620 RestoreCurrentFramebufferBindings(); 10675 RestoreCurrentFramebufferBindings();
10621 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 10676 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
10622 return; 10677 return;
10623 } 10678 }
10624 10679
10625 GLenum dest_type_previous = dest_type; 10680 GLenum dest_type_previous = dest_type;
10626 GLenum dest_internal_format = internal_format; 10681 GLenum dest_internal_format = internal_format;
10682 int dest_width = 0;
10683 int dest_height = 0;
10627 bool dest_level_defined = dest_texture->GetLevelSize( 10684 bool dest_level_defined = dest_texture->GetLevelSize(
10628 GL_TEXTURE_2D, level, &dest_width, &dest_height); 10685 GL_TEXTURE_2D, level, &dest_width, &dest_height);
10629 10686
10630 if (dest_level_defined) { 10687 if (dest_level_defined) {
10631 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, 10688 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous,
10632 &dest_internal_format); 10689 &dest_internal_format);
10633 } 10690 }
10634 10691
10635 // Resize the destination texture to the dimensions of the source texture. 10692 // Resize the destination texture to the dimensions of the source texture.
10636 if (!dest_level_defined || dest_width != source_width || 10693 if (!dest_level_defined || dest_width != source_width ||
(...skipping 30 matching lines...) Expand all
10667 if (image->CopyTexImage(GL_TEXTURE_2D)) 10724 if (image->CopyTexImage(GL_TEXTURE_2D))
10668 return; 10725 return;
10669 } 10726 }
10670 10727
10671 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); 10728 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
10672 10729
10673 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 10730 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
10674 // before presenting. 10731 // before presenting.
10675 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 10732 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
10676 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 10733 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
10677 // instead of using default matrix crbug.com/226218. 10734 // instead of using kIdentityMatrix crbug.com/226218.
10678 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
10679 0.0f, 1.0f, 0.0f, 0.0f,
10680 0.0f, 0.0f, 1.0f, 0.0f,
10681 0.0f, 0.0f, 0.0f, 1.0f};
10682 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 10735 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
10683 this, 10736 this, source_texture->target(), source_texture->service_id(),
10684 source_texture->target(), 10737 dest_texture->service_id(), level, source_width, source_height,
10685 source_texture->service_id(), 10738 unpack_flip_y_, unpack_premultiply_alpha_, unpack_unpremultiply_alpha_,
10686 dest_texture->service_id(), 10739 kIdentityMatrix);
10687 level,
10688 source_width,
10689 source_height,
10690 unpack_flip_y_,
10691 unpack_premultiply_alpha_,
10692 unpack_unpremultiply_alpha_,
10693 default_matrix);
10694 } else { 10740 } else {
10695 copy_texture_CHROMIUM_->DoCopyTexture(this, 10741 copy_texture_CHROMIUM_->DoCopyTexture(
10696 source_texture->target(), 10742 this, source_texture->target(), source_texture->service_id(),
10697 source_texture->service_id(), 10743 source_internal_format, dest_texture->service_id(), level,
10698 source_internal_format, 10744 internal_format, source_width, source_height, unpack_flip_y_,
10699 dest_texture->service_id(), 10745 unpack_premultiply_alpha_, unpack_unpremultiply_alpha_);
10700 level,
10701 internal_format,
10702 source_width,
10703 source_height,
10704 unpack_flip_y_,
10705 unpack_premultiply_alpha_,
10706 unpack_unpremultiply_alpha_);
10707 } 10746 }
10708 10747
10709 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 10748 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
10749 }
10750
10751 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(GLenum target,
10752 GLuint source_id,
10753 GLuint dest_id,
10754 GLint level,
10755 GLint xoffset,
10756 GLint yoffset) {
10757 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM");
10758
10759 TextureRef* source_texture_ref = GetTexture(source_id);
10760 TextureRef* dest_texture_ref = GetTexture(dest_id);
10761 Texture* source_texture = source_texture_ref->texture();
10762 Texture* dest_texture = dest_texture_ref->texture();
10763 int source_width = 0;
10764 int source_height = 0;
10765 gfx::GLImage* image =
10766 source_texture->GetLevelImage(source_texture->target(), 0);
10767 if (image) {
10768 gfx::Size size = image->GetSize();
10769 source_width = size.width();
10770 source_height = size.height();
10771 if (source_width <= 0 || source_height <= 0) {
10772 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
10773 "invalid image size");
10774 return;
10775 }
10776 } else {
10777 if (!source_texture->GetLevelSize(source_texture->target(), 0,
10778 &source_width, &source_height)) {
10779 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
10780 "source texture has no level 0");
10781 return;
10782 }
10783
10784 // Check that this type of texture is allowed.
10785 if (!texture_manager()->ValidForTarget(source_texture->target(), level,
10786 source_width, source_height, 1)) {
10787 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
10788 "source texture bad dimensions");
10789 return;
10790 }
10791 }
10792
10793 GLenum source_type = 0;
10794 GLenum source_internal_format = 0;
10795 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
10796 &source_internal_format);
10797 GLenum dest_type = 0;
10798 GLenum dest_internal_format = 0;
10799 bool dest_level_defined = dest_texture->GetLevelType(
10800 dest_texture->target(), level, &dest_type, &dest_internal_format);
10801 if (!dest_level_defined) {
10802 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM",
10803 "destination texture is not defined");
10804 return;
10805 }
10806 if (!dest_texture->ValidForTexture(dest_texture->target(), level, xoffset,
10807 yoffset, source_width, source_height,
10808 dest_type)) {
10809 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
10810 "destination texture bad dimensions.");
10811 return;
10812 }
10813
10814 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target,
10815 source_texture_ref, dest_texture_ref, level,
10816 dest_internal_format)) {
10817 return;
10818 }
10819
10820 // Clear the source texture if necessary.
10821 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
10822 source_texture->target(), 0)) {
10823 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
10824 "source texture dimensions too big");
10825 return;
10826 }
10827
10828 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
10829 // needed because it takes 10s of milliseconds to initialize.
10830 if (!copy_texture_CHROMIUM_.get()) {
10831 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM");
10832 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
10833 copy_texture_CHROMIUM_->Initialize(this);
10834 RestoreCurrentFramebufferBindings();
10835 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR)
10836 return;
10837 }
10838
10839 int dest_width = 0;
10840 int dest_height = 0;
10841 bool ok = dest_texture->GetLevelSize(GL_TEXTURE_2D, level, &dest_width,
10842 &dest_height);
10843 DCHECK(ok);
10844 if (xoffset != 0 || yoffset != 0 || source_width != dest_width ||
10845 source_height != dest_height) {
10846 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target,
10847 level)) {
10848 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
10849 "destination texture dimensions too big");
10850 return;
10851 }
10852 } else {
10853 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, level,
10854 true);
10855 }
10856
10857 ScopedModifyPixels modify(dest_texture_ref);
10858
10859 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
10860
10861 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
10862 // before presenting.
10863 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
10864 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
10865 // instead of using kIdentityMatrix crbug.com/226218.
10866 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform(
10867 this, source_texture->target(), source_texture->service_id(),
10868 dest_texture->service_id(), level, xoffset, yoffset, dest_width,
10869 dest_height, source_width, source_height, unpack_flip_y_,
10870 unpack_premultiply_alpha_, unpack_unpremultiply_alpha_,
10871 kIdentityMatrix);
10872 } else {
10873 copy_texture_CHROMIUM_->DoCopySubTexture(
10874 this, source_texture->target(), source_texture->service_id(),
10875 source_internal_format, dest_texture->service_id(), level,
10876 dest_internal_format, xoffset, yoffset, dest_width, dest_height,
10877 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
10878 unpack_unpremultiply_alpha_);
10879 }
10880
10881 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
10710 } 10882 }
10711 10883
10712 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 10884 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
10713 switch (internalformat) { 10885 switch (internalformat) {
10714 case GL_RGB565: 10886 case GL_RGB565:
10715 return GL_UNSIGNED_SHORT_5_6_5; 10887 return GL_UNSIGNED_SHORT_5_6_5;
10716 case GL_RGBA4: 10888 case GL_RGBA4:
10717 return GL_UNSIGNED_SHORT_4_4_4_4; 10889 return GL_UNSIGNED_SHORT_4_4_4_4;
10718 case GL_RGB5_A1: 10890 case GL_RGB5_A1:
10719 return GL_UNSIGNED_SHORT_5_5_5_1; 10891 return GL_UNSIGNED_SHORT_5_5_5_1;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
11301 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || 11473 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM ||
11302 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); 11474 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM);
11303 11475
11304 if (!features().chromium_path_rendering) { 11476 if (!features().chromium_path_rendering) {
11305 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 11477 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
11306 "glMatrixLoadIdentityCHROMIUM", 11478 "glMatrixLoadIdentityCHROMIUM",
11307 "function not available"); 11479 "function not available");
11308 return; 11480 return;
11309 } 11481 }
11310 11482
11311 static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
11312 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
11313 0.0f, 0.0f, 0.0f, 1.0f};
11314
11315 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM 11483 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM
11316 ? state_.projection_matrix 11484 ? state_.projection_matrix
11317 : state_.modelview_matrix; 11485 : state_.modelview_matrix;
11318 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); 11486 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix));
11319 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV 11487 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV
11320 // since the values of the _NV and _CHROMIUM tokens match. 11488 // since the values of the _NV and _CHROMIUM tokens match.
11321 glMatrixLoadIdentityEXT(matrix_mode); 11489 glMatrixLoadIdentityEXT(matrix_mode);
11322 } 11490 }
11323 11491
11324 bool GLES2DecoderImpl::ValidateAsyncTransfer( 11492 bool GLES2DecoderImpl::ValidateAsyncTransfer(
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
11643 } 11811 }
11644 } 11812 }
11645 11813
11646 // Include the auto-generated part of this file. We split this because it means 11814 // Include the auto-generated part of this file. We split this because it means
11647 // we can easily edit the non-auto generated parts right here in this file 11815 // we can easily edit the non-auto generated parts right here in this file
11648 // instead of having to edit some template or the code generator. 11816 // instead of having to edit some template or the code generator.
11649 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11817 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11650 11818
11651 } // namespace gles2 11819 } // namespace gles2
11652 } // namespace gpu 11820 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698