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 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1039 void DoCopySubTextureCHROMIUM(GLenum target, | 1039 void DoCopySubTextureCHROMIUM(GLenum target, |
1040 GLuint source_id, | 1040 GLuint source_id, |
1041 GLuint dest_id, | 1041 GLuint dest_id, |
1042 GLint xoffset, | 1042 GLint xoffset, |
1043 GLint yoffset, | 1043 GLint yoffset, |
1044 GLint x, | 1044 GLint x, |
1045 GLint y, | 1045 GLint y, |
1046 GLsizei width, | 1046 GLsizei width, |
1047 GLsizei height); | 1047 GLsizei height); |
1048 | 1048 |
1049 void DoCompressedCopyTextureCHROMIUM(GLenum target, | |
1050 GLuint source_id, | |
1051 GLuint dest_id); | |
1052 | |
1049 // Wrapper for TexStorage2DEXT. | 1053 // Wrapper for TexStorage2DEXT. |
1050 void DoTexStorage2DEXT( | 1054 void DoTexStorage2DEXT( |
1051 GLenum target, | 1055 GLenum target, |
1052 GLint levels, | 1056 GLint levels, |
1053 GLenum internal_format, | 1057 GLenum internal_format, |
1054 GLsizei width, | 1058 GLsizei width, |
1055 GLsizei height); | 1059 GLsizei height); |
1056 | 1060 |
1057 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 1061 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
1058 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, | 1062 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 | 1766 |
1763 bool WasContextLost() const override; | 1767 bool WasContextLost() const override; |
1764 bool WasContextLostByRobustnessExtension() const override; | 1768 bool WasContextLostByRobustnessExtension() const override; |
1765 void MarkContextLost(error::ContextLostReason reason) override; | 1769 void MarkContextLost(error::ContextLostReason reason) override; |
1766 bool CheckResetStatus(); | 1770 bool CheckResetStatus(); |
1767 | 1771 |
1768 #if defined(OS_MACOSX) | 1772 #if defined(OS_MACOSX) |
1769 void ReleaseIOSurfaceForTexture(GLuint texture_id); | 1773 void ReleaseIOSurfaceForTexture(GLuint texture_id); |
1770 #endif | 1774 #endif |
1771 | 1775 |
1776 bool GetCompressedTexSizeInBytes( | |
1777 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, | |
1778 GLenum format, GLsizei* size_in_bytes); | |
1779 | |
1772 bool ValidateCompressedTexDimensions( | 1780 bool ValidateCompressedTexDimensions( |
1773 const char* function_name, GLenum target, GLint level, | 1781 const char* function_name, GLenum target, GLint level, |
1774 GLsizei width, GLsizei height, GLsizei depth, GLenum format); | 1782 GLsizei width, GLsizei height, GLsizei depth, GLenum format); |
1775 bool ValidateCompressedTexFuncData( | 1783 bool ValidateCompressedTexFuncData( |
1776 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, | 1784 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, |
1777 GLenum format, GLsizei size); | 1785 GLenum format, GLsizei size); |
1778 bool ValidateCompressedTexSubDimensions( | 1786 bool ValidateCompressedTexSubDimensions( |
1779 const char* function_name, | 1787 const char* function_name, |
1780 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 1788 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
1781 GLsizei width, GLsizei height, GLsizei depth, GLenum format, | 1789 GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
1782 Texture* texture); | 1790 Texture* texture); |
1783 bool ValidateCopyTextureCHROMIUM(const char* function_name, | 1791 bool ValidateCopyTextureCHROMIUM(const char* function_name, |
1784 GLenum target, | 1792 GLenum target, |
1785 TextureRef* source_texture_ref, | 1793 TextureRef* source_texture_ref, |
1786 TextureRef* dest_texture_ref, | 1794 TextureRef* dest_texture_ref, |
1787 GLenum dest_internal_format); | 1795 GLenum dest_internal_format); |
1796 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, | |
1797 GLenum target, | |
1798 TextureRef* source_texture_ref, | |
1799 TextureRef* dest_texture_ref); | |
1788 | 1800 |
1789 void RenderWarning(const char* filename, int line, const std::string& msg); | 1801 void RenderWarning(const char* filename, int line, const std::string& msg); |
1790 void PerformanceWarning( | 1802 void PerformanceWarning( |
1791 const char* filename, int line, const std::string& msg); | 1803 const char* filename, int line, const std::string& msg); |
1792 | 1804 |
1793 const FeatureInfo::FeatureFlags& features() const { | 1805 const FeatureInfo::FeatureFlags& features() const { |
1794 return feature_info_->feature_flags(); | 1806 return feature_info_->feature_flags(); |
1795 } | 1807 } |
1796 | 1808 |
1797 const FeatureInfo::Workarounds& workarounds() const { | 1809 const FeatureInfo::Workarounds& workarounds() const { |
(...skipping 7224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9022 return (size == 1) || | 9034 return (size == 1) || |
9023 (size == 2) || !(size % kS3TCBlockWidth); | 9035 (size == 2) || !(size % kS3TCBlockWidth); |
9024 } | 9036 } |
9025 | 9037 |
9026 bool IsValidPVRTCSize(GLint level, GLsizei size) { | 9038 bool IsValidPVRTCSize(GLint level, GLsizei size) { |
9027 return GLES2Util::IsPOT(size); | 9039 return GLES2Util::IsPOT(size); |
9028 } | 9040 } |
9029 | 9041 |
9030 } // anonymous namespace. | 9042 } // anonymous namespace. |
9031 | 9043 |
9032 bool GLES2DecoderImpl::ValidateCompressedTexFuncData( | 9044 bool GLES2DecoderImpl::GetCompressedTexSizeInBytes( |
9033 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, | 9045 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, |
9034 GLenum format, GLsizei size) { | 9046 GLenum format, GLsizei* size_in_bytes) { |
9035 base::CheckedNumeric<GLsizei> bytes_required(0); | 9047 base::CheckedNumeric<GLsizei> bytes_required(0); |
9036 | 9048 |
9037 switch (format) { | 9049 switch (format) { |
9038 case GL_ATC_RGB_AMD: | 9050 case GL_ATC_RGB_AMD: |
9039 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 9051 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
9040 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 9052 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
9041 case GL_ETC1_RGB8_OES: | 9053 case GL_ETC1_RGB8_OES: |
9042 bytes_required = | 9054 bytes_required = |
9043 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; | 9055 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; |
9044 bytes_required *= | 9056 bytes_required *= |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9095 bytes_required *= | 9107 bytes_required *= |
9096 (height + kEACAndETC2BlockSize - 1) / kEACAndETC2BlockSize; | 9108 (height + kEACAndETC2BlockSize - 1) / kEACAndETC2BlockSize; |
9097 bytes_required *= 16; | 9109 bytes_required *= 16; |
9098 bytes_required *= depth; | 9110 bytes_required *= depth; |
9099 break; | 9111 break; |
9100 default: | 9112 default: |
9101 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, format, "format"); | 9113 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, format, "format"); |
9102 return false; | 9114 return false; |
9103 } | 9115 } |
9104 | 9116 |
9105 if (!bytes_required.IsValid() || size != bytes_required.ValueOrDefault(0)) { | 9117 if (!bytes_required.IsValid()) { |
9118 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "invalid size"); | |
9119 return false; | |
9120 } | |
9121 | |
9122 *size_in_bytes = bytes_required.ValueOrDefault(0); | |
9123 return true; | |
9124 } | |
9125 | |
9126 bool GLES2DecoderImpl::ValidateCompressedTexFuncData( | |
9127 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, | |
9128 GLenum format, GLsizei size) { | |
9129 GLsizei bytes_required = 0; | |
9130 if (!GetCompressedTexSizeInBytes( | |
9131 function_name, width, height, depth, format, &bytes_required)) { | |
9132 return false; | |
9133 } | |
9134 | |
9135 if (size != bytes_required) { | |
9106 LOCAL_SET_GL_ERROR( | 9136 LOCAL_SET_GL_ERROR( |
9107 GL_INVALID_VALUE, function_name, "size is not correct for dimensions"); | 9137 GL_INVALID_VALUE, function_name, "size is not correct for dimensions"); |
9108 return false; | 9138 return false; |
9109 } | 9139 } |
9110 | 9140 |
9111 return true; | 9141 return true; |
9112 } | 9142 } |
9113 | 9143 |
9114 bool GLES2DecoderImpl::ValidateCompressedTexDimensions( | 9144 bool GLES2DecoderImpl::ValidateCompressedTexDimensions( |
9115 const char* function_name, GLenum target, GLint level, | 9145 const char* function_name, GLenum target, GLint level, |
(...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11916 source_internal_format == GL_LUMINANCE_ALPHA || | 11946 source_internal_format == GL_LUMINANCE_ALPHA || |
11917 source_internal_format == GL_BGRA_EXT; | 11947 source_internal_format == GL_BGRA_EXT; |
11918 if (!valid_source_format || !valid_dest_format) { | 11948 if (!valid_source_format || !valid_dest_format) { |
11919 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 11949 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
11920 "invalid internal format"); | 11950 "invalid internal format"); |
11921 return false; | 11951 return false; |
11922 } | 11952 } |
11923 return true; | 11953 return true; |
11924 } | 11954 } |
11925 | 11955 |
11956 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( | |
11957 const char* function_name, | |
11958 GLenum target, | |
11959 TextureRef* source_texture_ref, | |
11960 TextureRef* dest_texture_ref) { | |
11961 if (!source_texture_ref || !dest_texture_ref) { | |
11962 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); | |
11963 return false; | |
11964 } | |
11965 | |
11966 if (GL_TEXTURE_2D != target) { | |
11967 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | |
11968 "invalid texture target"); | |
11969 return false; | |
11970 } | |
11971 | |
11972 Texture* source_texture = source_texture_ref->texture(); | |
11973 Texture* dest_texture = dest_texture_ref->texture(); | |
11974 if (source_texture == dest_texture) { | |
11975 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
11976 "source and destination textures are the same"); | |
11977 return false; | |
11978 } | |
11979 | |
11980 if (dest_texture->target() != GL_TEXTURE_2D || | |
11981 (source_texture->target() != GL_TEXTURE_2D && | |
11982 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && | |
11983 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { | |
11984 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | |
11985 "invalid texture target binding"); | |
11986 return false; | |
11987 } | |
11988 | |
11989 GLenum source_type = 0; | |
11990 GLenum source_internal_format = 0; | |
11991 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | |
11992 &source_internal_format); | |
11993 | |
11994 bool valid_format = | |
11995 source_internal_format == GL_ATC_RGB_AMD || | |
11996 source_internal_format == GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD || | |
11997 source_internal_format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || | |
11998 source_internal_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT || | |
11999 source_internal_format == GL_ETC1_RGB8_OES; | |
12000 | |
12001 if (!valid_format) { | |
12002 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
12003 "invalid internal format"); | |
12004 return false; | |
12005 } | |
12006 | |
12007 return true; | |
12008 } | |
12009 | |
11926 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target, | 12010 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target, |
11927 GLuint source_id, | 12011 GLuint source_id, |
11928 GLuint dest_id, | 12012 GLuint dest_id, |
11929 GLenum internal_format, | 12013 GLenum internal_format, |
11930 GLenum dest_type) { | 12014 GLenum dest_type) { |
11931 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); | 12015 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); |
11932 | 12016 |
11933 TextureRef* source_texture_ref = GetTexture(source_id); | 12017 TextureRef* source_texture_ref = GetTexture(source_id); |
11934 TextureRef* dest_texture_ref = GetTexture(dest_id); | 12018 TextureRef* dest_texture_ref = GetTexture(dest_id); |
11935 Texture* source_texture = source_texture_ref->texture(); | 12019 Texture* source_texture = source_texture_ref->texture(); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12221 copy_texture_CHROMIUM_->DoCopySubTexture( | 12305 copy_texture_CHROMIUM_->DoCopySubTexture( |
12222 this, source_texture->target(), source_texture->service_id(), | 12306 this, source_texture->target(), source_texture->service_id(), |
12223 source_internal_format, dest_texture->service_id(), dest_internal_format, | 12307 source_internal_format, dest_texture->service_id(), dest_internal_format, |
12224 xoffset, yoffset, x, y, width, height, dest_width, dest_height, | 12308 xoffset, yoffset, x, y, width, height, dest_width, dest_height, |
12225 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_, | 12309 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_, |
12226 unpack_unpremultiply_alpha_); | 12310 unpack_unpremultiply_alpha_); |
12227 | 12311 |
12228 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | 12312 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
12229 } | 12313 } |
12230 | 12314 |
12315 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, | |
12316 GLuint source_id, | |
12317 GLuint dest_id) { | |
12318 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); | |
12319 | |
12320 TextureRef* source_texture_ref = GetTexture(source_id); | |
12321 TextureRef* dest_texture_ref = GetTexture(dest_id); | |
12322 Texture* source_texture = source_texture_ref->texture(); | |
12323 Texture* dest_texture = dest_texture_ref->texture(); | |
12324 int source_width = 0; | |
12325 int source_height = 0; | |
12326 gfx::GLImage* image = | |
12327 source_texture->GetLevelImage(source_texture->target(), 0); | |
12328 if (image) { | |
12329 gfx::Size size = image->GetSize(); | |
12330 source_width = size.width(); | |
12331 source_height = size.height(); | |
12332 if (source_width <= 0 || source_height <= 0) { | |
12333 LOCAL_SET_GL_ERROR( | |
12334 GL_INVALID_VALUE, | |
12335 "glCompressedCopyTextureCHROMIUM", "invalid image size"); | |
12336 return; | |
12337 } | |
12338 } else { | |
12339 if (!source_texture->GetLevelSize(source_texture->target(), 0, | |
12340 &source_width, &source_height, nullptr)) { | |
12341 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, | |
12342 "glCompressedCopyTextureCHROMIUM", | |
12343 "source texture has no level 0"); | |
12344 return; | |
12345 } | |
12346 | |
12347 // Check that this type of texture is allowed. | |
12348 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, | |
12349 source_width, source_height, 1)) { | |
12350 LOCAL_SET_GL_ERROR( | |
12351 GL_INVALID_VALUE, "glCompressedCopyTextureCHROMIUM", | |
12352 "Bad dimensions"); | |
12353 return; | |
12354 } | |
12355 } | |
12356 | |
12357 GLenum source_type = 0; | |
12358 GLenum source_internal_format = 0; | |
12359 source_texture->GetLevelType( | |
12360 source_texture->target(), 0, &source_type, &source_internal_format); | |
12361 | |
12362 if (dest_texture->IsImmutable()) { | |
12363 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | |
12364 "glCompressedCopyTextureCHROMIUM", | |
12365 "texture is immutable"); | |
12366 return; | |
12367 } | |
12368 | |
12369 bool unpack_premultiply_alpha_change = | |
12370 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_; | |
12371 if (unpack_flip_y_ || unpack_premultiply_alpha_change) { | |
12372 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCompressedCopyTextureCHROMIUM", | |
12373 "pixel-storage multipliers are not supported"); | |
piman
2015/06/15 18:37:47
And return.
christiank
2015/06/16 06:57:49
Done.
| |
12374 } | |
12375 | |
12376 if (!ValidateCompressedCopyTextureCHROMIUM( | |
12377 "glCompressedCopyTextureCHROMIUM", | |
12378 target, | |
12379 source_texture_ref, dest_texture_ref)) { | |
12380 return; | |
12381 } | |
12382 | |
12383 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is | |
12384 // needed because it takes 10s of milliseconds to initialize. | |
12385 if (!copy_texture_CHROMIUM_.get()) { | |
12386 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); | |
12387 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | |
12388 copy_texture_CHROMIUM_->Initialize(this); | |
12389 RestoreCurrentFramebufferBindings(); | |
12390 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) | |
12391 return; | |
12392 } | |
12393 | |
12394 // Clear the source texture if necessary. | |
12395 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, | |
12396 source_texture->target(), 0)) { | |
12397 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCompressedCopyTextureCHROMIUM", | |
12398 "dimensions too big"); | |
12399 return; | |
12400 } | |
12401 | |
12402 GLenum dest_type = 0; | |
12403 GLenum dest_internal_format = 0; | |
12404 int dest_width = 0; | |
12405 int dest_height = 0; | |
12406 bool dest_level_defined = dest_texture->GetLevelSize( | |
12407 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); | |
12408 | |
12409 if (dest_level_defined) { | |
12410 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type, | |
12411 &dest_internal_format); | |
12412 } | |
12413 | |
12414 ScopedTextureBinder binder( | |
12415 &state_, dest_texture->service_id(), GL_TEXTURE_2D); | |
12416 | |
12417 // Resize the destination texture to the dimensions of the source texture. | |
12418 if (!dest_level_defined || dest_width != source_width || | |
12419 dest_height != source_height || | |
12420 dest_internal_format != source_internal_format) { | |
12421 GLsizei source_size = 0; | |
12422 if (!GetCompressedTexSizeInBytes( | |
12423 "glCompressedCopyTextureCHROMIUM", source_width, source_height, | |
12424 1, source_internal_format, &source_size)) { | |
12425 return; | |
12426 } | |
12427 | |
12428 // Ensure that the glCompressedTexImage2D succeeds. | |
12429 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | |
12430 glCompressedTexImage2D(GL_TEXTURE_2D, 0, source_internal_format, | |
12431 source_width, source_height, 0, source_size, | |
12432 NULL); | |
12433 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopyTextureCHROMIUM"); | |
12434 if (error != GL_NO_ERROR) { | |
12435 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); | |
12436 return; | |
12437 } | |
12438 | |
12439 texture_manager()->SetLevelInfo( | |
12440 dest_texture_ref, GL_TEXTURE_2D, 0, source_internal_format, | |
12441 source_width, source_height, 1, 0, source_internal_format, | |
12442 source_type, gfx::Rect(source_width, source_height)); | |
12443 } else { | |
12444 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, | |
12445 true); | |
12446 } | |
12447 | |
12448 ScopedModifyPixels modify(dest_texture_ref); | |
12449 | |
12450 // Try using GLImage::CopyTexImage when possible. | |
12451 if (image) { | |
12452 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(0, 0), | |
12453 gfx::Rect(0, 0, source_width, source_height))) { | |
12454 return; | |
12455 } | |
12456 } | |
12457 | |
12458 TRACE_EVENT0( | |
12459 "gpu", | |
12460 "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM, fallback"); | |
12461 | |
12462 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); | |
12463 | |
12464 // As a fallback, copy into a non-compressed GL_RGBA texture. | |
12465 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopyTextureCHROMIUM"); | |
12466 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, source_width, source_height, | |
12467 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | |
12468 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedCopyTextureCHROMIUM"); | |
12469 if (error != GL_NO_ERROR) { | |
12470 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); | |
12471 return; | |
12472 } | |
12473 | |
12474 texture_manager()->SetLevelInfo( | |
12475 dest_texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, source_width, | |
12476 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
12477 gfx::Rect(source_width, source_height)); | |
12478 | |
12479 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | |
12480 // before presenting. | |
12481 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { | |
12482 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | |
12483 // instead of using kIdentityMatrix crbug.com/226218. | |
12484 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | |
12485 this, source_texture->target(), source_texture->service_id(), | |
12486 dest_texture->service_id(), source_width, source_height, | |
12487 unpack_flip_y_, unpack_premultiply_alpha_, | |
12488 unpack_unpremultiply_alpha_, kIdentityMatrix); | |
12489 } else { | |
12490 copy_texture_CHROMIUM_->DoCopyTexture( | |
12491 this, source_texture->target(), source_texture->service_id(), | |
12492 source_internal_format, dest_texture->service_id(), GL_RGBA, | |
12493 source_width, source_height, unpack_flip_y_, | |
12494 unpack_premultiply_alpha_, unpack_unpremultiply_alpha_); | |
12495 } | |
12496 | |
12497 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); | |
12498 } | |
12499 | |
12231 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 12500 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
12232 switch (internalformat) { | 12501 switch (internalformat) { |
12233 case GL_RGB565: | 12502 case GL_RGB565: |
12234 return GL_UNSIGNED_SHORT_5_6_5; | 12503 return GL_UNSIGNED_SHORT_5_6_5; |
12235 case GL_RGBA4: | 12504 case GL_RGBA4: |
12236 return GL_UNSIGNED_SHORT_4_4_4_4; | 12505 return GL_UNSIGNED_SHORT_4_4_4_4; |
12237 case GL_RGB5_A1: | 12506 case GL_RGB5_A1: |
12238 return GL_UNSIGNED_SHORT_5_5_5_1; | 12507 return GL_UNSIGNED_SHORT_5_5_5_1; |
12239 case GL_RGB8_OES: | 12508 case GL_RGB8_OES: |
12240 return GL_UNSIGNED_BYTE; | 12509 return GL_UNSIGNED_BYTE; |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13426 } | 13695 } |
13427 } | 13696 } |
13428 | 13697 |
13429 // Include the auto-generated part of this file. We split this because it means | 13698 // Include the auto-generated part of this file. We split this because it means |
13430 // we can easily edit the non-auto generated parts right here in this file | 13699 // we can easily edit the non-auto generated parts right here in this file |
13431 // instead of having to edit some template or the code generator. | 13700 // instead of having to edit some template or the code generator. |
13432 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 13701 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
13433 | 13702 |
13434 } // namespace gles2 | 13703 } // namespace gles2 |
13435 } // namespace gpu | 13704 } // namespace gpu |
OLD | NEW |