| 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 <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 6927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6938 } | 6938 } |
| 6939 typedef cmds::ReadPixels::Result Result; | 6939 typedef cmds::ReadPixels::Result Result; |
| 6940 uint32 pixels_size; | 6940 uint32 pixels_size; |
| 6941 if (!GLES2Util::ComputeImageDataSizes( | 6941 if (!GLES2Util::ComputeImageDataSizes( |
| 6942 width, height, format, type, state_.pack_alignment, &pixels_size, | 6942 width, height, format, type, state_.pack_alignment, &pixels_size, |
| 6943 NULL, NULL)) { | 6943 NULL, NULL)) { |
| 6944 return error::kOutOfBounds; | 6944 return error::kOutOfBounds; |
| 6945 } | 6945 } |
| 6946 void* pixels = GetSharedMemoryAs<void*>( | 6946 void* pixels = GetSharedMemoryAs<void*>( |
| 6947 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); | 6947 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); |
| 6948 Result* result = GetSharedMemoryAs<Result*>( | 6948 if (!pixels) { |
| 6949 return error::kOutOfBounds; |
| 6950 } |
| 6951 Result* result = NULL; |
| 6952 if (c.result_shm_id != 0) { |
| 6953 result = GetSharedMemoryAs<Result*>( |
| 6949 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 6954 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 6950 if (!pixels || !result) { | 6955 if (!result) { |
| 6951 return error::kOutOfBounds; | 6956 return error::kOutOfBounds; |
| 6957 } |
| 6952 } | 6958 } |
| 6953 | 6959 |
| 6954 if (!validators_->read_pixel_format.IsValid(format)) { | 6960 if (!validators_->read_pixel_format.IsValid(format)) { |
| 6955 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format"); | 6961 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format"); |
| 6956 return error::kNoError; | 6962 return error::kNoError; |
| 6957 } | 6963 } |
| 6958 if (!validators_->pixel_type.IsValid(type)) { | 6964 if (!validators_->pixel_type.IsValid(type)) { |
| 6959 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); | 6965 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); |
| 6960 return error::kNoError; | 6966 return error::kNoError; |
| 6961 } | 6967 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7022 glReadPixels( | 7028 glReadPixels( |
| 7023 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); | 7029 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); |
| 7024 } | 7030 } |
| 7025 dst += padded_row_size; | 7031 dst += padded_row_size; |
| 7026 } | 7032 } |
| 7027 } else { | 7033 } else { |
| 7028 glReadPixels(x, y, width, height, format, type, pixels); | 7034 glReadPixels(x, y, width, height, format, type, pixels); |
| 7029 } | 7035 } |
| 7030 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels"); | 7036 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels"); |
| 7031 if (error == GL_NO_ERROR) { | 7037 if (error == GL_NO_ERROR) { |
| 7032 *result = true; | 7038 if (result != NULL) { |
| 7039 *result = true; |
| 7040 } |
| 7033 | 7041 |
| 7034 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 7042 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
| 7035 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 7043 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| 7036 if ((channels_exist & 0x0008) == 0 && | 7044 if ((channels_exist & 0x0008) == 0 && |
| 7037 workarounds().clear_alpha_in_readpixels) { | 7045 workarounds().clear_alpha_in_readpixels) { |
| 7038 // Set the alpha to 255 because some drivers are buggy in this regard. | 7046 // Set the alpha to 255 because some drivers are buggy in this regard. |
| 7039 uint32 temp_size; | 7047 uint32 temp_size; |
| 7040 | 7048 |
| 7041 uint32 unpadded_row_size; | 7049 uint32 unpadded_row_size; |
| 7042 uint32 padded_row_size; | 7050 uint32 padded_row_size; |
| (...skipping 3410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10453 return error::kNoError; | 10461 return error::kNoError; |
| 10454 } | 10462 } |
| 10455 | 10463 |
| 10456 // Include the auto-generated part of this file. We split this because it means | 10464 // Include the auto-generated part of this file. We split this because it means |
| 10457 // we can easily edit the non-auto generated parts right here in this file | 10465 // we can easily edit the non-auto generated parts right here in this file |
| 10458 // instead of having to edit some template or the code generator. | 10466 // instead of having to edit some template or the code generator. |
| 10459 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10467 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10460 | 10468 |
| 10461 } // namespace gles2 | 10469 } // namespace gles2 |
| 10462 } // namespace gpu | 10470 } // namespace gpu |
| OLD | NEW |