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

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: remove level altogether Created 5 years, 10 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 const GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
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 GLenum internal_format,
943 GLint level, 948 GLenum dest_type);
944 GLenum internal_format, 949
945 GLenum dest_type); 950 void DoCopySubTextureCHROMIUM(GLenum target,
951 GLuint source_id,
952 GLuint dest_id,
953 GLint xoffset,
954 GLint yoffset);
946 955
947 // Wrapper for TexStorage2DEXT. 956 // Wrapper for TexStorage2DEXT.
948 void DoTexStorage2DEXT( 957 void DoTexStorage2DEXT(
949 GLenum target, 958 GLenum target,
950 GLint levels, 959 GLint levels,
951 GLenum internal_format, 960 GLenum internal_format,
952 GLsizei width, 961 GLsizei width,
953 GLsizei height); 962 GLsizei height);
954 963
955 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 964 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 const char* function_name, 1661 const char* function_name,
1653 GLint level, GLsizei width, GLsizei height, GLenum format); 1662 GLint level, GLsizei width, GLsizei height, GLenum format);
1654 bool ValidateCompressedTexFuncData( 1663 bool ValidateCompressedTexFuncData(
1655 const char* function_name, 1664 const char* function_name,
1656 GLsizei width, GLsizei height, GLenum format, size_t size); 1665 GLsizei width, GLsizei height, GLenum format, size_t size);
1657 bool ValidateCompressedTexSubDimensions( 1666 bool ValidateCompressedTexSubDimensions(
1658 const char* function_name, 1667 const char* function_name,
1659 GLenum target, GLint level, GLint xoffset, GLint yoffset, 1668 GLenum target, GLint level, GLint xoffset, GLint yoffset,
1660 GLsizei width, GLsizei height, GLenum format, 1669 GLsizei width, GLsizei height, GLenum format,
1661 Texture* texture); 1670 Texture* texture);
1671 bool ValidateCopyTextureCHROMIUM(const char* function_name,
1672 GLenum target,
1673 TextureRef* source_texture_ref,
1674 TextureRef* dest_texture_ref,
1675 GLenum dest_internal_format);
1662 1676
1663 void RenderWarning(const char* filename, int line, const std::string& msg); 1677 void RenderWarning(const char* filename, int line, const std::string& msg);
1664 void PerformanceWarning( 1678 void PerformanceWarning(
1665 const char* filename, int line, const std::string& msg); 1679 const char* filename, int line, const std::string& msg);
1666 1680
1667 const FeatureInfo::FeatureFlags& features() const { 1681 const FeatureInfo::FeatureFlags& features() const {
1668 return feature_info_->feature_flags(); 1682 return feature_info_->feature_flags();
1669 } 1683 }
1670 1684
1671 const FeatureInfo::Workarounds& workarounds() const { 1685 const FeatureInfo::Workarounds& workarounds() const {
(...skipping 9255 matching lines...) Expand 10 before | Expand all | Expand 10 after
10927 return GL_LUMINANCE_ALPHA; 10941 return GL_LUMINANCE_ALPHA;
10928 case GL_BGRA8_EXT: 10942 case GL_BGRA8_EXT:
10929 return GL_BGRA_EXT; 10943 return GL_BGRA_EXT;
10930 case GL_SRGB8_ALPHA8_EXT: 10944 case GL_SRGB8_ALPHA8_EXT:
10931 return GL_SRGB_ALPHA_EXT; 10945 return GL_SRGB_ALPHA_EXT;
10932 default: 10946 default:
10933 return GL_NONE; 10947 return GL_NONE;
10934 } 10948 }
10935 } 10949 }
10936 10950
10937 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 10951 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
10938 GLenum target, GLuint source_id, GLuint dest_id, GLint level, 10952 const char* function_name,
10939 GLenum internal_format, GLenum dest_type) { 10953 GLenum target,
10940 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 10954 TextureRef* source_texture_ref,
10941 10955 TextureRef* dest_texture_ref,
10942 TextureRef* dest_texture_ref = GetTexture(dest_id); 10956 GLenum dest_internal_format) {
10943 TextureRef* source_texture_ref = GetTexture(source_id);
10944
10945 if (!source_texture_ref || !dest_texture_ref) { 10957 if (!source_texture_ref || !dest_texture_ref) {
10946 LOCAL_SET_GL_ERROR( 10958 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
10947 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); 10959 return false;
10948 return;
10949 } 10960 }
10950 10961
10951 if (GL_TEXTURE_2D != target) { 10962 if (GL_TEXTURE_2D != target) {
10952 LOCAL_SET_GL_ERROR( 10963 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
10953 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid texture target"); 10964 "invalid texture target");
10954 return; 10965 return false;
10955 } 10966 }
10956 10967
10957 Texture* source_texture = source_texture_ref->texture(); 10968 Texture* source_texture = source_texture_ref->texture();
10958 Texture* dest_texture = dest_texture_ref->texture(); 10969 Texture* dest_texture = dest_texture_ref->texture();
10970 if (source_texture == dest_texture) {
10971 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
10972 "source and destination textures are the same");
10973 return false;
10974 }
10975
10959 if (dest_texture->target() != GL_TEXTURE_2D || 10976 if (dest_texture->target() != GL_TEXTURE_2D ||
10960 (source_texture->target() != GL_TEXTURE_2D && 10977 (source_texture->target() != GL_TEXTURE_2D &&
10961 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && 10978 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
10962 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { 10979 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
10963 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, 10980 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
10964 "glCopyTextureCHROMIUM",
10965 "invalid texture target binding"); 10981 "invalid texture target binding");
10966 return; 10982 return false;
10967 } 10983 }
10968 10984
10969 int source_width, source_height, dest_width, dest_height; 10985 GLenum source_type = 0;
10986 GLenum source_internal_format = 0;
10987 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
10988 &source_internal_format);
10970 10989
10990 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA,
10991 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not
10992 // renderable on some platforms.
10993 bool valid_dest_format = dest_internal_format == GL_RGB ||
10994 dest_internal_format == GL_RGBA ||
10995 dest_internal_format == GL_BGRA_EXT;
10996 bool valid_source_format = source_internal_format == GL_ALPHA ||
10997 source_internal_format == GL_RGB ||
10998 source_internal_format == GL_RGBA ||
10999 source_internal_format == GL_LUMINANCE ||
11000 source_internal_format == GL_LUMINANCE_ALPHA ||
11001 source_internal_format == GL_BGRA_EXT;
11002 if (!valid_source_format || !valid_dest_format) {
11003 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
11004 "invalid internal format");
11005 return false;
11006 }
11007 return true;
11008 }
11009
11010 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target,
11011 GLuint source_id,
11012 GLuint dest_id,
11013 GLenum internal_format,
11014 GLenum dest_type) {
11015 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
11016
11017 TextureRef* source_texture_ref = GetTexture(source_id);
11018 TextureRef* dest_texture_ref = GetTexture(dest_id);
11019 Texture* source_texture = source_texture_ref->texture();
11020 Texture* dest_texture = dest_texture_ref->texture();
11021 int source_width = 0;
11022 int source_height = 0;
10971 gfx::GLImage* image = 11023 gfx::GLImage* image =
10972 source_texture->GetLevelImage(source_texture->target(), 0); 11024 source_texture->GetLevelImage(source_texture->target(), 0);
10973 if (image) { 11025 if (image) {
10974 gfx::Size size = image->GetSize(); 11026 gfx::Size size = image->GetSize();
10975 source_width = size.width(); 11027 source_width = size.width();
10976 source_height = size.height(); 11028 source_height = size.height();
10977 if (source_width <= 0 || source_height <= 0) { 11029 if (source_width <= 0 || source_height <= 0) {
10978 LOCAL_SET_GL_ERROR( 11030 LOCAL_SET_GL_ERROR(
10979 GL_INVALID_VALUE, 11031 GL_INVALID_VALUE,
10980 "glCopyTextureChromium", "invalid image size"); 11032 "glCopyTextureChromium", "invalid image size");
10981 return; 11033 return;
10982 } 11034 }
10983 } else { 11035 } else {
10984 if (!source_texture->GetLevelSize( 11036 if (!source_texture->GetLevelSize(
10985 source_texture->target(), 0, &source_width, &source_height)) { 11037 source_texture->target(), 0, &source_width, &source_height)) {
10986 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, 11038 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
10987 "glCopyTextureChromium", 11039 "glCopyTextureChromium",
10988 "source texture has no level 0"); 11040 "source texture has no level 0");
10989 return; 11041 return;
10990 } 11042 }
10991 11043
10992 // Check that this type of texture is allowed. 11044 // Check that this type of texture is allowed.
10993 if (!texture_manager()->ValidForTarget( 11045 if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
10994 source_texture->target(), level, source_width, source_height, 1)) { 11046 source_width, source_height, 1)) {
10995 LOCAL_SET_GL_ERROR( 11047 LOCAL_SET_GL_ERROR(
10996 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions"); 11048 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions");
10997 return; 11049 return;
10998 } 11050 }
10999 } 11051 }
11000 11052
11001 // Clear the source texture if necessary.
11002 if (!texture_manager()->ClearTextureLevel(
11003 this, source_texture_ref, source_texture->target(), 0)) {
11004 LOCAL_SET_GL_ERROR(
11005 GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", "dimensions too big");
11006 return;
11007 }
11008
11009 GLenum source_type = 0; 11053 GLenum source_type = 0;
11010 GLenum source_internal_format = 0; 11054 GLenum source_internal_format = 0;
11011 source_texture->GetLevelType( 11055 source_texture->GetLevelType(
11012 source_texture->target(), 0, &source_type, &source_internal_format); 11056 source_texture->target(), 0, &source_type, &source_internal_format);
11013 11057
11014 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, 11058 if (dest_texture->IsImmutable()) {
11015 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not 11059 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM",
11016 // renderable on some platforms. 11060 "texture is immutable");
11017 bool valid_dest_format = internal_format == GL_RGB ||
11018 internal_format == GL_RGBA ||
11019 internal_format == GL_BGRA_EXT;
11020 bool valid_source_format = source_internal_format == GL_ALPHA ||
11021 source_internal_format == GL_RGB ||
11022 source_internal_format == GL_RGBA ||
11023 source_internal_format == GL_LUMINANCE ||
11024 source_internal_format == GL_LUMINANCE_ALPHA ||
11025 source_internal_format == GL_BGRA_EXT;
11026 if (!valid_source_format || !valid_dest_format) {
11027 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
11028 "glCopyTextureCHROMIUM",
11029 "invalid internal format");
11030 return; 11061 return;
11031 } 11062 }
11032 11063
11064 if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", target,
11065 source_texture_ref, dest_texture_ref,
11066 internal_format)) {
11067 return;
11068 }
11069
11070 // Clear the source texture if necessary.
11071 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
11072 source_texture->target(), 0)) {
11073 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM",
11074 "dimensions too big");
11075 return;
11076 }
11077
11033 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 11078 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
11034 // needed because it takes 10s of milliseconds to initialize. 11079 // needed because it takes 10s of milliseconds to initialize.
11035 if (!copy_texture_CHROMIUM_.get()) { 11080 if (!copy_texture_CHROMIUM_.get()) {
11036 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 11081 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
11037 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 11082 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
11038 copy_texture_CHROMIUM_->Initialize(this); 11083 copy_texture_CHROMIUM_->Initialize(this);
11039 RestoreCurrentFramebufferBindings(); 11084 RestoreCurrentFramebufferBindings();
11040 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 11085 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
11041 return; 11086 return;
11042 } 11087 }
11043 11088
11044 GLenum dest_type_previous = dest_type; 11089 GLenum dest_type_previous = dest_type;
11045 GLenum dest_internal_format = internal_format; 11090 GLenum dest_internal_format = internal_format;
11046 bool dest_level_defined = dest_texture->GetLevelSize( 11091 int dest_width = 0;
11047 GL_TEXTURE_2D, level, &dest_width, &dest_height); 11092 int dest_height = 0;
11093 bool dest_level_defined =
11094 dest_texture->GetLevelSize(GL_TEXTURE_2D, 0, &dest_width, &dest_height);
11048 11095
11049 if (dest_level_defined) { 11096 if (dest_level_defined) {
11050 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, 11097 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous,
11051 &dest_internal_format); 11098 &dest_internal_format);
11052 } 11099 }
11053 11100
11054 // Resize the destination texture to the dimensions of the source texture. 11101 // Resize the destination texture to the dimensions of the source texture.
11055 if (!dest_level_defined || dest_width != source_width || 11102 if (!dest_level_defined || dest_width != source_width ||
11056 dest_height != source_height || 11103 dest_height != source_height ||
11057 dest_internal_format != internal_format || 11104 dest_internal_format != internal_format ||
11058 dest_type_previous != dest_type) { 11105 dest_type_previous != dest_type) {
11059 // Ensure that the glTexImage2D succeeds. 11106 // Ensure that the glTexImage2D succeeds.
11060 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 11107 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
11061 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 11108 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
11062 glTexImage2D( 11109 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height,
11063 GL_TEXTURE_2D, level, internal_format, source_width, source_height, 11110 0, internal_format, dest_type, NULL);
11064 0, internal_format, dest_type, NULL);
11065 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); 11111 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM");
11066 if (error != GL_NO_ERROR) { 11112 if (error != GL_NO_ERROR) {
11067 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); 11113 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D);
11068 return; 11114 return;
11069 } 11115 }
11070 11116
11071 texture_manager()->SetLevelInfo( 11117 texture_manager()->SetLevelInfo(
11072 dest_texture_ref, GL_TEXTURE_2D, level, internal_format, source_width, 11118 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width,
11073 source_height, 1, 0, internal_format, dest_type, true); 11119 source_height, 1, 0, internal_format, dest_type, true);
11074 } else { 11120 } else {
11075 texture_manager()->SetLevelCleared( 11121 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
11076 dest_texture_ref, GL_TEXTURE_2D, level, true); 11122 true);
11077 } 11123 }
11078 11124
11079 ScopedModifyPixels modify(dest_texture_ref); 11125 ScopedModifyPixels modify(dest_texture_ref);
11080 11126
11081 // Try using GLImage::CopyTexImage when possible. 11127 // Try using GLImage::CopyTexImage when possible.
11082 bool unpack_premultiply_alpha_change = 11128 bool unpack_premultiply_alpha_change =
11083 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_; 11129 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_;
11084 if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change && !level) { 11130 if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change) {
11085 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 11131 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
11086 if (image->CopyTexImage(GL_TEXTURE_2D)) 11132 if (image->CopyTexImage(GL_TEXTURE_2D))
11087 return; 11133 return;
11088 } 11134 }
11089 11135
11090 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); 11136 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
11091 11137
11092 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 11138 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
11093 // before presenting. 11139 // before presenting.
11094 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 11140 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
11095 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 11141 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
11096 // instead of using default matrix crbug.com/226218. 11142 // instead of using kIdentityMatrix crbug.com/226218.
11097 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
11098 0.0f, 1.0f, 0.0f, 0.0f,
11099 0.0f, 0.0f, 1.0f, 0.0f,
11100 0.0f, 0.0f, 0.0f, 1.0f};
11101 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 11143 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
11102 this, 11144 this, source_texture->target(), source_texture->service_id(),
11103 source_texture->target(), 11145 dest_texture->service_id(), source_width, source_height, unpack_flip_y_,
11104 source_texture->service_id(), 11146 unpack_premultiply_alpha_, unpack_unpremultiply_alpha_,
11105 dest_texture->service_id(), 11147 kIdentityMatrix);
11106 level,
11107 source_width,
11108 source_height,
11109 unpack_flip_y_,
11110 unpack_premultiply_alpha_,
11111 unpack_unpremultiply_alpha_,
11112 default_matrix);
11113 } else { 11148 } else {
11114 copy_texture_CHROMIUM_->DoCopyTexture(this, 11149 copy_texture_CHROMIUM_->DoCopyTexture(
11115 source_texture->target(), 11150 this, source_texture->target(), source_texture->service_id(),
11116 source_texture->service_id(), 11151 source_internal_format, dest_texture->service_id(), internal_format,
11117 source_internal_format, 11152 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
11118 dest_texture->service_id(), 11153 unpack_unpremultiply_alpha_);
11119 level,
11120 internal_format,
11121 source_width,
11122 source_height,
11123 unpack_flip_y_,
11124 unpack_premultiply_alpha_,
11125 unpack_unpremultiply_alpha_);
11126 } 11154 }
11127 11155
11128 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 11156 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
11157 }
11158
11159 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(GLenum target,
11160 GLuint source_id,
11161 GLuint dest_id,
11162 GLint xoffset,
11163 GLint yoffset) {
11164 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM");
11165
11166 TextureRef* source_texture_ref = GetTexture(source_id);
11167 TextureRef* dest_texture_ref = GetTexture(dest_id);
11168 Texture* source_texture = source_texture_ref->texture();
11169 Texture* dest_texture = dest_texture_ref->texture();
11170 int source_width = 0;
11171 int source_height = 0;
11172 gfx::GLImage* image =
11173 source_texture->GetLevelImage(source_texture->target(), 0);
11174 if (image) {
11175 gfx::Size size = image->GetSize();
11176 source_width = size.width();
11177 source_height = size.height();
11178 if (source_width <= 0 || source_height <= 0) {
11179 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11180 "invalid image size");
11181 return;
11182 }
11183 } else {
11184 if (!source_texture->GetLevelSize(source_texture->target(), 0,
11185 &source_width, &source_height)) {
11186 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11187 "source texture has no level 0");
11188 return;
11189 }
11190
11191 // Check that this type of texture is allowed.
11192 if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
11193 source_width, source_height, 1)) {
11194 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11195 "source texture bad dimensions");
11196 return;
11197 }
11198 }
11199
11200 GLenum source_type = 0;
11201 GLenum source_internal_format = 0;
11202 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
11203 &source_internal_format);
11204 GLenum dest_type = 0;
11205 GLenum dest_internal_format = 0;
11206 bool dest_level_defined = dest_texture->GetLevelType(
11207 dest_texture->target(), 0, &dest_type, &dest_internal_format);
11208 if (!dest_level_defined) {
11209 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM",
11210 "destination texture is not defined");
11211 return;
11212 }
11213 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset,
dshwang 2015/02/27 11:56:41 Here.
11214 yoffset, source_width, source_height,
11215 dest_type)) {
11216 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11217 "destination texture bad dimensions.");
11218 return;
11219 }
11220
11221 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target,
11222 source_texture_ref, dest_texture_ref,
11223 dest_internal_format)) {
11224 return;
11225 }
11226
11227 // Clear the source texture if necessary.
11228 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
11229 source_texture->target(), 0)) {
11230 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
11231 "source texture dimensions too big");
11232 return;
11233 }
11234
11235 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
11236 // needed because it takes 10s of milliseconds to initialize.
11237 if (!copy_texture_CHROMIUM_.get()) {
11238 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM");
11239 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
11240 copy_texture_CHROMIUM_->Initialize(this);
11241 RestoreCurrentFramebufferBindings();
11242 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR)
11243 return;
11244 }
11245
11246 int dest_width = 0;
11247 int dest_height = 0;
11248 bool ok =
11249 dest_texture->GetLevelSize(GL_TEXTURE_2D, 0, &dest_width, &dest_height);
11250 DCHECK(ok);
11251 if (xoffset != 0 || yoffset != 0 || source_width != dest_width ||
11252 source_height != dest_height) {
11253 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target,
11254 0)) {
11255 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
11256 "destination texture dimensions too big");
11257 return;
11258 }
11259 } else {
11260 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
11261 true);
11262 }
11263
11264 ScopedModifyPixels modify(dest_texture_ref);
11265
11266 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
11267
11268 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
11269 // before presenting.
11270 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
11271 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
11272 // instead of using kIdentityMatrix crbug.com/226218.
11273 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform(
11274 this, source_texture->target(), source_texture->service_id(),
11275 dest_texture->service_id(), xoffset, yoffset, dest_width, dest_height,
11276 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
11277 unpack_unpremultiply_alpha_, kIdentityMatrix);
11278 } else {
11279 copy_texture_CHROMIUM_->DoCopySubTexture(
11280 this, source_texture->target(), source_texture->service_id(),
11281 source_internal_format, dest_texture->service_id(),
11282 dest_internal_format, xoffset, yoffset, dest_width, dest_height,
11283 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
11284 unpack_unpremultiply_alpha_);
11285 }
11286
11287 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
11129 } 11288 }
11130 11289
11131 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 11290 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
11132 switch (internalformat) { 11291 switch (internalformat) {
11133 case GL_RGB565: 11292 case GL_RGB565:
11134 return GL_UNSIGNED_SHORT_5_6_5; 11293 return GL_UNSIGNED_SHORT_5_6_5;
11135 case GL_RGBA4: 11294 case GL_RGBA4:
11136 return GL_UNSIGNED_SHORT_4_4_4_4; 11295 return GL_UNSIGNED_SHORT_4_4_4_4;
11137 case GL_RGB5_A1: 11296 case GL_RGB5_A1:
11138 return GL_UNSIGNED_SHORT_5_5_5_1; 11297 return GL_UNSIGNED_SHORT_5_5_5_1;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
11720 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || 11879 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM ||
11721 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); 11880 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM);
11722 11881
11723 if (!features().chromium_path_rendering) { 11882 if (!features().chromium_path_rendering) {
11724 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 11883 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
11725 "glMatrixLoadIdentityCHROMIUM", 11884 "glMatrixLoadIdentityCHROMIUM",
11726 "function not available"); 11885 "function not available");
11727 return; 11886 return;
11728 } 11887 }
11729 11888
11730 static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
11731 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
11732 0.0f, 0.0f, 0.0f, 1.0f};
11733
11734 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM 11889 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM
11735 ? state_.projection_matrix 11890 ? state_.projection_matrix
11736 : state_.modelview_matrix; 11891 : state_.modelview_matrix;
11737 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); 11892 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix));
11738 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV 11893 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV
11739 // since the values of the _NV and _CHROMIUM tokens match. 11894 // since the values of the _NV and _CHROMIUM tokens match.
11740 glMatrixLoadIdentityEXT(matrix_mode); 11895 glMatrixLoadIdentityEXT(matrix_mode);
11741 } 11896 }
11742 11897
11743 bool GLES2DecoderImpl::ValidateAsyncTransfer( 11898 bool GLES2DecoderImpl::ValidateAsyncTransfer(
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
12126 } 12281 }
12127 } 12282 }
12128 12283
12129 // Include the auto-generated part of this file. We split this because it means 12284 // Include the auto-generated part of this file. We split this because it means
12130 // we can easily edit the non-auto generated parts right here in this file 12285 // we can easily edit the non-auto generated parts right here in this file
12131 // instead of having to edit some template or the code generator. 12286 // instead of having to edit some template or the code generator.
12132 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 12287 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
12133 12288
12134 } // namespace gles2 12289 } // namespace gles2
12135 } // namespace gpu 12290 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698