| 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 13246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13257 return; | 13257 return; |
| 13258 } | 13258 } |
| 13259 | 13259 |
| 13260 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { | 13260 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { |
| 13261 LOCAL_SET_GL_ERROR( | 13261 LOCAL_SET_GL_ERROR( |
| 13262 GL_INVALID_OPERATION, | 13262 GL_INVALID_OPERATION, |
| 13263 func_name, "source and destination textures are the same"); | 13263 func_name, "source and destination textures are the same"); |
| 13264 return; | 13264 return; |
| 13265 } | 13265 } |
| 13266 | 13266 |
| 13267 // For 3D textures, we always clear the entire texture. See the code in | 13267 ScopedResolvedFrameBufferBinder binder(this, false, true); |
| 13268 // TextureManager::ValidateAndDoTexSubImage for TexSubImage3D. | 13268 gfx::Size size = GetBoundReadFrameBufferSize(); |
| 13269 GLint copyX = 0; |
| 13270 GLint copyY = 0; |
| 13271 GLint copyWidth = 0; |
| 13272 GLint copyHeight = 0; |
| 13273 Clip(x, width, size.width(), ©X, ©Width); |
| 13274 Clip(y, height, size.height(), ©Y, ©Height); |
| 13275 |
| 13276 GLint dx = copyX - x; |
| 13277 GLint dy = copyY - y; |
| 13278 GLint destX = xoffset + dx; |
| 13279 GLint destY = yoffset + dy; |
| 13280 // For 3D textures, we always clear the entire texture to 0 if it is not |
| 13281 // cleared. See the code in TextureManager::ValidateAndDoTexSubImage |
| 13282 // for TexSubImage3D. |
| 13269 if (!texture->IsLevelCleared(target, level)) { | 13283 if (!texture->IsLevelCleared(target, level)) { |
| 13270 texture_manager()->ClearTextureLevel(this, texture_ref, target, level); | 13284 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, |
| 13285 level)) { |
| 13286 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); |
| 13287 return; |
| 13288 } |
| 13271 DCHECK(texture->IsLevelCleared(target, level)); | 13289 DCHECK(texture->IsLevelCleared(target, level)); |
| 13272 } | 13290 } |
| 13273 | 13291 |
| 13274 // TODO(yunchao): Follow-up CLs are necessary. For instance: | 13292 // TODO(yunchao): Follow-up CLs are necessary. For instance: |
| 13275 // 1. emulation of unsized formats in core profile | 13293 // 1. emulation of unsized formats in core profile |
| 13276 // 2. out-of-bounds reading, etc. | |
| 13277 | 13294 |
| 13278 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, | 13295 if (copyHeight > 0 && copyWidth > 0) { |
| 13279 height); | 13296 glCopyTexSubImage3D(target, level, destX, destY, zoffset, |
| 13297 copyX, copyY, copyWidth, copyHeight); |
| 13298 } |
| 13280 | 13299 |
| 13281 // This may be a slow command. Exit command processing to allow for | 13300 // This may be a slow command. Exit command processing to allow for |
| 13282 // context preemption and GPU watchdog checks. | 13301 // context preemption and GPU watchdog checks. |
| 13283 ExitCommandProcessingEarly(); | 13302 ExitCommandProcessingEarly(); |
| 13284 } | 13303 } |
| 13285 | 13304 |
| 13286 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, | 13305 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, |
| 13287 const void* cmd_data) { | 13306 const void* cmd_data) { |
| 13288 const gles2::cmds::TexSubImage2D& c = | 13307 const gles2::cmds::TexSubImage2D& c = |
| 13289 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); | 13308 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); |
| (...skipping 4453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17743 } | 17762 } |
| 17744 | 17763 |
| 17745 // Include the auto-generated part of this file. We split this because it means | 17764 // Include the auto-generated part of this file. We split this because it means |
| 17746 // we can easily edit the non-auto generated parts right here in this file | 17765 // we can easily edit the non-auto generated parts right here in this file |
| 17747 // instead of having to edit some template or the code generator. | 17766 // instead of having to edit some template or the code generator. |
| 17748 #include "base/macros.h" | 17767 #include "base/macros.h" |
| 17749 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17768 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17750 | 17769 |
| 17751 } // namespace gles2 | 17770 } // namespace gles2 |
| 17752 } // namespace gpu | 17771 } // namespace gpu |
| OLD | NEW |