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 8034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8045 base::CheckedNumeric<GLint> src_width_temp = srcX1; | 8045 base::CheckedNumeric<GLint> src_width_temp = srcX1; |
8046 src_width_temp -= srcX0; | 8046 src_width_temp -= srcX0; |
8047 base::CheckedNumeric<GLint> src_height_temp = srcY1; | 8047 base::CheckedNumeric<GLint> src_height_temp = srcY1; |
8048 src_height_temp -= srcY0; | 8048 src_height_temp -= srcY0; |
8049 GLuint src_width = 0, src_height = 0; | 8049 GLuint src_width = 0, src_height = 0; |
8050 if (!src_width_temp.IsValid() || !src_height_temp.IsValid()) { | 8050 if (!src_width_temp.IsValid() || !src_height_temp.IsValid()) { |
8051 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 8051 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
8052 "the width or height of src region overflow"); | 8052 "the width or height of src region overflow"); |
8053 return; | 8053 return; |
8054 } | 8054 } |
8055 src_width = std::abs(src_width_temp.ValueOrDefault(0)); | 8055 if (!src_width_temp.Abs().AssignIfValid(&src_width)) |
8056 src_height = std::abs(src_height_temp.ValueOrDefault(0)); | 8056 src_width = 0; |
| 8057 if (!src_height_temp.Abs().AssignIfValid(&src_height)) |
| 8058 src_height = 0; |
8057 | 8059 |
8058 gfx::Rect src_region(src_x, src_y, src_width, src_height); | 8060 gfx::Rect src_region(src_x, src_y, src_width, src_height); |
8059 if (!src_bounds.Contains(src_region) && | 8061 if (!src_bounds.Contains(src_region) && |
8060 (src_width != 0) && (src_height != 0)) { | 8062 (src_width != 0) && (src_height != 0)) { |
8061 // If pixels lying outside the read framebuffer, adjust src region | 8063 // If pixels lying outside the read framebuffer, adjust src region |
8062 // and dst region to appropriate in-bounds regions respectively. | 8064 // and dst region to appropriate in-bounds regions respectively. |
8063 src_bounds.Intersect(src_region); | 8065 src_bounds.Intersect(src_region); |
8064 GLuint src_real_width = src_bounds.width(); | 8066 GLuint src_real_width = src_bounds.width(); |
8065 GLuint src_real_height = src_bounds.height(); | 8067 GLuint src_real_height = src_bounds.height(); |
8066 GLuint xoffset = src_bounds.x() - src_x; | 8068 GLuint xoffset = src_bounds.x() - src_x; |
(...skipping 14 matching lines...) Expand all Loading... |
8081 base::CheckedNumeric<GLint> dst_width_temp = dstX1; | 8083 base::CheckedNumeric<GLint> dst_width_temp = dstX1; |
8082 dst_width_temp -= dstX0; | 8084 dst_width_temp -= dstX0; |
8083 base::CheckedNumeric<GLint> dst_height_temp = dstY1; | 8085 base::CheckedNumeric<GLint> dst_height_temp = dstY1; |
8084 dst_height_temp -= dstY0; | 8086 dst_height_temp -= dstY0; |
8085 GLuint dst_width = 0, dst_height = 0; | 8087 GLuint dst_width = 0, dst_height = 0; |
8086 if (!dst_width_temp.IsValid() || !dst_height_temp.IsValid()) { | 8088 if (!dst_width_temp.IsValid() || !dst_height_temp.IsValid()) { |
8087 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 8089 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
8088 "the width or height of dst region overflow"); | 8090 "the width or height of dst region overflow"); |
8089 return; | 8091 return; |
8090 } | 8092 } |
8091 dst_width = std::abs(dst_width_temp.ValueOrDefault(0)); | 8093 if (!dst_width_temp.Abs().AssignIfValid(&dst_width)) |
8092 dst_height = std::abs(dst_height_temp.ValueOrDefault(0)); | 8094 dst_width = 0; |
| 8095 if (!dst_height_temp.Abs().AssignIfValid(&dst_height)) |
| 8096 dst_height = 0; |
8093 | 8097 |
8094 GLfloat dst_mapping_width = | 8098 GLfloat dst_mapping_width = |
8095 static_cast<GLfloat>(src_real_width) * dst_width / src_width; | 8099 static_cast<GLfloat>(src_real_width) * dst_width / src_width; |
8096 GLfloat dst_mapping_height = | 8100 GLfloat dst_mapping_height = |
8097 static_cast<GLfloat>(src_real_height) * dst_height / src_height; | 8101 static_cast<GLfloat>(src_real_height) * dst_height / src_height; |
8098 GLfloat dst_mapping_xoffset = | 8102 GLfloat dst_mapping_xoffset = |
8099 static_cast<GLfloat>(xoffset) * dst_width / src_width; | 8103 static_cast<GLfloat>(xoffset) * dst_width / src_width; |
8100 GLfloat dst_mapping_yoffset = | 8104 GLfloat dst_mapping_yoffset = |
8101 static_cast<GLfloat>(yoffset) * dst_height / src_height; | 8105 static_cast<GLfloat>(yoffset) * dst_height / src_height; |
8102 | 8106 |
(...skipping 10797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18900 } | 18904 } |
18901 | 18905 |
18902 // Include the auto-generated part of this file. We split this because it means | 18906 // Include the auto-generated part of this file. We split this because it means |
18903 // we can easily edit the non-auto generated parts right here in this file | 18907 // we can easily edit the non-auto generated parts right here in this file |
18904 // instead of having to edit some template or the code generator. | 18908 // instead of having to edit some template or the code generator. |
18905 #include "base/macros.h" | 18909 #include "base/macros.h" |
18906 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18910 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
18907 | 18911 |
18908 } // namespace gles2 | 18912 } // namespace gles2 |
18909 } // namespace gpu | 18913 } // namespace gpu |
OLD | NEW |