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 #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 7532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7543 | 7543 |
| 7544 if (buffer != 0) { | 7544 if (buffer != 0) { |
| 7545 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); | 7545 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); |
| 7546 void* data; | 7546 void* data; |
| 7547 if (features().map_buffer_range) { | 7547 if (features().map_buffer_range) { |
| 7548 data = glMapBufferRange( | 7548 data = glMapBufferRange( |
| 7549 GL_PIXEL_PACK_BUFFER_ARB, 0, pixels_size, GL_MAP_READ_BIT); | 7549 GL_PIXEL_PACK_BUFFER_ARB, 0, pixels_size, GL_MAP_READ_BIT); |
| 7550 } else { | 7550 } else { |
| 7551 data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); | 7551 data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); |
| 7552 } | 7552 } |
| 7553 memcpy(pixels, data, pixels_size); | 7553 if (data) |
|
piman
2014/11/11 22:54:31
In which case should data be NULL?
Should we raise
| |
| 7554 memcpy(pixels, data, pixels_size); | |
| 7554 // GL_PIXEL_PACK_BUFFER_ARB is currently unused, so we don't | 7555 // GL_PIXEL_PACK_BUFFER_ARB is currently unused, so we don't |
| 7555 // have to restore the state. | 7556 // have to restore the state. |
| 7556 glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); | 7557 glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); |
| 7557 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); | 7558 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); |
| 7558 glDeleteBuffersARB(1, &buffer); | 7559 glDeleteBuffersARB(1, &buffer); |
| 7560 if (!data) | |
| 7561 return; | |
| 7559 } | 7562 } |
| 7560 | 7563 |
| 7561 if (result != NULL) { | 7564 if (result != NULL) { |
| 7562 *result = true; | 7565 *result = true; |
| 7563 } | 7566 } |
| 7564 | 7567 |
| 7565 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 7568 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
| 7566 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 7569 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| 7567 if ((channels_exist & 0x0008) == 0 && | 7570 if ((channels_exist & 0x0008) == 0 && |
| 7568 workarounds().clear_alpha_in_readpixels) { | 7571 workarounds().clear_alpha_in_readpixels) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7744 glReadPixels( | 7747 glReadPixels( |
| 7745 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); | 7748 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); |
| 7746 } | 7749 } |
| 7747 dst += padded_row_size; | 7750 dst += padded_row_size; |
| 7748 } | 7751 } |
| 7749 } else { | 7752 } else { |
| 7750 if (async && features().use_async_readpixels) { | 7753 if (async && features().use_async_readpixels) { |
| 7751 GLuint buffer = 0; | 7754 GLuint buffer = 0; |
| 7752 glGenBuffersARB(1, &buffer); | 7755 glGenBuffersARB(1, &buffer); |
| 7753 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); | 7756 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); |
| 7754 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, GL_STREAM_READ); | 7757 // For ANGLE client version 2, GL_STREAM_READ is not available. |
| 7758 const GLenum usage_hint = | |
| 7759 features().is_angle ? GL_STATIC_DRAW : GL_STREAM_READ; | |
| 7760 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, usage_hint); | |
| 7755 GLenum error = glGetError(); | 7761 GLenum error = glGetError(); |
| 7756 if (error == GL_NO_ERROR) { | 7762 if (error == GL_NO_ERROR) { |
| 7757 glReadPixels(x, y, width, height, format, type, 0); | 7763 glReadPixels(x, y, width, height, format, type, 0); |
| 7758 pending_readpixel_fences_.push(linked_ptr<FenceCallback>( | 7764 pending_readpixel_fences_.push(linked_ptr<FenceCallback>( |
| 7759 new FenceCallback())); | 7765 new FenceCallback())); |
| 7760 WaitForReadPixels(base::Bind( | 7766 WaitForReadPixels(base::Bind( |
| 7761 &GLES2DecoderImpl::FinishReadPixels, | 7767 &GLES2DecoderImpl::FinishReadPixels, |
| 7762 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr | 7768 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr |
| 7763 <GLES2DecoderImpl>(this), | 7769 <GLES2DecoderImpl>(this), |
| 7764 c, buffer)); | 7770 c, buffer)); |
| (...skipping 3697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11462 } | 11468 } |
| 11463 } | 11469 } |
| 11464 | 11470 |
| 11465 // Include the auto-generated part of this file. We split this because it means | 11471 // Include the auto-generated part of this file. We split this because it means |
| 11466 // we can easily edit the non-auto generated parts right here in this file | 11472 // we can easily edit the non-auto generated parts right here in this file |
| 11467 // instead of having to edit some template or the code generator. | 11473 // instead of having to edit some template or the code generator. |
| 11468 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11474 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 11469 | 11475 |
| 11470 } // namespace gles2 | 11476 } // namespace gles2 |
| 11471 } // namespace gpu | 11477 } // namespace gpu |
| OLD | NEW |