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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1540553003: Revert of Command Buffer: read pixels into pixel pack buffer (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 #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 <cmath> 10 #include <cmath>
(...skipping 9156 matching lines...) Expand 10 before | Expand all | Expand 10 after
9167 GLsizei width = c.width; 9167 GLsizei width = c.width;
9168 GLsizei height = c.height; 9168 GLsizei height = c.height;
9169 GLenum format = c.format; 9169 GLenum format = c.format;
9170 GLenum type = c.type; 9170 GLenum type = c.type;
9171 GLboolean async = static_cast<GLboolean>(c.async); 9171 GLboolean async = static_cast<GLboolean>(c.async);
9172 if (width < 0 || height < 0) { 9172 if (width < 0 || height < 0) {
9173 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); 9173 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0");
9174 return error::kNoError; 9174 return error::kNoError;
9175 } 9175 }
9176 typedef cmds::ReadPixels::Result Result; 9176 typedef cmds::ReadPixels::Result Result;
9177 uint32 pixels_size = 0; 9177 uint32 pixels_size;
9178 if (c.pixels_shm_id == 0) { 9178 if (state_.bound_pixel_pack_buffer.get()) {
9179 PixelStoreParams params = state_.GetPackParams(); 9179 // TODO(zmo): Need to handle the case of reading into a PIXEL_PACK_BUFFER
9180 if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1, format, type, 9180 // in ES3, including more pack parameters. For now, generate a GL error.
9181 params, &pixels_size, nullptr, nullptr, nullptr)) { 9181 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9182 return error::kOutOfBounds; 9182 "ReadPixels to a pixel pack buffer isn't implemented");
9183 } 9183 return error::kNoError;
9184 } else {
9185 // When reading into client buffer, we actually set pack parameters to 0
9186 // (except for alignment) before calling glReadPixels. This makes sure we
9187 // only send back meaningful pixel data to the command buffer client side,
9188 // and the client side will take the responsibility to take the pixels and
9189 // write to the client buffer according to the full ES3 pack parameters.
9190 if (!GLES2Util::ComputeImageDataSizes(width, height, 1, format, type,
9191 state_.pack_alignment, &pixels_size, nullptr, nullptr)) {
9192 return error::kOutOfBounds;
9193 }
9194 } 9184 }
9195 9185 if (!GLES2Util::ComputeImageDataSizes(
9196 void* pixels = nullptr; 9186 width, height, 1, format, type, state_.pack_alignment, &pixels_size,
9197 Buffer* buffer = state_.bound_pixel_pack_buffer.get(); 9187 NULL, NULL)) {
9198 if (c.pixels_shm_id == 0) { 9188 return error::kOutOfBounds;
9199 if (buffer) {
9200 if (buffer->GetMappedRange()) {
9201 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9202 "pixel pack buffer should not be mapped to client memory");
9203 return error::kNoError;
9204 }
9205 uint32 size = 0;
9206 if (!SafeAddUint32(pixels_size, c.pixels_shm_offset, &size)) {
9207 LOCAL_SET_GL_ERROR(
9208 GL_INVALID_VALUE, "glReadPixels", "size + offset overflow");
9209 return error::kNoError;
9210 }
9211 if (static_cast<uint32>(buffer->size()) < size) {
9212 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9213 "pixel pack buffer is not large enough");
9214 return error::kNoError;
9215 }
9216 pixels = reinterpret_cast<void *>(c.pixels_shm_offset);
9217 } else {
9218 return error::kInvalidArguments;
9219 }
9220 } else {
9221 if (buffer) {
9222 return error::kInvalidArguments;
9223 } else {
9224 pixels = GetSharedMemoryAs<void*>(
9225 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
9226 if (!pixels) {
9227 return error::kOutOfBounds;
9228 }
9229 }
9230 } 9189 }
9231 9190 void* pixels = GetSharedMemoryAs<void*>(
9191 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
9192 if (!pixels) {
9193 return error::kOutOfBounds;
9194 }
9232 Result* result = NULL; 9195 Result* result = NULL;
9233 if (c.result_shm_id != 0) { 9196 if (c.result_shm_id != 0) {
9234 result = GetSharedMemoryAs<Result*>( 9197 result = GetSharedMemoryAs<Result*>(
9235 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 9198 c.result_shm_id, c.result_shm_offset, sizeof(*result));
9236 if (!result) { 9199 if (!result) {
9237 return error::kOutOfBounds; 9200 return error::kOutOfBounds;
9238 } 9201 }
9239 } 9202 }
9240 9203
9241 if (!validators_->read_pixel_format.IsValid(format)) { 9204 if (!validators_->read_pixel_format.IsValid(format)) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
9357 9320
9358 if (!CheckBoundFramebuffersValid("glReadPixels")) { 9321 if (!CheckBoundFramebuffersValid("glReadPixels")) {
9359 return error::kNoError; 9322 return error::kNoError;
9360 } 9323 }
9361 9324
9362 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels"); 9325 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels");
9363 9326
9364 ScopedResolvedFrameBufferBinder binder(this, false, true); 9327 ScopedResolvedFrameBufferBinder binder(this, false, true);
9365 9328
9366 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { 9329 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) {
9367 // TODO(yunchao): need to handle the out-of-bounds case for reading pixels
9368 // into PIXEL_PACK buffer.
9369 if (c.pixels_shm_id == 0) {
9370 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9371 "read pixels out of bounds into PIXEL_PACK buffer");
9372 return error::kNoError;
9373 }
9374 // The user requested an out of range area. Get the results 1 line 9330 // The user requested an out of range area. Get the results 1 line
9375 // at a time. 9331 // at a time.
9376 uint32 temp_size; 9332 uint32 temp_size;
9377 uint32 unpadded_row_size; 9333 uint32 unpadded_row_size;
9378 uint32 padded_row_size; 9334 uint32 padded_row_size;
9379 if (!GLES2Util::ComputeImageDataSizes( 9335 if (!GLES2Util::ComputeImageDataSizes(
9380 width, 2, 1, format, type, state_.pack_alignment, &temp_size, 9336 width, 2, 1, format, type, state_.pack_alignment, &temp_size,
9381 &unpadded_row_size, &padded_row_size)) { 9337 &unpadded_row_size, &padded_row_size)) {
9382 LOCAL_SET_GL_ERROR( 9338 LOCAL_SET_GL_ERROR(
9383 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); 9339 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
9439 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); 9395 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
9440 return error::kNoError; 9396 return error::kNoError;
9441 } else { 9397 } else {
9442 // On error, unbind pack buffer and fall through to sync readpixels 9398 // On error, unbind pack buffer and fall through to sync readpixels
9443 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); 9399 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
9444 glDeleteBuffersARB(1, &buffer); 9400 glDeleteBuffersARB(1, &buffer);
9445 } 9401 }
9446 } 9402 }
9447 glReadPixels(x, y, width, height, format, type, pixels); 9403 glReadPixels(x, y, width, height, format, type, pixels);
9448 } 9404 }
9449 if (c.pixels_shm_id != 0) { 9405 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels");
9450 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels"); 9406 if (error == GL_NO_ERROR) {
9451 if (error == GL_NO_ERROR) { 9407 if (result != NULL) {
9452 if (result != NULL) { 9408 *result = true;
9453 *result = true;
9454 }
9455 FinishReadPixels(c, 0);
9456 } 9409 }
9410 FinishReadPixels(c, 0);
9457 } 9411 }
9458 9412
9459 return error::kNoError; 9413 return error::kNoError;
9460 } 9414 }
9461 9415
9462 error::Error GLES2DecoderImpl::HandlePixelStorei(uint32 immediate_data_size, 9416 error::Error GLES2DecoderImpl::HandlePixelStorei(uint32 immediate_data_size,
9463 const void* cmd_data) { 9417 const void* cmd_data) {
9464 const gles2::cmds::PixelStorei& c = 9418 const gles2::cmds::PixelStorei& c =
9465 *static_cast<const gles2::cmds::PixelStorei*>(cmd_data); 9419 *static_cast<const gles2::cmds::PixelStorei*>(cmd_data);
9466 GLenum pname = c.pname; 9420 GLenum pname = c.pname;
(...skipping 6364 matching lines...) Expand 10 before | Expand all | Expand 10 after
15831 return error::kNoError; 15785 return error::kNoError;
15832 } 15786 }
15833 15787
15834 // Include the auto-generated part of this file. We split this because it means 15788 // Include the auto-generated part of this file. We split this because it means
15835 // we can easily edit the non-auto generated parts right here in this file 15789 // we can easily edit the non-auto generated parts right here in this file
15836 // instead of having to edit some template or the code generator. 15790 // instead of having to edit some template or the code generator.
15837 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15838 15792
15839 } // namespace gles2 15793 } // namespace gles2
15840 } // namespace gpu 15794 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698