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

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

Issue 1320093002: Command Buffer: read pixels into pixel pack buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unittests 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 8843 matching lines...) Expand 10 before | Expand all | Expand 10 after
8854 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); 8854 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0");
8855 return error::kNoError; 8855 return error::kNoError;
8856 } 8856 }
8857 typedef cmds::ReadPixels::Result Result; 8857 typedef cmds::ReadPixels::Result Result;
8858 uint32 pixels_size; 8858 uint32 pixels_size;
8859 if (!GLES2Util::ComputeImageDataSizes( 8859 if (!GLES2Util::ComputeImageDataSizes(
8860 width, height, 1, format, type, state_.pack_alignment, &pixels_size, 8860 width, height, 1, format, type, state_.pack_alignment, &pixels_size,
8861 NULL, NULL)) { 8861 NULL, NULL)) {
8862 return error::kOutOfBounds; 8862 return error::kOutOfBounds;
8863 } 8863 }
8864 void* pixels = GetSharedMemoryAs<void*>( 8864
8865 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); 8865 void* pixels = NULL;
8866 if (!pixels) { 8866 bool pixel_pack_buffer_binding =
8867 return error::kOutOfBounds; 8867 GetClientId(buffer_manager(), state_.bound_pixel_pack_buffer.get());
8868 if (c.pixels_shm_id == 0) {
8869 if (pixel_pack_buffer_binding) {
8870 pixels = reinterpret_cast<void *>(c.pixels_shm_offset);
Zhenyao Mo 2015/12/02 00:25:52 We probably want to perform a bunch of extra valid
yunchao 2015/12/02 09:36:55 Done.
8871 } else {
8872 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
8873 "no pixel pack buffer bound");
8874 return error::kNoError;
8875 }
8876 } else {
8877 if (pixel_pack_buffer_binding) {
8878 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
8879 "pixel pack buffer bound");
8880 return error::kNoError;
8881 } else {
8882 pixels = GetSharedMemoryAs<void*>(
8883 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
8884 if (!pixels) {
8885 return error::kOutOfBounds;
8886 }
8887 }
8868 } 8888 }
8889
8869 Result* result = NULL; 8890 Result* result = NULL;
8870 if (c.result_shm_id != 0) { 8891 if (c.result_shm_id != 0) {
8871 result = GetSharedMemoryAs<Result*>( 8892 result = GetSharedMemoryAs<Result*>(
8872 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 8893 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8873 if (!result) { 8894 if (!result) {
8874 return error::kOutOfBounds; 8895 return error::kOutOfBounds;
8875 } 8896 }
8876 } 8897 }
8877 8898
8878 if (!validators_->read_pixel_format.IsValid(format)) { 8899 if (!validators_->read_pixel_format.IsValid(format)) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
8993 } 9014 }
8994 9015
8995 if (!CheckBoundFramebuffersValid("glReadPixels")) { 9016 if (!CheckBoundFramebuffersValid("glReadPixels")) {
8996 return error::kNoError; 9017 return error::kNoError;
8997 } 9018 }
8998 9019
8999 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels"); 9020 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glReadPixels");
9000 9021
9001 ScopedResolvedFrameBufferBinder binder(this, false, true); 9022 ScopedResolvedFrameBufferBinder binder(this, false, true);
9002 9023
9003 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { 9024 if ((x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height())
9025 && c.pixels_shm_id != 0) {
9004 // The user requested an out of range area. Get the results 1 line 9026 // The user requested an out of range area. Get the results 1 line
9005 // at a time. 9027 // at a time.
9006 uint32 temp_size; 9028 uint32 temp_size;
9007 uint32 unpadded_row_size; 9029 uint32 unpadded_row_size;
9008 uint32 padded_row_size; 9030 uint32 padded_row_size;
9009 if (!GLES2Util::ComputeImageDataSizes( 9031 if (!GLES2Util::ComputeImageDataSizes(
9010 width, 2, 1, format, type, state_.pack_alignment, &temp_size, 9032 width, 2, 1, format, type, state_.pack_alignment, &temp_size,
9011 &unpadded_row_size, &padded_row_size)) { 9033 &unpadded_row_size, &padded_row_size)) {
9012 LOCAL_SET_GL_ERROR( 9034 LOCAL_SET_GL_ERROR(
9013 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); 9035 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
9066 glDeleteBuffersARB(1, &buffer); 9088 glDeleteBuffersARB(1, &buffer);
9067 } 9089 }
9068 } 9090 }
9069 glReadPixels(x, y, width, height, format, type, pixels); 9091 glReadPixels(x, y, width, height, format, type, pixels);
9070 } 9092 }
9071 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels"); 9093 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels");
9072 if (error == GL_NO_ERROR) { 9094 if (error == GL_NO_ERROR) {
9073 if (result != NULL) { 9095 if (result != NULL) {
9074 *result = true; 9096 *result = true;
9075 } 9097 }
9076 FinishReadPixels(c, 0); 9098 if (c.pixels_shm_id != 0) {
9099 FinishReadPixels(c, 0);
9100 }
9077 } 9101 }
9078 9102
9079 return error::kNoError; 9103 return error::kNoError;
9080 } 9104 }
9081 9105
9082 error::Error GLES2DecoderImpl::HandlePixelStorei(uint32 immediate_data_size, 9106 error::Error GLES2DecoderImpl::HandlePixelStorei(uint32 immediate_data_size,
9083 const void* cmd_data) { 9107 const void* cmd_data) {
9084 const gles2::cmds::PixelStorei& c = 9108 const gles2::cmds::PixelStorei& c =
9085 *static_cast<const gles2::cmds::PixelStorei*>(cmd_data); 9109 *static_cast<const gles2::cmds::PixelStorei*>(cmd_data);
9086 GLenum pname = c.pname; 9110 GLenum pname = c.pname;
(...skipping 6207 matching lines...) Expand 10 before | Expand all | Expand 10 after
15294 return error::kNoError; 15318 return error::kNoError;
15295 } 15319 }
15296 15320
15297 // Include the auto-generated part of this file. We split this because it means 15321 // Include the auto-generated part of this file. We split this because it means
15298 // we can easily edit the non-auto generated parts right here in this file 15322 // we can easily edit the non-auto generated parts right here in this file
15299 // instead of having to edit some template or the code generator. 15323 // instead of having to edit some template or the code generator.
15300 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15324 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15301 15325
15302 } // namespace gles2 15326 } // namespace gles2
15303 } // namespace gpu 15327 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698