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

Unified Diff: gpu/command_buffer/client/gles2_implementation_impl_autogen.h

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/client/gles2_implementation_impl_autogen.h
diff --git a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
index d84c123351663f4991e46825515e245d1305524e..625c7473af16d2f27a780be27faca48f03fbbd15 100644
--- a/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_impl_autogen.h
@@ -1747,73 +1747,10 @@ void GLES2Implementation::ShaderSource(GLuint shader,
SetGLError(GL_INVALID_VALUE, "glShaderSource", "count < 0");
return;
}
- // Compute the total size.
- base::CheckedNumeric<size_t> total_size = count;
- total_size += 1;
- total_size *= sizeof(GLint);
- if (!total_size.IsValid()) {
- SetGLError(GL_INVALID_VALUE, "glShaderSource", "overflow");
- return;
- }
- size_t header_size = total_size.ValueOrDefault(0);
- std::vector<GLint> header(count + 1);
- header[0] = static_cast<GLint>(count);
- for (GLsizei ii = 0; ii < count; ++ii) {
- GLint len = 0;
- if (str[ii]) {
- len = (length && length[ii] >= 0)
- ? length[ii]
- : base::checked_cast<GLint>(strlen(str[ii]));
- }
- total_size += len;
- total_size += 1; // NULL at the end of each char array.
- if (!total_size.IsValid()) {
- SetGLError(GL_INVALID_VALUE, "glShaderSource", "overflow");
- return;
- }
- header[ii + 1] = len;
- }
- // Pack data into a bucket on the service.
- helper_->SetBucketSize(kResultBucketId, total_size.ValueOrDefault(0));
- size_t offset = 0;
- for (GLsizei ii = 0; ii <= count; ++ii) {
- const char* src =
- (ii == 0) ? reinterpret_cast<const char*>(&header[0]) : str[ii - 1];
- base::CheckedNumeric<size_t> checked_size =
- (ii == 0) ? header_size : static_cast<size_t>(header[ii]);
- if (ii > 0) {
- checked_size += 1; // NULL in the end.
- }
- if (!checked_size.IsValid()) {
- SetGLError(GL_INVALID_VALUE, "glShaderSource", "overflow");
- return;
- }
- size_t size = checked_size.ValueOrDefault(0);
- while (size) {
- ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
- if (!buffer.valid() || buffer.size() == 0) {
- SetGLError(GL_OUT_OF_MEMORY, "glShaderSource", "too large");
- return;
- }
- size_t copy_size = buffer.size();
- if (ii > 0 && buffer.size() == size)
- --copy_size;
- if (copy_size)
- memcpy(buffer.address(), src, copy_size);
- if (copy_size < buffer.size()) {
- // Append NULL in the end.
- DCHECK(copy_size + 1 == buffer.size());
- char* str = reinterpret_cast<char*>(buffer.address());
- str[copy_size] = 0;
- }
- helper_->SetBucketData(kResultBucketId, offset, buffer.size(),
- buffer.shm_id(), buffer.offset());
- offset += buffer.size();
- src += buffer.size();
- size -= buffer.size();
- }
+
+ if (!PackStringsToBucket(count, str, length, "glShaderSource")) {
+ return;
}
- DCHECK_EQ(total_size.ValueOrDefault(0), offset);
helper_->ShaderSourceBucket(shader, kResultBucketId);
helper_->SetBucketSize(kResultBucketId, 0);
CheckGLError();
@@ -1990,72 +1927,11 @@ void GLES2Implementation::TransformFeedbackVaryings(GLuint program,
SetGLError(GL_INVALID_VALUE, "glTransformFeedbackVaryings", "count < 0");
return;
}
- // Compute the total size.
- base::CheckedNumeric<size_t> total_size = count;
- total_size += 1;
- total_size *= sizeof(GLint);
- if (!total_size.IsValid()) {
- SetGLError(GL_INVALID_VALUE, "glTransformFeedbackVaryings", "overflow");
- return;
- }
- size_t header_size = total_size.ValueOrDefault(0);
- std::vector<GLint> header(count + 1);
- header[0] = static_cast<GLint>(count);
- for (GLsizei ii = 0; ii < count; ++ii) {
- GLint len = 0;
- if (varyings[ii]) {
- len = static_cast<GLint>(strlen(varyings[ii]));
- }
- total_size += len;
- total_size += 1; // NULL at the end of each char array.
- if (!total_size.IsValid()) {
- SetGLError(GL_INVALID_VALUE, "glTransformFeedbackVaryings", "overflow");
- return;
- }
- header[ii + 1] = len;
- }
- // Pack data into a bucket on the service.
- helper_->SetBucketSize(kResultBucketId, total_size.ValueOrDefault(0));
- size_t offset = 0;
- for (GLsizei ii = 0; ii <= count; ++ii) {
- const char* src = (ii == 0) ? reinterpret_cast<const char*>(&header[0])
- : varyings[ii - 1];
- base::CheckedNumeric<size_t> checked_size =
- (ii == 0) ? header_size : static_cast<size_t>(header[ii]);
- if (ii > 0) {
- checked_size += 1; // NULL in the end.
- }
- if (!checked_size.IsValid()) {
- SetGLError(GL_INVALID_VALUE, "glTransformFeedbackVaryings", "overflow");
- return;
- }
- size_t size = checked_size.ValueOrDefault(0);
- while (size) {
- ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
- if (!buffer.valid() || buffer.size() == 0) {
- SetGLError(GL_OUT_OF_MEMORY, "glTransformFeedbackVaryings",
- "too large");
- return;
- }
- size_t copy_size = buffer.size();
- if (ii > 0 && buffer.size() == size)
- --copy_size;
- if (copy_size)
- memcpy(buffer.address(), src, copy_size);
- if (copy_size < buffer.size()) {
- // Append NULL in the end.
- DCHECK(copy_size + 1 == buffer.size());
- char* str = reinterpret_cast<char*>(buffer.address());
- str[copy_size] = 0;
- }
- helper_->SetBucketData(kResultBucketId, offset, buffer.size(),
- buffer.shm_id(), buffer.offset());
- offset += buffer.size();
- src += buffer.size();
- size -= buffer.size();
- }
+
+ if (!PackStringsToBucket(count, varyings, NULL,
+ "glTransformFeedbackVaryings")) {
+ return;
}
- DCHECK_EQ(total_size.ValueOrDefault(0), offset);
helper_->TransformFeedbackVaryingsBucket(program, kResultBucketId,
buffermode);
helper_->SetBucketSize(kResultBucketId, 0);

Powered by Google App Engine
This is Rietveld 408576698