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(GL_INVALID_VALUE); | |
|
Zhenyao Mo
2016/09/07 17:05:33
You misunderstood me.
It should be
if (!updated_
xidachen
2016/09/07 17:36:39
Done.
| |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3150 CopyRectToBuffer( | 3153 CopyRectToBuffer( |
| 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 } |
| 3163 base::CheckedNumeric<GLint> updated_yoffset = yoffset; | |
| 3164 base::CheckedNumeric<GLint> updated_zoffset = zoffset; | |
| 3165 updated_yoffset += row_index; | |
| 3166 updated_zoffset += depth_index; | |
| 3160 helper_->TexSubImage3D( | 3167 helper_->TexSubImage3D( |
| 3161 target, level, xoffset, yoffset + row_index, zoffset + depth_index, | 3168 target, level, xoffset, |
| 3169 updated_yoffset.ValueOrDefault(GL_INVALID_VALUE), | |
| 3170 updated_zoffset.ValueOrDefault(GL_INVALID_VALUE), | |
|
Zhenyao Mo
2016/09/07 17:05:34
Same here.
xidachen
2016/09/07 17:36:38
Done.
| |
| 3162 width, my_height, my_depth, | 3171 width, my_height, my_depth, |
| 3163 format, type, buffer->shm_id(), buffer->offset(), internal); | 3172 format, type, buffer->shm_id(), buffer->offset(), internal); |
| 3164 buffer->Release(); | 3173 buffer->Release(); |
| 3165 | 3174 |
| 3166 total_rows -= num_rows; | 3175 total_rows -= num_rows; |
| 3167 if (total_rows > 0) { | 3176 if (total_rows > 0) { |
| 3168 GLint num_image_paddings; | 3177 GLint num_image_paddings; |
| 3169 if (num_images > 0) { | 3178 if (num_images > 0) { |
| 3170 DCHECK_EQ(row_index, 0); | 3179 DCHECK_EQ(row_index, 0); |
| 3171 depth_index += num_images; | 3180 depth_index += num_images; |
| (...skipping 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6895 cached_extensions_.clear(); | 6904 cached_extensions_.clear(); |
| 6896 } | 6905 } |
| 6897 | 6906 |
| 6898 // Include the auto-generated part of this file. We split this because it means | 6907 // 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 | 6908 // 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. | 6909 // instead of having to edit some template or the code generator. |
| 6901 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 6910 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 6902 | 6911 |
| 6903 } // namespace gles2 | 6912 } // namespace gles2 |
| 6904 } // namespace gpu | 6913 } // namespace gpu |
| OLD | NEW |