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 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1775 Texture* texture); | 1775 Texture* texture); |
1776 bool ValidateCopyTextureCHROMIUM(const char* function_name, | 1776 bool ValidateCopyTextureCHROMIUM(const char* function_name, |
1777 GLenum target, | 1777 GLenum target, |
1778 TextureRef* source_texture_ref, | 1778 TextureRef* source_texture_ref, |
1779 TextureRef* dest_texture_ref, | 1779 TextureRef* dest_texture_ref, |
1780 GLenum dest_internal_format); | 1780 GLenum dest_internal_format); |
1781 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, | 1781 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, |
1782 GLenum target, | 1782 GLenum target, |
1783 TextureRef* source_texture_ref, | 1783 TextureRef* source_texture_ref, |
1784 TextureRef* dest_texture_ref); | 1784 TextureRef* dest_texture_ref); |
1785 bool ValidateCompressedCopySubTextureDimensions( | |
reveman
2015/12/02 18:28:50
btw, do we still need this? we're not using copysu
christiank
2015/12/03 12:58:00
No we don't need it at the moment. I'll revert the
| |
1786 const char* function_name, | |
1787 GLenum target, GLint xoffset, GLint yoffset, | |
1788 GLsizei width, GLsizei height, GLenum format, | |
1789 Texture* texture); | |
1785 | 1790 |
1786 void RenderWarning(const char* filename, int line, const std::string& msg); | 1791 void RenderWarning(const char* filename, int line, const std::string& msg); |
1787 void PerformanceWarning( | 1792 void PerformanceWarning( |
1788 const char* filename, int line, const std::string& msg); | 1793 const char* filename, int line, const std::string& msg); |
1789 | 1794 |
1790 const FeatureInfo::FeatureFlags& features() const { | 1795 const FeatureInfo::FeatureFlags& features() const { |
1791 return feature_info_->feature_flags(); | 1796 return feature_info_->feature_flags(); |
1792 } | 1797 } |
1793 | 1798 |
1794 const FeatureInfo::Workarounds& workarounds() const { | 1799 const FeatureInfo::Workarounds& workarounds() const { |
(...skipping 10930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12725 | 12730 |
12726 if (!valid_format) { | 12731 if (!valid_format) { |
12727 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 12732 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
12728 "invalid internal format"); | 12733 "invalid internal format"); |
12729 return false; | 12734 return false; |
12730 } | 12735 } |
12731 | 12736 |
12732 return true; | 12737 return true; |
12733 } | 12738 } |
12734 | 12739 |
12740 bool GLES2DecoderImpl::ValidateCompressedCopySubTextureDimensions( | |
12741 const char* function_name, | |
12742 GLenum target, GLint xoffset, GLint yoffset, | |
12743 GLsizei width, GLsizei height, GLenum format, | |
12744 Texture* texture) { | |
12745 if (xoffset < 0 || yoffset < 0) { | |
12746 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "x/y offset < 0"); | |
12747 return false; | |
12748 } | |
12749 | |
12750 switch (format) { | |
12751 case GL_ATC_RGB_AMD: | |
12752 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | |
12753 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | |
12754 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | |
12755 case GL_ETC1_RGB8_OES: { | |
12756 const int kBlockWidth = 4; | |
12757 const int kBlockHeight = 4; | |
12758 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | |
12759 LOCAL_SET_GL_ERROR( | |
12760 GL_INVALID_OPERATION, function_name, | |
12761 "xoffset or yoffset not multiple of 4"); | |
12762 return false; | |
12763 } | |
12764 GLsizei tex_width = 0; | |
12765 GLsizei tex_height = 0; | |
12766 if (!texture->GetLevelSize(target, 0, &tex_width, &tex_height, nullptr) || | |
12767 width - xoffset > tex_width || | |
12768 height - yoffset > tex_height) { | |
12769 LOCAL_SET_GL_ERROR( | |
12770 GL_INVALID_OPERATION, function_name, "dimensions out of range"); | |
12771 return false; | |
12772 } | |
12773 return ValidateCompressedTexDimensions( | |
12774 function_name, target, 0, width, height, 1, format); | |
12775 } | |
12776 default: | |
12777 return false; | |
12778 } | |
12779 } | |
12780 | |
12735 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( | 12781 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
12736 GLenum target, | 12782 GLenum target, |
12737 GLuint source_id, | 12783 GLuint source_id, |
12738 GLuint dest_id, | 12784 GLuint dest_id, |
12739 GLenum internal_format, | 12785 GLenum internal_format, |
12740 GLenum dest_type, | 12786 GLenum dest_type, |
12741 GLboolean unpack_flip_y, | 12787 GLboolean unpack_flip_y, |
12742 GLboolean unpack_premultiply_alpha, | 12788 GLboolean unpack_premultiply_alpha, |
12743 GLboolean unpack_unmultiply_alpha) { | 12789 GLboolean unpack_unmultiply_alpha) { |
12744 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); | 12790 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13284 "destination texture bad dimensions."); | 13330 "destination texture bad dimensions."); |
13285 return; | 13331 return; |
13286 } | 13332 } |
13287 | 13333 |
13288 if (!ValidateCompressedCopyTextureCHROMIUM( | 13334 if (!ValidateCompressedCopyTextureCHROMIUM( |
13289 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref, | 13335 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref, |
13290 dest_texture_ref)) { | 13336 dest_texture_ref)) { |
13291 return; | 13337 return; |
13292 } | 13338 } |
13293 | 13339 |
13294 if (!ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM", | 13340 if (!ValidateCompressedCopySubTextureDimensions( |
13295 source_texture->target(), 0, x, y, 0, | 13341 "glCompressedCopySubTextureCHROMIUM", |
13296 width, height, 1, | 13342 source_texture->target(), x, y, |
13297 source_internal_format, | 13343 width, height, |
13298 source_texture) || | 13344 source_internal_format, |
13299 !ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM", | 13345 source_texture) || |
13300 dest_texture->target(), 0, | 13346 !ValidateCompressedCopySubTextureDimensions( |
13301 xoffset, yoffset, 0, width, height, 1, | 13347 "glCompressedCopySubTextureCHROMIUM", |
13302 dest_internal_format, | 13348 dest_texture->target(), |
13303 dest_texture)) { | 13349 xoffset, yoffset, width, height, |
13350 dest_internal_format, | |
13351 dest_texture)) { | |
13304 return; | 13352 return; |
13305 } | 13353 } |
13306 | 13354 |
13307 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is | 13355 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is |
13308 // needed because it takes 10s of milliseconds to initialize. | 13356 // needed because it takes 10s of milliseconds to initialize. |
13309 if (!copy_texture_CHROMIUM_.get()) { | 13357 if (!copy_texture_CHROMIUM_.get()) { |
13310 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopySubTextureCHROMIUM"); | 13358 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedCopySubTextureCHROMIUM"); |
13311 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 13359 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
13312 copy_texture_CHROMIUM_->Initialize(this); | 13360 copy_texture_CHROMIUM_->Initialize(this); |
13313 RestoreCurrentFramebufferBindings(); | 13361 RestoreCurrentFramebufferBindings(); |
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15322 return error::kNoError; | 15370 return error::kNoError; |
15323 } | 15371 } |
15324 | 15372 |
15325 // Include the auto-generated part of this file. We split this because it means | 15373 // Include the auto-generated part of this file. We split this because it means |
15326 // we can easily edit the non-auto generated parts right here in this file | 15374 // we can easily edit the non-auto generated parts right here in this file |
15327 // instead of having to edit some template or the code generator. | 15375 // instead of having to edit some template or the code generator. |
15328 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15376 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15329 | 15377 |
15330 } // namespace gles2 | 15378 } // namespace gles2 |
15331 } // namespace gpu | 15379 } // namespace gpu |
OLD | NEW |