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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
11 #include <GLES2/gl2extchromium.h> | 11 #include <GLES2/gl2extchromium.h> |
12 #include <GLES3/gl3.h> | 12 #include <GLES3/gl3.h> |
13 #include <stddef.h> | 13 #include <stddef.h> |
14 #include <stdint.h> | 14 #include <stdint.h> |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include <map> | 16 #include <map> |
17 #include <set> | 17 #include <set> |
18 #include <sstream> | 18 #include <sstream> |
19 #include <string> | 19 #include <string> |
20 #include "base/atomic_sequence_num.h" | 20 #include "base/atomic_sequence_num.h" |
21 #include "base/compiler_specific.h" | 21 #include "base/compiler_specific.h" |
22 #include "base/numerics/safe_math.h" | |
22 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
24 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
25 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
26 #include "base/trace_event/memory_allocator_dump.h" | 27 #include "base/trace_event/memory_allocator_dump.h" |
27 #include "base/trace_event/memory_dump_manager.h" | 28 #include "base/trace_event/memory_dump_manager.h" |
28 #include "base/trace_event/process_memory_dump.h" | 29 #include "base/trace_event/process_memory_dump.h" |
29 #include "base/trace_event/trace_event.h" | 30 #include "base/trace_event/trace_event.h" |
30 #include "gpu/command_buffer/client/buffer_tracker.h" | 31 #include "gpu/command_buffer/client/buffer_tracker.h" |
31 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 32 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
(...skipping 2836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2868 return; | 2869 return; |
2869 } | 2870 } |
2870 } else { | 2871 } else { |
2871 service_padded_row_size = padded_row_size; | 2872 service_padded_row_size = padded_row_size; |
2872 } | 2873 } |
2873 | 2874 |
2874 // advance pixels pointer past the skip rows and skip pixels | 2875 // advance pixels pointer past the skip rows and skip pixels |
2875 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; | 2876 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
2876 | 2877 |
2877 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); | 2878 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
2879 base::CheckedNumeric<GLint> checked_yoffset = yoffset; | |
Zhenyao Mo
2016/09/07 21:03:18
Let's do xoffset + width also.
xidachen
2016/09/07 23:05:19
Done.
| |
2880 checked_yoffset += height; | |
2881 if (!checked_yoffset.IsValid()) { | |
2882 SetGLError(GL_INVALID_VALUE, "TexSubImage2D", "yoffset + height overflows"); | |
2883 return; | |
2884 } | |
2878 TexSubImage2DImpl( | 2885 TexSubImage2DImpl( |
2879 target, level, xoffset, yoffset, width, height, format, type, | 2886 target, level, xoffset, yoffset, width, height, format, type, |
2880 unpadded_row_size, pixels, padded_row_size, GL_FALSE, &buffer, | 2887 unpadded_row_size, pixels, padded_row_size, GL_FALSE, &buffer, |
2881 service_padded_row_size); | 2888 service_padded_row_size); |
2882 CheckGLError(); | 2889 CheckGLError(); |
2883 } | 2890 } |
2884 | 2891 |
2885 void GLES2Implementation::TexSubImage3D( | 2892 void GLES2Implementation::TexSubImage3D( |
2886 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 2893 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
2887 GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, | 2894 GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2993 return; | 3000 return; |
2994 } | 3001 } |
2995 } else { | 3002 } else { |
2996 service_padded_row_size = padded_row_size; | 3003 service_padded_row_size = padded_row_size; |
2997 } | 3004 } |
2998 | 3005 |
2999 // advance pixels pointer past the skip images/rows/pixels | 3006 // advance pixels pointer past the skip images/rows/pixels |
3000 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; | 3007 pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
3001 | 3008 |
3002 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); | 3009 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
3010 base::CheckedNumeric<GLint> checked_yoffset = yoffset; | |
3011 checked_yoffset += height; | |
3012 if (!checked_yoffset.IsValid()) { | |
3013 SetGLError(GL_INVALID_VALUE, "TexSubImage3D", "yoffset + height overflows"); | |
3014 return; | |
3015 } | |
3016 base::CheckedNumeric<GLint> checked_zoffset = zoffset; | |
3017 checked_zoffset += depth; | |
3018 if (!checked_zoffset.IsValid()) { | |
3019 SetGLError(GL_INVALID_VALUE, "TexSubImage3D", "zoffset + depth overflows"); | |
3020 return; | |
3021 } | |
3003 TexSubImage3DImpl( | 3022 TexSubImage3DImpl( |
3004 target, level, xoffset, yoffset, zoffset, width, height, depth, | 3023 target, level, xoffset, yoffset, zoffset, width, height, depth, |
3005 format, type, unpadded_row_size, pixels, padded_row_size, GL_FALSE, | 3024 format, type, unpadded_row_size, pixels, padded_row_size, GL_FALSE, |
3006 &buffer, service_padded_row_size); | 3025 &buffer, service_padded_row_size); |
3007 CheckGLError(); | 3026 CheckGLError(); |
3008 } | 3027 } |
3009 | 3028 |
3010 static GLint ComputeNumRowsThatFitInBuffer(uint32_t padded_row_size, | 3029 static GLint ComputeNumRowsThatFitInBuffer(uint32_t padded_row_size, |
3011 uint32_t unpadded_row_size, | 3030 uint32_t unpadded_row_size, |
3012 unsigned int size, | 3031 unsigned int size, |
(...skipping 3882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6895 cached_extensions_.clear(); | 6914 cached_extensions_.clear(); |
6896 } | 6915 } |
6897 | 6916 |
6898 // Include the auto-generated part of this file. We split this because it means | 6917 // Include the auto-generated part of this file. We split this because it means |
6899 // we can easily edit the non-auto generated parts right here in this file | 6918 // we can easily edit the non-auto generated parts right here in this file |
6900 // instead of having to edit some template or the code generator. | 6919 // instead of having to edit some template or the code generator. |
6901 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6920 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
6902 | 6921 |
6903 } // namespace gles2 | 6922 } // namespace gles2 |
6904 } // namespace gpu | 6923 } // namespace gpu |
OLD | NEW |