Chromium Code Reviews| 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 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3059 GLint num_rows = ComputeNumRowsThatFitInBuffer( | 3060 GLint num_rows = ComputeNumRowsThatFitInBuffer( |
| 3060 buffer_padded_row_size, unpadded_row_size, buffer->size(), height); | 3061 buffer_padded_row_size, unpadded_row_size, buffer->size(), height); |
| 3061 num_rows = std::min(num_rows, height); | 3062 num_rows = std::min(num_rows, height); |
| 3062 CopyRectToBuffer( | 3063 CopyRectToBuffer( |
| 3063 source, num_rows, unpadded_row_size, pixels_padded_row_size, | 3064 source, num_rows, unpadded_row_size, pixels_padded_row_size, |
| 3064 buffer->address(), buffer_padded_row_size); | 3065 buffer->address(), buffer_padded_row_size); |
| 3065 helper_->TexSubImage2D( | 3066 helper_->TexSubImage2D( |
| 3066 target, level, xoffset, yoffset, width, num_rows, format, type, | 3067 target, level, xoffset, yoffset, width, num_rows, format, type, |
| 3067 buffer->shm_id(), buffer->offset(), internal); | 3068 buffer->shm_id(), buffer->offset(), internal); |
| 3068 buffer->Release(); | 3069 buffer->Release(); |
| 3069 yoffset += num_rows; | 3070 base::CheckedNumeric<GLint> updated_yoffset = yoffset; |
| 3071 updated_yoffset += num_rows; | |
| 3072 yoffset = updated_yoffset.ValueOrDefault(std::numeric_limits<int>::max()); | |
|
Zhenyao Mo
2016/09/07 02:15:16
Can we generate an INVALID_VALUE instead?
xidachen
2016/09/07 12:23:00
I used GL_INVALID_VALUE. So do we have checks some
| |
| 3070 source += num_rows * pixels_padded_row_size; | 3073 source += num_rows * pixels_padded_row_size; |
| 3071 height -= num_rows; | 3074 height -= num_rows; |
| 3072 } | 3075 } |
| 3073 } | 3076 } |
| 3074 | 3077 |
| 3075 void GLES2Implementation::TexSubImage3DImpl(GLenum target, | 3078 void GLES2Implementation::TexSubImage3DImpl(GLenum target, |
| 3076 GLint level, | 3079 GLint level, |
| 3077 GLint xoffset, | 3080 GLint xoffset, |
| 3078 GLint yoffset, | 3081 GLint yoffset, |
| 3079 GLsizei zoffset, | 3082 GLsizei zoffset, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3151 source + ii * image_size_src, my_height, unpadded_row_size, | 3154 source + ii * image_size_src, my_height, unpadded_row_size, |
| 3152 pixels_padded_row_size, buffer_pointer + ii * image_size_dst, | 3155 pixels_padded_row_size, buffer_pointer + ii * image_size_dst, |
| 3153 buffer_padded_row_size); | 3156 buffer_padded_row_size); |
| 3154 } | 3157 } |
| 3155 } else { | 3158 } else { |
| 3156 CopyRectToBuffer( | 3159 CopyRectToBuffer( |
| 3157 source, my_height, unpadded_row_size, pixels_padded_row_size, | 3160 source, my_height, unpadded_row_size, pixels_padded_row_size, |
| 3158 buffer->address(), buffer_padded_row_size); | 3161 buffer->address(), buffer_padded_row_size); |
| 3159 } | 3162 } |
| 3160 helper_->TexSubImage3D( | 3163 helper_->TexSubImage3D( |
| 3161 target, level, xoffset, yoffset + row_index, zoffset + depth_index, | 3164 target, level, xoffset, yoffset + row_index, zoffset + depth_index, |
|
Zhenyao Mo
2016/09/07 02:15:16
Here, should we worry about overflow also?
xidachen
2016/09/07 12:23:00
Ah, I totally missed that. Added in the new patch.
| |
| 3162 width, my_height, my_depth, | 3165 width, my_height, my_depth, |
| 3163 format, type, buffer->shm_id(), buffer->offset(), internal); | 3166 format, type, buffer->shm_id(), buffer->offset(), internal); |
| 3164 buffer->Release(); | 3167 buffer->Release(); |
| 3165 | 3168 |
| 3166 total_rows -= num_rows; | 3169 total_rows -= num_rows; |
| 3167 if (total_rows > 0) { | 3170 if (total_rows > 0) { |
| 3168 GLint num_image_paddings; | 3171 GLint num_image_paddings; |
| 3169 if (num_images > 0) { | 3172 if (num_images > 0) { |
| 3170 DCHECK_EQ(row_index, 0); | 3173 DCHECK_EQ(row_index, 0); |
| 3171 depth_index += num_images; | 3174 depth_index += num_images; |
| (...skipping 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6895 cached_extensions_.clear(); | 6898 cached_extensions_.clear(); |
| 6896 } | 6899 } |
| 6897 | 6900 |
| 6898 // Include the auto-generated part of this file. We split this because it means | 6901 // 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 | 6902 // 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. | 6903 // instead of having to edit some template or the code generator. |
| 6901 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6904 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 6902 | 6905 |
| 6903 } // namespace gles2 | 6906 } // namespace gles2 |
| 6904 } // namespace gpu | 6907 } // namespace gpu |
| OLD | NEW |