Index: gpu/command_buffer/client/gles2_implementation.cc |
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
index 631cfe32ef56aab184f4a8aea41ea410c80df2e8..64b34d6063cb4988051d61862af06d967252627a 100644 |
--- a/gpu/command_buffer/client/gles2_implementation.cc |
+++ b/gpu/command_buffer/client/gles2_implementation.cc |
@@ -257,6 +257,11 @@ IdHandlerInterface* GLES2Implementation::GetIdHandler(int namespace_id) const { |
return share_group_->GetIdHandler(namespace_id); |
} |
+RangeIdHandlerInterface* GLES2Implementation::GetRangeIdHandler( |
+ int namespace_id) const { |
+ return share_group_->GetRangeIdHandler(namespace_id); |
+} |
+ |
IdAllocator* GLES2Implementation::GetIdAllocator(int namespace_id) const { |
if (namespace_id == id_namespaces::kQueries) |
return query_id_allocator_.get(); |
@@ -5792,6 +5797,141 @@ void GLES2Implementation::GetInternalformativ( |
CheckGLError(); |
} |
+GLuint GLES2Implementation::GenPathsCHROMIUM(GLsizei range) { |
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenPathsCHROMIUM(" << range |
+ << ")"); |
+ GPU_CLIENT_SINGLE_THREAD_CHECK(); |
+ |
+ if (range < 0) { |
+ SetGLError(GL_INVALID_VALUE, "glGenPathsCHROMIUM", "range < 0"); |
+ return 0; |
+ } |
+ if (!base::IsValueInRangeForNumericType<int32_t>(range)) { |
+ SetGLError(GL_INVALID_VALUE, "glGenPathsCHROMIUM", |
+ "range more than 32-bit"); |
+ return 0; |
+ } |
+ |
+ if (range == 0) { |
+ return 0; |
+ } |
+ |
+ GLuint first_client_id = 0; |
+ GetRangeIdHandler(id_namespaces::kPaths) |
+ ->MakeIdRange(this, range, &first_client_id); |
+ |
+ if (first_client_id == 0) { |
+ // Ran out of id space. Is not specified to raise any gl errors. |
+ return 0; |
+ } |
+ |
+ helper_->GenPathsCHROMIUM(first_client_id, range); |
+ |
+ GPU_CLIENT_LOG_CODE_BLOCK({ |
+ for (GLsizei i = 0; i < range; ++i) { |
+ GPU_CLIENT_LOG(" " << i << ": " << (first_client_id + i)); |
+ } |
+ }); |
+ CheckGLError(); |
+ return first_client_id; |
+} |
+ |
+void GLES2Implementation::DeletePathsCHROMIUM(GLuint first_client_id, |
+ GLsizei range) { |
+ GPU_CLIENT_SINGLE_THREAD_CHECK(); |
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDeletePathsCHROMIUM(" |
+ << first_client_id << ", " << range << ")"); |
+ |
+ if (range < 0) { |
+ SetGLError(GL_INVALID_VALUE, "glDeletePathsCHROMIUM", "range < 0"); |
+ return; |
+ } |
+ |
+ if (!base::IsValueInRangeForNumericType<int32_t>(range)) { |
vmiura
2015/06/19 21:55:21
Should there be an error if (first_client_id + ran
Kimmo Kinnunen
2015/06/23 12:03:10
Done.
|
+ SetGLError(GL_INVALID_VALUE, "glGenPathsCHROMIUM", |
+ "range more than 32-bit"); |
+ return; |
+ } |
+ |
+ if (range == 0) { |
+ return; |
+ } |
+ |
+ GetRangeIdHandler(id_namespaces::kPaths) |
+ ->FreeIdRange(this, first_client_id, range, |
+ &GLES2Implementation::DeletePathsCHROMIUMStub); |
+ // Deleting non-existing paths does not produce errors in the extension. |
+} |
+ |
+void GLES2Implementation::DeletePathsCHROMIUMStub(GLuint first_client_id, |
+ GLsizei range) { |
+ helper_->DeletePathsCHROMIUM(first_client_id, range); |
+} |
+ |
+void GLES2Implementation::PathCommandsCHROMIUM(GLuint path, |
+ GLsizei num_commands, |
+ const GLubyte* commands, |
+ GLsizei num_coords, |
+ GLenum coord_type, |
+ const void* coords) { |
+ GPU_CLIENT_SINGLE_THREAD_CHECK(); |
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glPathCommandsCHROMIUM(" << path |
+ << ", " << num_commands << ", " << commands << ", " |
+ << num_coords << ", " << coords << ")"); |
+ if (path == 0) { |
+ SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", |
+ "invalid path object"); |
+ return; |
+ } |
+ if (num_commands < 0) { |
+ SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "numCommands < 0"); |
+ return; |
+ } |
+ if (num_commands != 0 && !commands) { |
+ SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "missing commands"); |
+ return; |
+ } |
+ if (num_coords < 0) { |
+ SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "numCoords < 0"); |
+ return; |
+ } |
+ uint32 coord_type_size = GLES2Util::GetGLTypeSizeForPathCoordType(coord_type); |
+ if (coord_type_size == 0) { |
+ SetGLError(GL_INVALID_ENUM, "glPathCommandsCHROMIUM", "invalid coordType"); |
+ return; |
+ } |
+ if (num_coords != 0 && !coords) { |
+ SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", "missing coords"); |
+ return; |
+ } |
+ if (num_commands == 0 && num_coords == 0) { |
+ helper_->PathCommandsCHROMIUM(path, 0, 0, 0, 0, GL_FLOAT, 0, 0); |
+ return; |
+ } |
+ |
+ uint32 coords_size = coord_type_size * num_coords; |
vmiura
2015/06/19 21:55:21
if (!SafeMultiplyUint32(width, bytes_per_group, &c
Kimmo Kinnunen
2015/06/23 12:03:10
Done.
|
+ |
+ ScopedTransferBufferPtr buffer(coords_size + num_commands, helper_, |
vmiura
2015/06/19 21:55:22
SafeAddUInt32 for "coords_size + num_commands".
Kimmo Kinnunen
2015/06/23 12:03:10
Done.
|
+ transfer_buffer_); |
+ if (!buffer.valid() || buffer.size() < coords_size + num_commands) { |
+ SetGLError(GL_INVALID_VALUE, "glPathCommandsCHROMIUM", |
+ "no room in transfer buffer for coords and commands"); |
+ return; |
+ } |
+ |
+ // Copy coords first because they need more strict alignment. |
+ unsigned char* coords_addr = static_cast<unsigned char*>(buffer.address()); |
+ memcpy(coords_addr, coords, coords_size); |
vmiura
2015/06/19 21:55:22
Memcpy from NULL pointer is undefined behavior I b
Kimmo Kinnunen
2015/06/23 12:03:10
Done.
|
+ |
+ unsigned char* commands_addr = |
+ static_cast<unsigned char*>(buffer.address()) + coords_size; |
+ memcpy(commands_addr, commands, num_commands); |
vmiura
2015/06/19 21:55:21
Same here
if (num_commands > 0)
memcpy(...)
Kimmo Kinnunen
2015/06/23 12:03:10
Done.
|
+ helper_->PathCommandsCHROMIUM(path, num_commands, buffer.shm_id(), |
+ buffer.offset() + coords_size, num_coords, |
+ coord_type, buffer.shm_id(), buffer.offset()); |
+ CheckGLError(); |
+} |
+ |
// Include the auto-generated part of this file. We split this because it means |
// we can easily edit the non-auto generated parts right here in this file |
// instead of having to edit some template or the code generator. |