Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 1494553002: Revert of Upgrade PixelStorei to ES3/WebGL2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 TransferBufferInterface* transfer_buffer, 78 TransferBufferInterface* transfer_buffer,
79 bool bind_generates_resource, 79 bool bind_generates_resource,
80 bool lose_context_when_out_of_memory, 80 bool lose_context_when_out_of_memory,
81 bool support_client_side_arrays, 81 bool support_client_side_arrays,
82 GpuControl* gpu_control) 82 GpuControl* gpu_control)
83 : helper_(helper), 83 : helper_(helper),
84 transfer_buffer_(transfer_buffer), 84 transfer_buffer_(transfer_buffer),
85 angle_pack_reverse_row_order_status_(kUnknownExtensionStatus), 85 angle_pack_reverse_row_order_status_(kUnknownExtensionStatus),
86 chromium_framebuffer_multisample_(kUnknownExtensionStatus), 86 chromium_framebuffer_multisample_(kUnknownExtensionStatus),
87 pack_alignment_(4), 87 pack_alignment_(4),
88 pack_row_length_(0),
89 pack_skip_pixels_(0),
90 pack_skip_rows_(0),
91 unpack_alignment_(4), 88 unpack_alignment_(4),
92 unpack_row_length_(0), 89 unpack_row_length_(0),
93 unpack_image_height_(0), 90 unpack_image_height_(0),
94 unpack_skip_rows_(0), 91 unpack_skip_rows_(0),
95 unpack_skip_pixels_(0), 92 unpack_skip_pixels_(0),
96 unpack_skip_images_(0), 93 unpack_skip_images_(0),
97 pack_reverse_row_order_(false), 94 pack_reverse_row_order_(false),
98 active_texture_unit_(0), 95 active_texture_unit_(0),
99 bound_framebuffer_(0), 96 bound_framebuffer_(0),
100 bound_read_framebuffer_(0), 97 bound_read_framebuffer_(0),
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 CheckGLError(); 1710 CheckGLError();
1714 } 1711 }
1715 1712
1716 void GLES2Implementation::PixelStorei(GLenum pname, GLint param) { 1713 void GLES2Implementation::PixelStorei(GLenum pname, GLint param) {
1717 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1714 GPU_CLIENT_SINGLE_THREAD_CHECK();
1718 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glPixelStorei(" 1715 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glPixelStorei("
1719 << GLES2Util::GetStringPixelStore(pname) << ", " 1716 << GLES2Util::GetStringPixelStore(pname) << ", "
1720 << param << ")"); 1717 << param << ")");
1721 switch (pname) { 1718 switch (pname) {
1722 case GL_PACK_ALIGNMENT: 1719 case GL_PACK_ALIGNMENT:
1723 pack_alignment_ = param; 1720 pack_alignment_ = param;
1724 break; 1721 break;
1725 case GL_PACK_ROW_LENGTH:
1726 pack_row_length_ = param;
1727 break;
1728 case GL_PACK_SKIP_PIXELS:
1729 pack_skip_pixels_ = param;
1730 break;
1731 case GL_PACK_SKIP_ROWS:
1732 pack_skip_rows_ = param;
1733 break;
1734 case GL_UNPACK_ALIGNMENT: 1722 case GL_UNPACK_ALIGNMENT:
1735 unpack_alignment_ = param; 1723 unpack_alignment_ = param;
1736 break; 1724 break;
1737 case GL_UNPACK_ROW_LENGTH_EXT: 1725 case GL_UNPACK_ROW_LENGTH_EXT:
1738 unpack_row_length_ = param; 1726 unpack_row_length_ = param;
1739 return; 1727 return;
1740 case GL_UNPACK_IMAGE_HEIGHT: 1728 case GL_UNPACK_IMAGE_HEIGHT:
1741 unpack_image_height_ = param; 1729 unpack_image_height_ = param;
1742 return; 1730 return;
1743 case GL_UNPACK_SKIP_ROWS_EXT: 1731 case GL_UNPACK_SKIP_ROWS_EXT:
1744 unpack_skip_rows_ = param; 1732 unpack_skip_rows_ = param;
1745 return; 1733 return;
1746 case GL_UNPACK_SKIP_PIXELS_EXT: 1734 case GL_UNPACK_SKIP_PIXELS_EXT:
1747 unpack_skip_pixels_ = param; 1735 unpack_skip_pixels_ = param;
1748 return; 1736 return;
1749 case GL_UNPACK_SKIP_IMAGES: 1737 case GL_UNPACK_SKIP_IMAGES:
1750 unpack_skip_images_ = param; 1738 unpack_skip_images_ = param;
1751 return; 1739 return;
1752 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: 1740 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
1753 pack_reverse_row_order_ = 1741 pack_reverse_row_order_ =
1754 IsAnglePackReverseRowOrderAvailable() ? (param != 0) : false; 1742 IsAnglePackReverseRowOrderAvailable() ? (param != 0) : false;
1755 break; 1743 break;
1756 default: 1744 default:
1757 break; 1745 break;
1758 } 1746 }
1759 helper_->PixelStorei(pname, param); 1747 helper_->PixelStorei(pname, param);
1760 CheckGLError(); 1748 CheckGLError();
1761 } 1749 }
1762 1750
1763 void GLES2Implementation::VertexAttribIPointer( 1751 void GLES2Implementation::VertexAttribIPointer(
1764 GLuint index, GLint size, GLenum type, GLsizei stride, const void* ptr) { 1752 GLuint index, GLint size, GLenum type, GLsizei stride, const void* ptr) {
1765 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1753 GPU_CLIENT_SINGLE_THREAD_CHECK();
1766 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttribIPointer(" 1754 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttribIPointer("
1767 << index << ", " 1755 << index << ", "
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after
3477 uint32 temp_size; 3465 uint32 temp_size;
3478 uint32 unpadded_row_size; 3466 uint32 unpadded_row_size;
3479 uint32 padded_row_size; 3467 uint32 padded_row_size;
3480 if (!GLES2Util::ComputeImageDataSizes( 3468 if (!GLES2Util::ComputeImageDataSizes(
3481 width, 2, 1, format, type, pack_alignment_, &temp_size, 3469 width, 2, 1, format, type, pack_alignment_, &temp_size,
3482 &unpadded_row_size, &padded_row_size)) { 3470 &unpadded_row_size, &padded_row_size)) {
3483 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large."); 3471 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large.");
3484 return; 3472 return;
3485 } 3473 }
3486 3474
3487 if (bound_pixel_pack_buffer_) {
3488 // TODO(zmo): Need to handle the case of reading into a PIXEL_PACK_BUFFER
3489 // in ES3. For now, generate a GL error.
3490 SetGLError(GL_INVALID_OPERATION, "glReadPixels",
3491 "ReadPixels to a pixel pack buffer isn't implemented");
3492 return;
3493 }
3494
3495 if (bound_pixel_pack_transfer_buffer_id_) { 3475 if (bound_pixel_pack_transfer_buffer_id_) {
3496 GLuint offset = ToGLuint(pixels); 3476 GLuint offset = ToGLuint(pixels);
3497 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( 3477 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
3498 bound_pixel_pack_transfer_buffer_id_, 3478 bound_pixel_pack_transfer_buffer_id_,
3499 "glReadPixels", offset, padded_row_size * height); 3479 "glReadPixels", offset, padded_row_size * height);
3500 if (buffer && buffer->shm_id() != -1) { 3480 if (buffer && buffer->shm_id() != -1) {
3501 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, 3481 helper_->ReadPixels(xoffset, yoffset, width, height, format, type,
3502 buffer->shm_id(), buffer->shm_offset(), 3482 buffer->shm_id(), buffer->shm_offset(),
3503 0, 0, true); 3483 0, 0, true);
3504 CheckGLError(); 3484 CheckGLError();
3505 } 3485 }
3506 return; 3486 return;
3507 } 3487 }
3508 3488
3509 if (!pixels) { 3489 if (!pixels) {
3510 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL"); 3490 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL");
3511 return; 3491 return;
3512 } 3492 }
3513 3493
3514 // compute the advance bytes per row for the dst pixels
3515 uint32 dst_padded_row_size;
3516 if (pack_row_length_ > 0) {
3517 if (!GLES2Util::ComputeImagePaddedRowSize(
3518 pack_row_length_, format, type, pack_alignment_,
3519 &dst_padded_row_size)) {
3520 SetGLError(
3521 GL_INVALID_VALUE, "glReadPixels", "pack row length too large");
3522 return;
3523 }
3524 } else {
3525 dst_padded_row_size = padded_row_size;
3526 }
3527
3528 // Advance pixels pointer past the skip rows and skip pixels
3529 dest += pack_skip_rows_ * dst_padded_row_size;
3530 if (pack_skip_pixels_) {
3531 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type);
3532 dest += pack_skip_pixels_ * group_size;
3533 }
3534
3535 // Transfer by rows. 3494 // Transfer by rows.
3536 // The max rows we can transfer. 3495 // The max rows we can transfer.
3537 while (height) { 3496 while (height) {
3538 GLsizei desired_size = padded_row_size * (height - 1) + unpadded_row_size; 3497 GLsizei desired_size = padded_row_size * (height - 1) + unpadded_row_size;
3539 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_); 3498 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_);
3540 if (!buffer.valid()) { 3499 if (!buffer.valid()) {
3541 return; 3500 return;
3542 } 3501 }
3543 GLint num_rows = ComputeNumRowsThatFitInBuffer( 3502 GLint num_rows = ComputeNumRowsThatFitInBuffer(
3544 padded_row_size, unpadded_row_size, buffer.size(), height); 3503 padded_row_size, unpadded_row_size, buffer.size(), height);
(...skipping 10 matching lines...) Expand all
3555 buffer.shm_id(), buffer.offset(), 3514 buffer.shm_id(), buffer.offset(),
3556 GetResultShmId(), GetResultShmOffset(), 3515 GetResultShmId(), GetResultShmOffset(),
3557 false); 3516 false);
3558 WaitForCmd(); 3517 WaitForCmd();
3559 if (*result != 0) { 3518 if (*result != 0) {
3560 // when doing a y-flip we have to iterate through top-to-bottom chunks 3519 // when doing a y-flip we have to iterate through top-to-bottom chunks
3561 // of the dst. The service side handles reversing the rows within a 3520 // of the dst. The service side handles reversing the rows within a
3562 // chunk. 3521 // chunk.
3563 int8* rows_dst; 3522 int8* rows_dst;
3564 if (pack_reverse_row_order_) { 3523 if (pack_reverse_row_order_) {
3565 rows_dst = dest + (height - num_rows) * dst_padded_row_size; 3524 rows_dst = dest + (height - num_rows) * padded_row_size;
3566 } else { 3525 } else {
3567 rows_dst = dest; 3526 rows_dst = dest;
3568 } 3527 }
3569 // We have to copy 1 row at a time to avoid writing pad bytes. 3528 // We have to copy 1 row at a time to avoid writing pad bytes.
3570 const int8* src = static_cast<const int8*>(buffer.address()); 3529 const int8* src = static_cast<const int8*>(buffer.address());
3571 for (GLint yy = 0; yy < num_rows; ++yy) { 3530 for (GLint yy = 0; yy < num_rows; ++yy) {
3572 memcpy(rows_dst, src, unpadded_row_size); 3531 memcpy(rows_dst, src, unpadded_row_size);
3573 rows_dst += dst_padded_row_size; 3532 rows_dst += padded_row_size;
3574 src += padded_row_size; 3533 src += padded_row_size;
3575 } 3534 }
3576 if (!pack_reverse_row_order_) { 3535 if (!pack_reverse_row_order_) {
3577 dest = rows_dst; 3536 dest = rows_dst;
3578 } 3537 }
3579 } 3538 }
3580 // If it was not marked as successful exit. 3539 // If it was not marked as successful exit.
3581 if (*result == 0) { 3540 if (*result == 0) {
3582 return; 3541 return;
3583 } 3542 }
(...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after
6431 CheckGLError(); 6390 CheckGLError();
6432 } 6391 }
6433 6392
6434 // Include the auto-generated part of this file. We split this because it means 6393 // Include the auto-generated part of this file. We split this because it means
6435 // we can easily edit the non-auto generated parts right here in this file 6394 // we can easily edit the non-auto generated parts right here in this file
6436 // instead of having to edit some template or the code generator. 6395 // instead of having to edit some template or the code generator.
6437 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 6396 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6438 6397
6439 } // namespace gles2 6398 } // namespace gles2
6440 } // namespace gpu 6399 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/service/context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698