| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 8006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8017 base::CheckedNumeric<GLint> src_width_temp = srcX1; | 8017 base::CheckedNumeric<GLint> src_width_temp = srcX1; |
| 8018 src_width_temp -= srcX0; | 8018 src_width_temp -= srcX0; |
| 8019 base::CheckedNumeric<GLint> src_height_temp = srcY1; | 8019 base::CheckedNumeric<GLint> src_height_temp = srcY1; |
| 8020 src_height_temp -= srcY0; | 8020 src_height_temp -= srcY0; |
| 8021 GLuint src_width = 0, src_height = 0; | 8021 GLuint src_width = 0, src_height = 0; |
| 8022 if (!src_width_temp.IsValid() || !src_height_temp.IsValid()) { | 8022 if (!src_width_temp.IsValid() || !src_height_temp.IsValid()) { |
| 8023 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 8023 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 8024 "the width or height of src region overflow"); | 8024 "the width or height of src region overflow"); |
| 8025 return; | 8025 return; |
| 8026 } | 8026 } |
| 8027 src_width = std::abs(src_width_temp.ValueOrDefault(0)); | 8027 if (!src_width_temp.Abs().AssignIfValid(&src_width)) |
| 8028 src_height = std::abs(src_height_temp.ValueOrDefault(0)); | 8028 src_width = 0; |
| 8029 if (!src_height_temp.Abs().AssignIfValid(&src_height)) |
| 8030 src_height = 0; |
| 8029 | 8031 |
| 8030 gfx::Rect src_region(src_x, src_y, src_width, src_height); | 8032 gfx::Rect src_region(src_x, src_y, src_width, src_height); |
| 8031 if (!src_bounds.Contains(src_region) && | 8033 if (!src_bounds.Contains(src_region) && |
| 8032 (src_width != 0) && (src_height != 0)) { | 8034 (src_width != 0) && (src_height != 0)) { |
| 8033 // If pixels lying outside the read framebuffer, adjust src region | 8035 // If pixels lying outside the read framebuffer, adjust src region |
| 8034 // and dst region to appropriate in-bounds regions respectively. | 8036 // and dst region to appropriate in-bounds regions respectively. |
| 8035 src_bounds.Intersect(src_region); | 8037 src_bounds.Intersect(src_region); |
| 8036 GLuint src_real_width = src_bounds.width(); | 8038 GLuint src_real_width = src_bounds.width(); |
| 8037 GLuint src_real_height = src_bounds.height(); | 8039 GLuint src_real_height = src_bounds.height(); |
| 8038 GLuint xoffset = src_bounds.x() - src_x; | 8040 GLuint xoffset = src_bounds.x() - src_x; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8053 base::CheckedNumeric<GLint> dst_width_temp = dstX1; | 8055 base::CheckedNumeric<GLint> dst_width_temp = dstX1; |
| 8054 dst_width_temp -= dstX0; | 8056 dst_width_temp -= dstX0; |
| 8055 base::CheckedNumeric<GLint> dst_height_temp = dstY1; | 8057 base::CheckedNumeric<GLint> dst_height_temp = dstY1; |
| 8056 dst_height_temp -= dstY0; | 8058 dst_height_temp -= dstY0; |
| 8057 GLuint dst_width = 0, dst_height = 0; | 8059 GLuint dst_width = 0, dst_height = 0; |
| 8058 if (!dst_width_temp.IsValid() || !dst_height_temp.IsValid()) { | 8060 if (!dst_width_temp.IsValid() || !dst_height_temp.IsValid()) { |
| 8059 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 8061 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 8060 "the width or height of dst region overflow"); | 8062 "the width or height of dst region overflow"); |
| 8061 return; | 8063 return; |
| 8062 } | 8064 } |
| 8063 dst_width = std::abs(dst_width_temp.ValueOrDefault(0)); | 8065 if (!dst_width_temp.Abs().AssignIfValid(&dst_width)) |
| 8064 dst_height = std::abs(dst_height_temp.ValueOrDefault(0)); | 8066 dst_width = 0; |
| 8067 if (!dst_height_temp.Abs().AssignIfValid(&dst_height)) |
| 8068 dst_height = 0; |
| 8065 | 8069 |
| 8066 GLfloat dst_mapping_width = | 8070 GLfloat dst_mapping_width = |
| 8067 static_cast<GLfloat>(src_real_width) * dst_width / src_width; | 8071 static_cast<GLfloat>(src_real_width) * dst_width / src_width; |
| 8068 GLfloat dst_mapping_height = | 8072 GLfloat dst_mapping_height = |
| 8069 static_cast<GLfloat>(src_real_height) * dst_height / src_height; | 8073 static_cast<GLfloat>(src_real_height) * dst_height / src_height; |
| 8070 GLfloat dst_mapping_xoffset = | 8074 GLfloat dst_mapping_xoffset = |
| 8071 static_cast<GLfloat>(xoffset) * dst_width / src_width; | 8075 static_cast<GLfloat>(xoffset) * dst_width / src_width; |
| 8072 GLfloat dst_mapping_yoffset = | 8076 GLfloat dst_mapping_yoffset = |
| 8073 static_cast<GLfloat>(yoffset) * dst_height / src_height; | 8077 static_cast<GLfloat>(yoffset) * dst_height / src_height; |
| 8074 | 8078 |
| (...skipping 10797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18872 } | 18876 } |
| 18873 | 18877 |
| 18874 // Include the auto-generated part of this file. We split this because it means | 18878 // Include the auto-generated part of this file. We split this because it means |
| 18875 // we can easily edit the non-auto generated parts right here in this file | 18879 // we can easily edit the non-auto generated parts right here in this file |
| 18876 // instead of having to edit some template or the code generator. | 18880 // instead of having to edit some template or the code generator. |
| 18877 #include "base/macros.h" | 18881 #include "base/macros.h" |
| 18878 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18882 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18879 | 18883 |
| 18880 } // namespace gles2 | 18884 } // namespace gles2 |
| 18881 } // namespace gpu | 18885 } // namespace gpu |
| OLD | NEW |