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