OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_HANDLERS_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_HANDLERS_H_ |
| 7 |
| 8 namespace gpu { |
| 9 namespace gles2 { |
| 10 |
| 11 // Custom Handlers |
| 12 error::Error GLES2DecoderPassthroughImpl::HandleBindAttribLocationBucket( |
| 13 uint32_t immediate_data_size, |
| 14 const void* cmd_data) { |
| 15 const gles2::cmds::BindAttribLocationBucket& c = |
| 16 *static_cast<const gles2::cmds::BindAttribLocationBucket*>(cmd_data); |
| 17 GLuint program = static_cast<GLuint>(c.program); |
| 18 GLuint index = static_cast<GLuint>(c.index); |
| 19 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 20 if (!bucket || bucket->size() == 0) { |
| 21 return error::kInvalidArguments; |
| 22 } |
| 23 std::string name_str; |
| 24 if (!bucket->GetAsString(&name_str)) { |
| 25 return error::kInvalidArguments; |
| 26 } |
| 27 error::Error error = DoBindAttribLocation(program, index, name_str.c_str()); |
| 28 if (error != error::kNoError) { |
| 29 return error; |
| 30 } |
| 31 return error::kNoError; |
| 32 } |
| 33 |
| 34 error::Error GLES2DecoderPassthroughImpl::HandleBufferData( |
| 35 uint32_t immediate_data_size, |
| 36 const void* cmd_data) { |
| 37 const gles2::cmds::BufferData& c = |
| 38 *static_cast<const gles2::cmds::BufferData*>(cmd_data); |
| 39 GLenum target = static_cast<GLenum>(c.target); |
| 40 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); |
| 41 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id); |
| 42 uint32_t data_shm_offset = static_cast<uint32_t>(c.data_shm_offset); |
| 43 GLenum usage = static_cast<GLenum>(c.usage); |
| 44 const void* data = NULL; |
| 45 if (data_shm_id != 0 || data_shm_offset != 0) { |
| 46 data = GetSharedMemoryAs<const void*>(data_shm_id, data_shm_offset, size); |
| 47 if (!data) { |
| 48 return error::kOutOfBounds; |
| 49 } |
| 50 } |
| 51 error::Error error = DoBufferData(target, size, data, usage); |
| 52 if (error != error::kNoError) { |
| 53 return error; |
| 54 } |
| 55 return error::kNoError; |
| 56 } |
| 57 |
| 58 error::Error GLES2DecoderPassthroughImpl::HandleClientWaitSync( |
| 59 uint32_t immediate_data_size, |
| 60 const void* cmd_data) { |
| 61 const gles2::cmds::ClientWaitSync& c = |
| 62 *static_cast<const gles2::cmds::ClientWaitSync*>(cmd_data); |
| 63 const GLuint sync = static_cast<GLuint>(c.sync); |
| 64 const GLbitfield flags = static_cast<GLbitfield>(c.flags); |
| 65 const GLuint64 timeout = c.timeout(); |
| 66 typedef cmds::ClientWaitSync::Result Result; |
| 67 Result* result_dst = GetSharedMemoryAs<Result*>( |
| 68 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); |
| 69 if (!result_dst) { |
| 70 return error::kOutOfBounds; |
| 71 } |
| 72 error::Error error = DoClientWaitSync(sync, flags, timeout, result_dst); |
| 73 if (error != error::kNoError) { |
| 74 return error; |
| 75 } |
| 76 return error::kNoError; |
| 77 } |
| 78 |
| 79 error::Error GLES2DecoderPassthroughImpl::HandleCompressedTexImage2DBucket( |
| 80 uint32_t immediate_data_size, |
| 81 const void* cmd_data) { |
| 82 const gles2::cmds::CompressedTexImage2DBucket& c = |
| 83 *static_cast<const gles2::cmds::CompressedTexImage2DBucket*>(cmd_data); |
| 84 GLenum target = static_cast<GLenum>(c.target); |
| 85 GLint level = static_cast<GLint>(c.level); |
| 86 GLenum internalformat = static_cast<GLenum>(c.internalformat); |
| 87 GLsizei width = static_cast<GLsizei>(c.width); |
| 88 GLsizei height = static_cast<GLsizei>(c.height); |
| 89 GLint border = static_cast<GLint>(c.border); |
| 90 Bucket* bucket = GetBucket(c.bucket_id); |
| 91 if (!bucket) { |
| 92 return error::kInvalidArguments; |
| 93 } |
| 94 uint32_t data_size = bucket->size(); |
| 95 GLsizei imageSize = data_size; |
| 96 const void* data = bucket->GetData(0, data_size); |
| 97 if (!data) { |
| 98 return error::kInvalidArguments; |
| 99 } |
| 100 error::Error error = DoCompressedTexImage2D( |
| 101 target, level, internalformat, width, height, border, imageSize, data); |
| 102 if (error != error::kNoError) { |
| 103 return error; |
| 104 } |
| 105 return error::kNoError; |
| 106 } |
| 107 |
| 108 error::Error GLES2DecoderPassthroughImpl::HandleCompressedTexImage2D( |
| 109 uint32_t immediate_data_size, |
| 110 const void* cmd_data) { |
| 111 const gles2::cmds::CompressedTexImage2D& c = |
| 112 *static_cast<const gles2::cmds::CompressedTexImage2D*>(cmd_data); |
| 113 GLenum target = static_cast<GLenum>(c.target); |
| 114 GLint level = static_cast<GLint>(c.level); |
| 115 GLenum internalformat = static_cast<GLenum>(c.internalformat); |
| 116 GLsizei width = static_cast<GLsizei>(c.width); |
| 117 GLsizei height = static_cast<GLsizei>(c.height); |
| 118 GLint border = static_cast<GLint>(c.border); |
| 119 GLsizei imageSize = static_cast<GLsizei>(c.imageSize); |
| 120 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id); |
| 121 uint32_t data_shm_offset = static_cast<uint32_t>(c.data_shm_offset); |
| 122 const void* data = NULL; |
| 123 if (data_shm_id != 0 || data_shm_offset != 0) { |
| 124 data = |
| 125 GetSharedMemoryAs<const void*>(data_shm_id, data_shm_offset, imageSize); |
| 126 if (!data) { |
| 127 return error::kOutOfBounds; |
| 128 } |
| 129 } |
| 130 error::Error error = DoCompressedTexImage2D( |
| 131 target, level, internalformat, width, height, border, imageSize, data); |
| 132 if (error != error::kNoError) { |
| 133 return error; |
| 134 } |
| 135 return error::kNoError; |
| 136 } |
| 137 |
| 138 error::Error GLES2DecoderPassthroughImpl::HandleCompressedTexSubImage2DBucket( |
| 139 uint32_t immediate_data_size, |
| 140 const void* cmd_data) { |
| 141 const gles2::cmds::CompressedTexSubImage2DBucket& c = |
| 142 *static_cast<const gles2::cmds::CompressedTexSubImage2DBucket*>(cmd_data); |
| 143 GLenum target = static_cast<GLenum>(c.target); |
| 144 GLint level = static_cast<GLint>(c.level); |
| 145 GLint xoffset = static_cast<GLint>(c.xoffset); |
| 146 GLint yoffset = static_cast<GLint>(c.yoffset); |
| 147 GLsizei width = static_cast<GLsizei>(c.width); |
| 148 GLsizei height = static_cast<GLsizei>(c.height); |
| 149 GLenum format = static_cast<GLenum>(c.format); |
| 150 Bucket* bucket = GetBucket(c.bucket_id); |
| 151 if (!bucket) { |
| 152 return error::kInvalidArguments; |
| 153 } |
| 154 uint32_t data_size = bucket->size(); |
| 155 GLsizei imageSize = data_size; |
| 156 const void* data = bucket->GetData(0, data_size); |
| 157 if (!data) { |
| 158 return error::kInvalidArguments; |
| 159 } |
| 160 error::Error error = DoCompressedTexSubImage2D( |
| 161 target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 162 if (error != error::kNoError) { |
| 163 return error; |
| 164 } |
| 165 return error::kNoError; |
| 166 } |
| 167 |
| 168 error::Error GLES2DecoderPassthroughImpl::HandleCompressedTexImage3DBucket( |
| 169 uint32_t immediate_data_size, |
| 170 const void* cmd_data) { |
| 171 const gles2::cmds::CompressedTexImage3DBucket& c = |
| 172 *static_cast<const gles2::cmds::CompressedTexImage3DBucket*>(cmd_data); |
| 173 GLenum target = static_cast<GLenum>(c.target); |
| 174 GLint level = static_cast<GLint>(c.level); |
| 175 GLenum internal_format = static_cast<GLenum>(c.internalformat); |
| 176 GLsizei width = static_cast<GLsizei>(c.width); |
| 177 GLsizei height = static_cast<GLsizei>(c.height); |
| 178 GLsizei depth = static_cast<GLsizei>(c.depth); |
| 179 GLint border = static_cast<GLint>(c.border); |
| 180 Bucket* bucket = GetBucket(c.bucket_id); |
| 181 if (!bucket) { |
| 182 return error::kInvalidArguments; |
| 183 } |
| 184 uint32_t data_size = bucket->size(); |
| 185 GLsizei imageSize = data_size; |
| 186 const void* data = bucket->GetData(0, data_size); |
| 187 if (!data) { |
| 188 return error::kInvalidArguments; |
| 189 } |
| 190 error::Error error = |
| 191 DoCompressedTexImage3D(target, level, internal_format, width, height, |
| 192 depth, border, imageSize, data); |
| 193 if (error != error::kNoError) { |
| 194 return error; |
| 195 } |
| 196 return error::kNoError; |
| 197 } |
| 198 error::Error GLES2DecoderPassthroughImpl::HandleCompressedTexImage3D( |
| 199 uint32_t immediate_data_size, |
| 200 const void* cmd_data) { |
| 201 const gles2::cmds::CompressedTexImage3D& c = |
| 202 *static_cast<const gles2::cmds::CompressedTexImage3D*>(cmd_data); |
| 203 GLenum target = static_cast<GLenum>(c.target); |
| 204 GLint level = static_cast<GLint>(c.level); |
| 205 GLenum internal_format = static_cast<GLenum>(c.internalformat); |
| 206 GLsizei width = static_cast<GLsizei>(c.width); |
| 207 GLsizei height = static_cast<GLsizei>(c.height); |
| 208 GLsizei depth = static_cast<GLsizei>(c.depth); |
| 209 GLint border = static_cast<GLint>(c.border); |
| 210 GLsizei image_size = static_cast<GLsizei>(c.imageSize); |
| 211 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id); |
| 212 uint32_t data_shm_offset = static_cast<uint32_t>(c.data_shm_offset); |
| 213 const void* data = NULL; |
| 214 if (data_shm_id != 0 || data_shm_offset != 0) { |
| 215 data = GetSharedMemoryAs<const void*>(data_shm_id, data_shm_offset, |
| 216 image_size); |
| 217 if (!data) { |
| 218 return error::kOutOfBounds; |
| 219 } |
| 220 } |
| 221 error::Error error = |
| 222 DoCompressedTexImage3D(target, level, internal_format, width, height, |
| 223 depth, border, image_size, data); |
| 224 if (error != error::kNoError) { |
| 225 return error; |
| 226 } |
| 227 return error::kNoError; |
| 228 } |
| 229 |
| 230 error::Error GLES2DecoderPassthroughImpl::HandleCompressedTexSubImage3DBucket( |
| 231 uint32_t immediate_data_size, |
| 232 const void* cmd_data) { |
| 233 const gles2::cmds::CompressedTexSubImage3DBucket& c = |
| 234 *static_cast<const gles2::cmds::CompressedTexSubImage3DBucket*>(cmd_data); |
| 235 GLenum target = static_cast<GLenum>(c.target); |
| 236 GLint level = static_cast<GLint>(c.level); |
| 237 GLint xoffset = static_cast<GLint>(c.xoffset); |
| 238 GLint yoffset = static_cast<GLint>(c.yoffset); |
| 239 GLint zoffset = static_cast<GLint>(c.zoffset); |
| 240 GLsizei width = static_cast<GLsizei>(c.width); |
| 241 GLsizei height = static_cast<GLsizei>(c.height); |
| 242 GLsizei depth = static_cast<GLsizei>(c.depth); |
| 243 GLenum format = static_cast<GLenum>(c.format); |
| 244 Bucket* bucket = GetBucket(c.bucket_id); |
| 245 if (!bucket) { |
| 246 return error::kInvalidArguments; |
| 247 } |
| 248 uint32_t data_size = bucket->size(); |
| 249 GLsizei image_size = data_size; |
| 250 const void* data = bucket->GetData(0, data_size); |
| 251 if (!data) { |
| 252 return error::kInvalidArguments; |
| 253 } |
| 254 error::Error error = |
| 255 DoCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, |
| 256 height, depth, format, image_size, data); |
| 257 if (error != error::kNoError) { |
| 258 return error; |
| 259 } |
| 260 return error::kNoError; |
| 261 } |
| 262 |
| 263 error::Error GLES2DecoderPassthroughImpl::HandleCreateProgram( |
| 264 uint32_t immediate_data_size, |
| 265 const void* cmd_data) { |
| 266 const gles2::cmds::CreateProgram& c = |
| 267 *static_cast<const gles2::cmds::CreateProgram*>(cmd_data); |
| 268 GLuint client_id = static_cast<GLuint>(c.client_id); |
| 269 error::Error error = DoCreateProgram(client_id); |
| 270 if (error != error::kNoError) { |
| 271 return error; |
| 272 } |
| 273 return error::kNoError; |
| 274 } |
| 275 |
| 276 error::Error GLES2DecoderPassthroughImpl::HandleCreateShader( |
| 277 uint32_t immediate_data_size, |
| 278 const void* cmd_data) { |
| 279 const gles2::cmds::CreateShader& c = |
| 280 *static_cast<const gles2::cmds::CreateShader*>(cmd_data); |
| 281 GLenum type = static_cast<GLenum>(c.type); |
| 282 GLuint client_id = static_cast<GLuint>(c.client_id); |
| 283 error::Error error = DoCreateShader(type, client_id); |
| 284 if (error != error::kNoError) { |
| 285 return error; |
| 286 } |
| 287 return error::kNoError; |
| 288 } |
| 289 |
| 290 error::Error GLES2DecoderPassthroughImpl::HandleFenceSync( |
| 291 uint32_t immediate_data_size, |
| 292 const void* cmd_data) { |
| 293 const gles2::cmds::FenceSync& c = |
| 294 *static_cast<const gles2::cmds::FenceSync*>(cmd_data); |
| 295 GLenum condition = static_cast<GLenum>(c.condition); |
| 296 GLbitfield flags = static_cast<GLbitfield>(c.flags); |
| 297 GLuint client_id = static_cast<GLuint>(c.client_id); |
| 298 error::Error error = DoFenceSync(condition, flags, client_id); |
| 299 if (error != error::kNoError) { |
| 300 return error; |
| 301 } |
| 302 return error::kNoError; |
| 303 } |
| 304 |
| 305 error::Error GLES2DecoderPassthroughImpl::HandleDrawArrays( |
| 306 uint32_t immediate_data_size, |
| 307 const void* cmd_data) { |
| 308 const gles2::cmds::DrawArrays& c = |
| 309 *static_cast<const gles2::cmds::DrawArrays*>(cmd_data); |
| 310 GLenum mode = static_cast<GLenum>(c.mode); |
| 311 GLint first = static_cast<GLint>(c.first); |
| 312 GLsizei count = static_cast<GLsizei>(c.count); |
| 313 error::Error error = DoDrawArrays(mode, first, count); |
| 314 if (error != error::kNoError) { |
| 315 return error; |
| 316 } |
| 317 return error::kNoError; |
| 318 } |
| 319 |
| 320 error::Error GLES2DecoderPassthroughImpl::HandleDrawElements( |
| 321 uint32_t immediate_data_size, |
| 322 const void* cmd_data) { |
| 323 const gles2::cmds::DrawElements& c = |
| 324 *static_cast<const gles2::cmds::DrawElements*>(cmd_data); |
| 325 GLenum mode = static_cast<GLenum>(c.mode); |
| 326 GLsizei count = static_cast<GLsizei>(c.count); |
| 327 GLenum type = static_cast<GLenum>(c.type); |
| 328 const GLvoid* indices = |
| 329 reinterpret_cast<const GLvoid*>(static_cast<uintptr_t>(c.index_offset)); |
| 330 error::Error error = DoDrawElements(mode, count, type, indices); |
| 331 if (error != error::kNoError) { |
| 332 return error; |
| 333 } |
| 334 return error::kNoError; |
| 335 } |
| 336 |
| 337 error::Error GLES2DecoderPassthroughImpl::HandleGetActiveAttrib( |
| 338 uint32_t immediate_data_size, |
| 339 const void* cmd_data) { |
| 340 const gles2::cmds::GetActiveAttrib& c = |
| 341 *static_cast<const gles2::cmds::GetActiveAttrib*>(cmd_data); |
| 342 GLuint program = static_cast<GLuint>(c.program); |
| 343 GLuint index = static_cast<GLuint>(c.index); |
| 344 uint32_t name_bucket_id = c.name_bucket_id; |
| 345 typedef cmds::GetActiveAttrib::Result Result; |
| 346 Result* result = GetSharedMemoryAs<Result*>( |
| 347 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 348 if (!result) { |
| 349 return error::kOutOfBounds; |
| 350 } |
| 351 // Check that the client initialized the result. |
| 352 if (result->success != 0) { |
| 353 return error::kInvalidArguments; |
| 354 } |
| 355 |
| 356 std::string name; |
| 357 error::Error error = |
| 358 DoGetActiveAttrib(program, index, &result->size, &result->type, &name); |
| 359 if (error != error::kNoError) { |
| 360 return error; |
| 361 } |
| 362 |
| 363 result->success = 1; // true. |
| 364 Bucket* bucket = CreateBucket(name_bucket_id); |
| 365 bucket->SetFromString(name.c_str()); |
| 366 return error::kNoError; |
| 367 } |
| 368 |
| 369 error::Error GLES2DecoderPassthroughImpl::HandleGetActiveUniform( |
| 370 uint32_t immediate_data_size, |
| 371 const void* cmd_data) { |
| 372 const gles2::cmds::GetActiveUniform& c = |
| 373 *static_cast<const gles2::cmds::GetActiveUniform*>(cmd_data); |
| 374 GLuint program = static_cast<GLuint>(c.program); |
| 375 GLuint index = static_cast<GLuint>(c.index); |
| 376 uint32_t name_bucket_id = c.name_bucket_id; |
| 377 typedef cmds::GetActiveUniform::Result Result; |
| 378 Result* result = GetSharedMemoryAs<Result*>( |
| 379 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 380 if (!result) { |
| 381 return error::kOutOfBounds; |
| 382 } |
| 383 // Check that the client initialized the result. |
| 384 if (result->success != 0) { |
| 385 return error::kInvalidArguments; |
| 386 } |
| 387 |
| 388 std::string name; |
| 389 error::Error error = |
| 390 DoGetActiveUniform(program, index, &result->size, &result->type, &name); |
| 391 if (error != error::kNoError) { |
| 392 return error; |
| 393 } |
| 394 |
| 395 result->success = 1; // true. |
| 396 Bucket* bucket = CreateBucket(name_bucket_id); |
| 397 bucket->SetFromString(name.c_str()); |
| 398 return error::kNoError; |
| 399 } |
| 400 |
| 401 error::Error GLES2DecoderPassthroughImpl::HandleGetActiveUniformBlockiv( |
| 402 uint32_t immediate_data_size, |
| 403 const void* cmd_data) { |
| 404 const gles2::cmds::GetActiveUniformBlockiv& c = |
| 405 *static_cast<const gles2::cmds::GetActiveUniformBlockiv*>(cmd_data); |
| 406 GLuint program = static_cast<GLuint>(c.program); |
| 407 GLuint uniformBlockIndex = static_cast<GLuint>(c.index); |
| 408 GLenum pname = static_cast<GLenum>(c.pname); |
| 409 unsigned int buffer_size = 0; |
| 410 typedef cmds::GetActiveUniformBlockiv::Result Result; |
| 411 Result* result = GetSharedMemoryAndSizeAs<Result*>( |
| 412 c.params_shm_id, c.params_shm_offset, &buffer_size); |
| 413 GLint* params = result ? result->GetData() : NULL; |
| 414 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); |
| 415 GLsizei length = 0; |
| 416 error::Error error = DoGetActiveUniformBlockiv( |
| 417 program, uniformBlockIndex, pname, bufsize, &length, params); |
| 418 if (error != error::kNoError) { |
| 419 return error; |
| 420 } |
| 421 if (length > bufsize) { |
| 422 return error::kOutOfBounds; |
| 423 } |
| 424 result->SetNumResults(length); |
| 425 return error::kNoError; |
| 426 } |
| 427 |
| 428 error::Error GLES2DecoderPassthroughImpl::HandleGetActiveUniformBlockName( |
| 429 uint32_t immediate_data_size, |
| 430 const void* cmd_data) { |
| 431 const gles2::cmds::GetActiveUniformBlockName& c = |
| 432 *static_cast<const gles2::cmds::GetActiveUniformBlockName*>(cmd_data); |
| 433 GLuint program = static_cast<GLuint>(c.program); |
| 434 GLuint uniformBlockIndex = static_cast<GLuint>(c.index); |
| 435 uint32_t name_bucket_id = c.name_bucket_id; |
| 436 typedef cmds::GetActiveUniformBlockName::Result Result; |
| 437 Result* result = GetSharedMemoryAs<Result*>( |
| 438 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 439 if (!result) { |
| 440 return error::kOutOfBounds; |
| 441 } |
| 442 // Check that the client initialized the result. |
| 443 if (*result != 0) { |
| 444 return error::kInvalidArguments; |
| 445 } |
| 446 |
| 447 std::string name; |
| 448 error::Error error = |
| 449 DoGetActiveUniformBlockName(program, uniformBlockIndex, &name); |
| 450 if (error != error::kNoError) { |
| 451 return error; |
| 452 } |
| 453 |
| 454 *result = 1; |
| 455 Bucket* bucket = CreateBucket(name_bucket_id); |
| 456 bucket->SetFromString(name.c_str()); |
| 457 return error::kNoError; |
| 458 } |
| 459 |
| 460 error::Error GLES2DecoderPassthroughImpl::HandleGetActiveUniformsiv( |
| 461 uint32_t immediate_data_size, |
| 462 const void* cmd_data) { |
| 463 const gles2::cmds::GetActiveUniformsiv& c = |
| 464 *static_cast<const gles2::cmds::GetActiveUniformsiv*>(cmd_data); |
| 465 GLuint program = static_cast<GLuint>(c.program); |
| 466 GLenum pname = static_cast<GLenum>(c.pname); |
| 467 Bucket* bucket = GetBucket(c.indices_bucket_id); |
| 468 if (!bucket) { |
| 469 return error::kInvalidArguments; |
| 470 } |
| 471 GLsizei uniformCount = static_cast<GLsizei>(bucket->size() / sizeof(GLuint)); |
| 472 const GLuint* indices = bucket->GetDataAs<const GLuint*>(0, bucket->size()); |
| 473 typedef cmds::GetActiveUniformsiv::Result Result; |
| 474 Result* result = GetSharedMemoryAs<Result*>( |
| 475 c.params_shm_id, c.params_shm_offset, Result::ComputeSize(uniformCount)); |
| 476 GLint* params = result ? result->GetData() : NULL; |
| 477 if (params == NULL) { |
| 478 return error::kOutOfBounds; |
| 479 } |
| 480 // Check that the client initialized the result. |
| 481 if (result->size != 0) { |
| 482 return error::kInvalidArguments; |
| 483 } |
| 484 |
| 485 GLsizei bufsize = uniformCount; |
| 486 GLsizei length = 0; |
| 487 error::Error error = DoGetActiveUniformsiv(program, uniformCount, indices, |
| 488 pname, bufsize, &length, params); |
| 489 if (error != error::kNoError) { |
| 490 return error; |
| 491 } |
| 492 |
| 493 result->SetNumResults(length); |
| 494 return error::kNoError; |
| 495 } |
| 496 |
| 497 error::Error GLES2DecoderPassthroughImpl::HandleGetAttachedShaders( |
| 498 uint32_t immediate_data_size, |
| 499 const void* cmd_data) { |
| 500 const gles2::cmds::GetAttachedShaders& c = |
| 501 *static_cast<const gles2::cmds::GetAttachedShaders*>(cmd_data); |
| 502 GLuint program = static_cast<GLuint>(c.program); |
| 503 typedef cmds::GetAttachedShaders::Result Result; |
| 504 uint32_t maxCount = Result::ComputeMaxResults(c.result_size); |
| 505 Result* result = GetSharedMemoryAs<Result*>( |
| 506 c.result_shm_id, c.result_shm_offset, Result::ComputeSize(maxCount)); |
| 507 if (!result) { |
| 508 return error::kOutOfBounds; |
| 509 } |
| 510 // Check that the client initialized the result. |
| 511 if (result->size != 0) { |
| 512 return error::kInvalidArguments; |
| 513 } |
| 514 GLsizei count = 0; |
| 515 error::Error error = |
| 516 DoGetAttachedShaders(program, maxCount, &count, result->GetData()); |
| 517 if (error != error::kNoError) { |
| 518 return error; |
| 519 } |
| 520 |
| 521 result->SetNumResults(count); |
| 522 return error::kNoError; |
| 523 } |
| 524 |
| 525 error::Error GLES2DecoderPassthroughImpl::HandleGetAttribLocation( |
| 526 uint32_t immediate_data_size, |
| 527 const void* cmd_data) { |
| 528 const gles2::cmds::GetAttribLocation& c = |
| 529 *static_cast<const gles2::cmds::GetAttribLocation*>(cmd_data); |
| 530 GLuint program = static_cast<GLuint>(c.program); |
| 531 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 532 if (!bucket) { |
| 533 return error::kInvalidArguments; |
| 534 } |
| 535 std::string name_str; |
| 536 if (!bucket->GetAsString(&name_str)) { |
| 537 return error::kInvalidArguments; |
| 538 } |
| 539 GLint* location = GetSharedMemoryAs<GLint*>( |
| 540 c.location_shm_id, c.location_shm_offset, sizeof(GLint)); |
| 541 if (!location) { |
| 542 return error::kOutOfBounds; |
| 543 } |
| 544 if (*location != -1) { |
| 545 return error::kInvalidArguments; |
| 546 } |
| 547 error::Error error = DoGetAttribLocation(program, name_str.c_str(), location); |
| 548 if (error != error::kNoError) { |
| 549 return error; |
| 550 } |
| 551 return error::kNoError; |
| 552 } |
| 553 |
| 554 error::Error GLES2DecoderPassthroughImpl::HandleGetFragDataLocation( |
| 555 uint32_t immediate_data_size, |
| 556 const void* cmd_data) { |
| 557 const gles2::cmds::GetFragDataLocation& c = |
| 558 *static_cast<const gles2::cmds::GetFragDataLocation*>(cmd_data); |
| 559 GLuint program = static_cast<GLuint>(c.program); |
| 560 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 561 if (!bucket) { |
| 562 return error::kInvalidArguments; |
| 563 } |
| 564 std::string name_str; |
| 565 if (!bucket->GetAsString(&name_str)) { |
| 566 return error::kInvalidArguments; |
| 567 } |
| 568 GLint* location = GetSharedMemoryAs<GLint*>( |
| 569 c.location_shm_id, c.location_shm_offset, sizeof(GLint)); |
| 570 if (!location) { |
| 571 return error::kOutOfBounds; |
| 572 } |
| 573 if (*location != -1) { |
| 574 return error::kInvalidArguments; |
| 575 } |
| 576 error::Error error = |
| 577 DoGetFragDataLocation(program, name_str.c_str(), location); |
| 578 if (error != error::kNoError) { |
| 579 return error; |
| 580 } |
| 581 return error::kNoError; |
| 582 } |
| 583 |
| 584 error::Error GLES2DecoderPassthroughImpl::HandleGetInternalformativ( |
| 585 uint32_t immediate_data_size, |
| 586 const void* cmd_data) { |
| 587 const gles2::cmds::GetInternalformativ& c = |
| 588 *static_cast<const gles2::cmds::GetInternalformativ*>(cmd_data); |
| 589 GLenum target = static_cast<GLenum>(c.target); |
| 590 GLenum internalformat = static_cast<GLenum>(c.format); |
| 591 GLenum pname = static_cast<GLenum>(c.pname); |
| 592 unsigned int buffer_size = 0; |
| 593 typedef cmds::GetInternalformativ::Result Result; |
| 594 Result* result = GetSharedMemoryAndSizeAs<Result*>( |
| 595 c.params_shm_id, c.params_shm_offset, &buffer_size); |
| 596 GLint* params = result ? result->GetData() : NULL; |
| 597 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); |
| 598 GLsizei length = 0; |
| 599 error::Error error = DoGetInternalformativ(target, internalformat, pname, |
| 600 bufsize, &length, params); |
| 601 if (error != error::kNoError) { |
| 602 return error; |
| 603 } |
| 604 if (length > bufsize) { |
| 605 return error::kOutOfBounds; |
| 606 } |
| 607 result->SetNumResults(length); |
| 608 return error::kNoError; |
| 609 } |
| 610 |
| 611 error::Error GLES2DecoderPassthroughImpl::HandleGetProgramInfoLog( |
| 612 uint32_t immediate_data_size, |
| 613 const void* cmd_data) { |
| 614 const gles2::cmds::GetProgramInfoLog& c = |
| 615 *static_cast<const gles2::cmds::GetProgramInfoLog*>(cmd_data); |
| 616 GLuint program = static_cast<GLuint>(c.program); |
| 617 uint32_t bucket_id = static_cast<uint32_t>(c.bucket_id); |
| 618 |
| 619 std::string infolog; |
| 620 error::Error error = DoGetProgramInfoLog(program, &infolog); |
| 621 if (error != error::kNoError) { |
| 622 return error; |
| 623 } |
| 624 |
| 625 Bucket* bucket = CreateBucket(bucket_id); |
| 626 bucket->SetFromString(infolog.c_str()); |
| 627 return error::kNoError; |
| 628 } |
| 629 |
| 630 error::Error GLES2DecoderPassthroughImpl::HandleGetShaderInfoLog( |
| 631 uint32_t immediate_data_size, |
| 632 const void* cmd_data) { |
| 633 const gles2::cmds::GetShaderInfoLog& c = |
| 634 *static_cast<const gles2::cmds::GetShaderInfoLog*>(cmd_data); |
| 635 GLuint shader = static_cast<GLuint>(c.shader); |
| 636 uint32_t bucket_id = static_cast<uint32_t>(c.bucket_id); |
| 637 |
| 638 std::string infolog; |
| 639 error::Error error = DoGetShaderInfoLog(shader, &infolog); |
| 640 if (error != error::kNoError) { |
| 641 return error; |
| 642 } |
| 643 |
| 644 Bucket* bucket = CreateBucket(bucket_id); |
| 645 bucket->SetFromString(infolog.c_str()); |
| 646 return error::kNoError; |
| 647 } |
| 648 |
| 649 error::Error GLES2DecoderPassthroughImpl::HandleGetShaderPrecisionFormat( |
| 650 uint32_t immediate_data_size, |
| 651 const void* cmd_data) { |
| 652 const gles2::cmds::GetShaderPrecisionFormat& c = |
| 653 *static_cast<const gles2::cmds::GetShaderPrecisionFormat*>(cmd_data); |
| 654 GLenum shader_type = static_cast<GLenum>(c.shadertype); |
| 655 GLenum precision_type = static_cast<GLenum>(c.precisiontype); |
| 656 typedef cmds::GetShaderPrecisionFormat::Result Result; |
| 657 Result* result = GetSharedMemoryAs<Result*>( |
| 658 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 659 if (!result) { |
| 660 return error::kOutOfBounds; |
| 661 } |
| 662 // Check that the client initialized the result. |
| 663 if (result->success != 0) { |
| 664 return error::kInvalidArguments; |
| 665 } |
| 666 |
| 667 GLint range[2] = {0, 0}; |
| 668 GLint precision = 0; |
| 669 error::Error error = DoGetShaderPrecisionFormat(shader_type, precision_type, |
| 670 range, &precision); |
| 671 if (error != error::kNoError) { |
| 672 return error; |
| 673 } |
| 674 |
| 675 result->success = 1; // true |
| 676 result->min_range = range[0]; |
| 677 result->max_range = range[1]; |
| 678 result->precision = precision; |
| 679 |
| 680 return error::kNoError; |
| 681 } |
| 682 |
| 683 error::Error GLES2DecoderPassthroughImpl::HandleGetShaderSource( |
| 684 uint32_t immediate_data_size, |
| 685 const void* cmd_data) { |
| 686 const gles2::cmds::GetShaderSource& c = |
| 687 *static_cast<const gles2::cmds::GetShaderSource*>(cmd_data); |
| 688 GLuint shader = static_cast<GLuint>(c.shader); |
| 689 uint32_t bucket_id = static_cast<uint32_t>(c.bucket_id); |
| 690 |
| 691 std::string source; |
| 692 error::Error error = DoGetShaderSource(shader, &source); |
| 693 if (error != error::kNoError) { |
| 694 return error; |
| 695 } |
| 696 |
| 697 Bucket* bucket = CreateBucket(bucket_id); |
| 698 bucket->SetFromString(source.c_str()); |
| 699 |
| 700 return error::kNoError; |
| 701 } |
| 702 error::Error GLES2DecoderPassthroughImpl::HandleGetString( |
| 703 uint32_t immediate_data_size, |
| 704 const void* cmd_data) { |
| 705 const gles2::cmds::GetString& c = |
| 706 *static_cast<const gles2::cmds::GetString*>(cmd_data); |
| 707 GLenum name = static_cast<GLenum>(c.name); |
| 708 |
| 709 const char* str = nullptr; |
| 710 error::Error error = DoGetString(name, &str); |
| 711 if (error != error::kNoError) { |
| 712 return error; |
| 713 } |
| 714 if (!str) { |
| 715 return error::kOutOfBounds; |
| 716 } |
| 717 Bucket* bucket = CreateBucket(c.bucket_id); |
| 718 bucket->SetFromString(str); |
| 719 |
| 720 return error::kNoError; |
| 721 } |
| 722 error::Error GLES2DecoderPassthroughImpl::HandleGetTransformFeedbackVarying( |
| 723 uint32_t immediate_data_size, |
| 724 const void* cmd_data) { |
| 725 const gles2::cmds::GetTransformFeedbackVarying& c = |
| 726 *static_cast<const gles2::cmds::GetTransformFeedbackVarying*>(cmd_data); |
| 727 GLuint program = static_cast<GLuint>(c.program); |
| 728 GLuint index = static_cast<GLuint>(c.index); |
| 729 uint32_t name_bucket_id = c.name_bucket_id; |
| 730 typedef cmds::GetTransformFeedbackVarying::Result Result; |
| 731 Result* result = GetSharedMemoryAs<Result*>( |
| 732 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 733 if (!result) { |
| 734 return error::kOutOfBounds; |
| 735 } |
| 736 // Check that the client initialized the result. |
| 737 if (result->success != 0) { |
| 738 return error::kInvalidArguments; |
| 739 } |
| 740 |
| 741 GLsizei size = 0; |
| 742 GLenum type = 0; |
| 743 std::string name; |
| 744 error::Error error = |
| 745 DoGetTransformFeedbackVarying(program, index, &size, &type, &name); |
| 746 if (error != error::kNoError) { |
| 747 return error; |
| 748 } |
| 749 |
| 750 result->success = 1; // true. |
| 751 result->size = static_cast<int32_t>(size); |
| 752 result->type = static_cast<uint32_t>(type); |
| 753 Bucket* bucket = CreateBucket(name_bucket_id); |
| 754 bucket->SetFromString(name.c_str()); |
| 755 return error::kNoError; |
| 756 } |
| 757 |
| 758 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformBlockIndex( |
| 759 uint32_t immediate_data_size, |
| 760 const void* cmd_data) { |
| 761 const gles2::cmds::GetUniformBlockIndex& c = |
| 762 *static_cast<const gles2::cmds::GetUniformBlockIndex*>(cmd_data); |
| 763 GLuint program = static_cast<GLuint>(c.program); |
| 764 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 765 if (!bucket) { |
| 766 return error::kInvalidArguments; |
| 767 } |
| 768 std::string name_str; |
| 769 if (!bucket->GetAsString(&name_str)) { |
| 770 return error::kInvalidArguments; |
| 771 } |
| 772 GLint* index = GetSharedMemoryAs<GLint*>(c.index_shm_id, c.index_shm_offset, |
| 773 sizeof(GLint)); |
| 774 if (!index) { |
| 775 return error::kOutOfBounds; |
| 776 } |
| 777 if (*index != -1) { |
| 778 return error::kInvalidArguments; |
| 779 } |
| 780 error::Error error = DoGetUniformBlockIndex(program, name_str.c_str(), index); |
| 781 if (error != error::kNoError) { |
| 782 return error; |
| 783 } |
| 784 return error::kNoError; |
| 785 } |
| 786 |
| 787 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformfv( |
| 788 uint32_t immediate_data_size, |
| 789 const void* cmd_data) { |
| 790 const gles2::cmds::GetUniformfv& c = |
| 791 *static_cast<const gles2::cmds::GetUniformfv*>(cmd_data); |
| 792 GLuint program = static_cast<GLuint>(c.program); |
| 793 GLint location = static_cast<GLint>(c.location); |
| 794 unsigned int buffer_size = 0; |
| 795 typedef cmds::GetUniformfv::Result Result; |
| 796 Result* result = GetSharedMemoryAndSizeAs<Result*>( |
| 797 c.params_shm_id, c.params_shm_offset, &buffer_size); |
| 798 GLfloat* params = result ? result->GetData() : NULL; |
| 799 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); |
| 800 GLsizei length = 0; |
| 801 error::Error error = |
| 802 DoGetUniformfv(program, location, bufsize, &length, params); |
| 803 if (error != error::kNoError) { |
| 804 return error; |
| 805 } |
| 806 if (length > bufsize) { |
| 807 return error::kOutOfBounds; |
| 808 } |
| 809 result->SetNumResults(length); |
| 810 return error::kNoError; |
| 811 } |
| 812 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformiv( |
| 813 uint32_t immediate_data_size, |
| 814 const void* cmd_data) { |
| 815 const gles2::cmds::GetUniformiv& c = |
| 816 *static_cast<const gles2::cmds::GetUniformiv*>(cmd_data); |
| 817 GLuint program = static_cast<GLuint>(c.program); |
| 818 GLint location = static_cast<GLint>(c.location); |
| 819 unsigned int buffer_size = 0; |
| 820 typedef cmds::GetUniformiv::Result Result; |
| 821 Result* result = GetSharedMemoryAndSizeAs<Result*>( |
| 822 c.params_shm_id, c.params_shm_offset, &buffer_size); |
| 823 GLint* params = result ? result->GetData() : NULL; |
| 824 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); |
| 825 GLsizei length = 0; |
| 826 error::Error error = |
| 827 DoGetUniformiv(program, location, bufsize, &length, params); |
| 828 if (error != error::kNoError) { |
| 829 return error; |
| 830 } |
| 831 if (length > bufsize) { |
| 832 return error::kOutOfBounds; |
| 833 } |
| 834 result->SetNumResults(length); |
| 835 return error::kNoError; |
| 836 } |
| 837 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformuiv( |
| 838 uint32_t immediate_data_size, |
| 839 const void* cmd_data) { |
| 840 const gles2::cmds::GetUniformuiv& c = |
| 841 *static_cast<const gles2::cmds::GetUniformuiv*>(cmd_data); |
| 842 GLuint program = static_cast<GLuint>(c.program); |
| 843 GLint location = static_cast<GLint>(c.location); |
| 844 unsigned int buffer_size = 0; |
| 845 typedef cmds::GetUniformuiv::Result Result; |
| 846 Result* result = GetSharedMemoryAndSizeAs<Result*>( |
| 847 c.params_shm_id, c.params_shm_offset, &buffer_size); |
| 848 GLuint* params = result ? result->GetData() : NULL; |
| 849 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); |
| 850 GLsizei length = 0; |
| 851 error::Error error = |
| 852 DoGetUniformuiv(program, location, bufsize, &length, params); |
| 853 if (error != error::kNoError) { |
| 854 return error; |
| 855 } |
| 856 if (length > bufsize) { |
| 857 return error::kOutOfBounds; |
| 858 } |
| 859 result->SetNumResults(length); |
| 860 return error::kNoError; |
| 861 } |
| 862 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformIndices( |
| 863 uint32_t immediate_data_size, |
| 864 const void* cmd_data) { |
| 865 const gles2::cmds::GetUniformIndices& c = |
| 866 *static_cast<const gles2::cmds::GetUniformIndices*>(cmd_data); |
| 867 GLuint program = static_cast<GLuint>(c.program); |
| 868 Bucket* bucket = GetBucket(c.names_bucket_id); |
| 869 if (!bucket) { |
| 870 return error::kInvalidArguments; |
| 871 } |
| 872 GLsizei count = 0; |
| 873 std::vector<char*> names; |
| 874 std::vector<GLint> len; |
| 875 if (!bucket->GetAsStrings(&count, &names, &len) || count <= 0) { |
| 876 return error::kInvalidArguments; |
| 877 } |
| 878 typedef cmds::GetUniformIndices::Result Result; |
| 879 Result* result = GetSharedMemoryAs<Result*>( |
| 880 c.indices_shm_id, c.indices_shm_offset, |
| 881 Result::ComputeSize(static_cast<size_t>(count))); |
| 882 GLuint* indices = result ? result->GetData() : NULL; |
| 883 if (indices == NULL) { |
| 884 return error::kOutOfBounds; |
| 885 } |
| 886 // Check that the client initialized the result. |
| 887 if (result->size != 0) { |
| 888 return error::kInvalidArguments; |
| 889 } |
| 890 GLsizei length = 0; |
| 891 error::Error error = |
| 892 DoGetUniformIndices(program, count, &names[0], count, &length, indices); |
| 893 if (error != error::kNoError) { |
| 894 return error; |
| 895 } |
| 896 if (length != count) { |
| 897 return error::kOutOfBounds; |
| 898 } |
| 899 result->SetNumResults(length); |
| 900 return error::kNoError; |
| 901 } |
| 902 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformLocation( |
| 903 uint32_t immediate_data_size, |
| 904 const void* cmd_data) { |
| 905 const gles2::cmds::GetUniformLocation& c = |
| 906 *static_cast<const gles2::cmds::GetUniformLocation*>(cmd_data); |
| 907 GLuint program = static_cast<GLuint>(c.program); |
| 908 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 909 if (!bucket) { |
| 910 return error::kInvalidArguments; |
| 911 } |
| 912 std::string name_str; |
| 913 if (!bucket->GetAsString(&name_str)) { |
| 914 return error::kInvalidArguments; |
| 915 } |
| 916 GLint* location = GetSharedMemoryAs<GLint*>( |
| 917 c.location_shm_id, c.location_shm_offset, sizeof(GLint)); |
| 918 if (!location) { |
| 919 return error::kOutOfBounds; |
| 920 } |
| 921 if (*location != -1) { |
| 922 return error::kInvalidArguments; |
| 923 } |
| 924 error::Error error = |
| 925 DoGetUniformLocation(program, name_str.c_str(), location); |
| 926 if (error != error::kNoError) { |
| 927 return error; |
| 928 } |
| 929 return error::kNoError; |
| 930 } |
| 931 error::Error GLES2DecoderPassthroughImpl::HandleGetVertexAttribPointerv( |
| 932 uint32_t immediate_data_size, |
| 933 const void* cmd_data) { |
| 934 const gles2::cmds::GetVertexAttribPointerv& c = |
| 935 *static_cast<const gles2::cmds::GetVertexAttribPointerv*>(cmd_data); |
| 936 GLuint index = static_cast<GLuint>(c.index); |
| 937 GLenum pname = static_cast<GLenum>(c.pname); |
| 938 unsigned int buffer_size = 0; |
| 939 typedef cmds::GetVertexAttribPointerv::Result Result; |
| 940 Result* result = GetSharedMemoryAndSizeAs<Result*>( |
| 941 c.pointer_shm_id, c.pointer_shm_offset, &buffer_size); |
| 942 GLuint* params = result ? result->GetData() : NULL; |
| 943 GLsizei bufsize = Result::ComputeMaxResults(buffer_size); |
| 944 GLsizei length = 0; |
| 945 error::Error error = |
| 946 DoGetVertexAttribPointerv(index, pname, bufsize, &length, params); |
| 947 if (error != error::kNoError) { |
| 948 return error; |
| 949 } |
| 950 if (length > bufsize) { |
| 951 return error::kOutOfBounds; |
| 952 } |
| 953 result->SetNumResults(length); |
| 954 return error::kNoError; |
| 955 } |
| 956 error::Error GLES2DecoderPassthroughImpl::HandlePixelStorei( |
| 957 uint32_t immediate_data_size, |
| 958 const void* cmd_data) { |
| 959 const gles2::cmds::PixelStorei& c = |
| 960 *static_cast<const gles2::cmds::PixelStorei*>(cmd_data); |
| 961 GLenum pname = static_cast<GLuint>(c.pname); |
| 962 GLint param = static_cast<GLint>(c.param); |
| 963 error::Error error = DoPixelStorei(pname, param); |
| 964 if (error != error::kNoError) { |
| 965 return error; |
| 966 } |
| 967 return error::kNoError; |
| 968 } |
| 969 error::Error GLES2DecoderPassthroughImpl::HandleReadPixels( |
| 970 uint32_t immediate_data_size, |
| 971 const void* cmd_data) { |
| 972 const gles2::cmds::ReadPixels& c = |
| 973 *static_cast<const gles2::cmds::ReadPixels*>(cmd_data); |
| 974 GLint x = static_cast<GLint>(c.x); |
| 975 GLint y = static_cast<GLint>(c.y); |
| 976 GLsizei width = static_cast<GLsizei>(c.width); |
| 977 GLsizei height = static_cast<GLsizei>(c.height); |
| 978 GLenum format = static_cast<GLenum>(c.format); |
| 979 GLenum type = static_cast<GLenum>(c.type); |
| 980 |
| 981 uint8_t* pixels = nullptr; |
| 982 unsigned int buffer_size = 0; |
| 983 if (c.pixels_shm_id != 0) { |
| 984 pixels = GetSharedMemoryAndSizeAs<uint8_t*>( |
| 985 c.pixels_shm_id, c.pixels_shm_offset, &buffer_size); |
| 986 if (!pixels) { |
| 987 return error::kOutOfBounds; |
| 988 } |
| 989 } |
| 990 |
| 991 GLsizei bufsize = buffer_size; |
| 992 GLsizei length = 0; |
| 993 error::Error error = |
| 994 DoReadPixels(x, y, width, height, format, type, bufsize, &length, pixels); |
| 995 if (error != error::kNoError) { |
| 996 return error; |
| 997 } |
| 998 if (length > bufsize) { |
| 999 return error::kOutOfBounds; |
| 1000 } |
| 1001 |
| 1002 typedef cmds::ReadPixels::Result Result; |
| 1003 Result* result = nullptr; |
| 1004 if (c.result_shm_id != 0) { |
| 1005 result = GetSharedMemoryAs<Result*>(c.result_shm_id, c.result_shm_offset, |
| 1006 sizeof(*result)); |
| 1007 if (!result) { |
| 1008 return error::kOutOfBounds; |
| 1009 } |
| 1010 if (result->success != 0) { |
| 1011 return error::kInvalidArguments; |
| 1012 } |
| 1013 } |
| 1014 |
| 1015 if (result) { |
| 1016 result->success = 1; |
| 1017 result->row_length = static_cast<uint32_t>(width); |
| 1018 result->num_rows = static_cast<uint32_t>(height); |
| 1019 } |
| 1020 |
| 1021 return error::kNoError; |
| 1022 } |
| 1023 error::Error GLES2DecoderPassthroughImpl::HandleShaderBinary( |
| 1024 uint32_t immediate_data_size, |
| 1025 const void* cmd_data) { |
| 1026 const gles2::cmds::ShaderBinary& c = |
| 1027 *static_cast<const gles2::cmds::ShaderBinary*>(cmd_data); |
| 1028 GLsizei n = static_cast<GLsizei>(c.n); |
| 1029 GLsizei length = static_cast<GLsizei>(c.length); |
| 1030 uint32_t data_size; |
| 1031 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { |
| 1032 return error::kOutOfBounds; |
| 1033 } |
| 1034 const GLuint* shaders = GetSharedMemoryAs<const GLuint*>( |
| 1035 c.shaders_shm_id, c.shaders_shm_offset, data_size); |
| 1036 GLenum binaryformat = static_cast<GLenum>(c.binaryformat); |
| 1037 const void* binary = GetSharedMemoryAs<const void*>( |
| 1038 c.binary_shm_id, c.binary_shm_offset, length); |
| 1039 if (shaders == NULL || binary == NULL) { |
| 1040 return error::kOutOfBounds; |
| 1041 } |
| 1042 |
| 1043 error::Error error = DoShaderBinary(n, shaders, binaryformat, binary, length); |
| 1044 if (error != error::kNoError) { |
| 1045 return error; |
| 1046 } |
| 1047 |
| 1048 return error::kNoError; |
| 1049 } |
| 1050 error::Error GLES2DecoderPassthroughImpl::HandleTexImage2D( |
| 1051 uint32_t immediate_data_size, |
| 1052 const void* cmd_data) { |
| 1053 const gles2::cmds::TexImage2D& c = |
| 1054 *static_cast<const gles2::cmds::TexImage2D*>(cmd_data); |
| 1055 GLenum target = static_cast<GLenum>(c.target); |
| 1056 GLint level = static_cast<GLint>(c.level); |
| 1057 GLint internal_format = static_cast<GLint>(c.internalformat); |
| 1058 GLsizei width = static_cast<GLsizei>(c.width); |
| 1059 GLsizei height = static_cast<GLsizei>(c.height); |
| 1060 GLint border = static_cast<GLint>(c.border); |
| 1061 GLenum format = static_cast<GLenum>(c.format); |
| 1062 GLenum type = static_cast<GLenum>(c.type); |
| 1063 |
| 1064 GLsizei imagesize = 0; |
| 1065 const void* pixels = NULL; |
| 1066 if (c.pixels_shm_id != 0 || c.pixels_shm_offset != 0) { |
| 1067 unsigned int buffer_size = 0; |
| 1068 pixels = GetSharedMemoryAndSizeAs<uint8_t*>( |
| 1069 c.pixels_shm_id, c.pixels_shm_offset, &buffer_size); |
| 1070 if (!pixels) { |
| 1071 return error::kOutOfBounds; |
| 1072 } |
| 1073 imagesize = buffer_size; |
| 1074 } |
| 1075 |
| 1076 error::Error error = |
| 1077 DoTexImage2D(target, level, internal_format, width, height, border, |
| 1078 format, type, imagesize, pixels); |
| 1079 if (error != error::kNoError) { |
| 1080 return error; |
| 1081 } |
| 1082 |
| 1083 return error::kNoError; |
| 1084 } |
| 1085 |
| 1086 error::Error GLES2DecoderPassthroughImpl::HandleTexImage3D( |
| 1087 uint32_t immediate_data_size, |
| 1088 const void* cmd_data) { |
| 1089 const gles2::cmds::TexImage3D& c = |
| 1090 *static_cast<const gles2::cmds::TexImage3D*>(cmd_data); |
| 1091 GLenum target = static_cast<GLenum>(c.target); |
| 1092 GLint level = static_cast<GLint>(c.level); |
| 1093 GLint internal_format = static_cast<GLint>(c.internalformat); |
| 1094 GLsizei width = static_cast<GLsizei>(c.width); |
| 1095 GLsizei height = static_cast<GLsizei>(c.height); |
| 1096 GLsizei depth = static_cast<GLsizei>(c.depth); |
| 1097 GLint border = static_cast<GLint>(c.border); |
| 1098 GLenum format = static_cast<GLenum>(c.format); |
| 1099 GLenum type = static_cast<GLenum>(c.type); |
| 1100 |
| 1101 GLsizei imagesize = 0; |
| 1102 const void* pixels = NULL; |
| 1103 if (c.pixels_shm_id != 0 || c.pixels_shm_offset != 0) { |
| 1104 unsigned int buffer_size = 0; |
| 1105 pixels = GetSharedMemoryAndSizeAs<uint8_t*>( |
| 1106 c.pixels_shm_id, c.pixels_shm_offset, &buffer_size); |
| 1107 if (!pixels) { |
| 1108 return error::kOutOfBounds; |
| 1109 } |
| 1110 imagesize = buffer_size; |
| 1111 } |
| 1112 |
| 1113 error::Error error = |
| 1114 DoTexImage3D(target, level, internal_format, width, height, depth, border, |
| 1115 format, type, imagesize, pixels); |
| 1116 if (error != error::kNoError) { |
| 1117 return error; |
| 1118 } |
| 1119 |
| 1120 return error::kNoError; |
| 1121 } |
| 1122 |
| 1123 error::Error GLES2DecoderPassthroughImpl::HandleTexSubImage2D( |
| 1124 uint32_t immediate_data_size, |
| 1125 const void* cmd_data) { |
| 1126 const gles2::cmds::TexSubImage2D& c = |
| 1127 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); |
| 1128 GLenum target = static_cast<GLenum>(c.target); |
| 1129 GLint level = static_cast<GLint>(c.level); |
| 1130 GLint xoffset = static_cast<GLint>(c.xoffset); |
| 1131 GLint yoffset = static_cast<GLint>(c.yoffset); |
| 1132 GLsizei width = static_cast<GLsizei>(c.width); |
| 1133 GLsizei height = static_cast<GLsizei>(c.height); |
| 1134 GLenum format = static_cast<GLenum>(c.format); |
| 1135 GLenum type = static_cast<GLenum>(c.type); |
| 1136 |
| 1137 unsigned int buffer_size = 0; |
| 1138 const void* pixels = GetSharedMemoryAndSizeAs<uint8_t*>( |
| 1139 c.pixels_shm_id, c.pixels_shm_offset, &buffer_size); |
| 1140 if (!pixels) { |
| 1141 return error::kOutOfBounds; |
| 1142 } |
| 1143 GLsizei imagesize = buffer_size; |
| 1144 |
| 1145 error::Error error = DoTexSubImage2D(target, level, xoffset, yoffset, width, |
| 1146 height, format, type, imagesize, pixels); |
| 1147 if (error != error::kNoError) { |
| 1148 return error; |
| 1149 } |
| 1150 |
| 1151 return error::kNoError; |
| 1152 } |
| 1153 |
| 1154 error::Error GLES2DecoderPassthroughImpl::HandleTexSubImage3D( |
| 1155 uint32_t immediate_data_size, |
| 1156 const void* cmd_data) { |
| 1157 const gles2::cmds::TexSubImage3D& c = |
| 1158 *static_cast<const gles2::cmds::TexSubImage3D*>(cmd_data); |
| 1159 GLenum target = static_cast<GLenum>(c.target); |
| 1160 GLint level = static_cast<GLint>(c.level); |
| 1161 GLint xoffset = static_cast<GLint>(c.xoffset); |
| 1162 GLint yoffset = static_cast<GLint>(c.yoffset); |
| 1163 GLint zoffset = static_cast<GLint>(c.zoffset); |
| 1164 GLsizei width = static_cast<GLsizei>(c.width); |
| 1165 GLsizei height = static_cast<GLsizei>(c.height); |
| 1166 GLsizei depth = static_cast<GLsizei>(c.depth); |
| 1167 GLenum format = static_cast<GLenum>(c.format); |
| 1168 GLenum type = static_cast<GLenum>(c.type); |
| 1169 |
| 1170 unsigned int buffer_size = 0; |
| 1171 const void* pixels = GetSharedMemoryAndSizeAs<uint8_t*>( |
| 1172 c.pixels_shm_id, c.pixels_shm_offset, &buffer_size); |
| 1173 if (!pixels) { |
| 1174 return error::kOutOfBounds; |
| 1175 } |
| 1176 GLsizei imagesize = buffer_size; |
| 1177 |
| 1178 error::Error error = |
| 1179 DoTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, |
| 1180 depth, format, type, imagesize, pixels); |
| 1181 if (error != error::kNoError) { |
| 1182 return error; |
| 1183 } |
| 1184 |
| 1185 return error::kNoError; |
| 1186 } |
| 1187 |
| 1188 error::Error GLES2DecoderPassthroughImpl::HandleUniformBlockBinding( |
| 1189 uint32_t immediate_data_size, |
| 1190 const void* cmd_data) { |
| 1191 const gles2::cmds::UniformBlockBinding& c = |
| 1192 *static_cast<const gles2::cmds::UniformBlockBinding*>(cmd_data); |
| 1193 GLuint program = static_cast<GLuint>(c.program); |
| 1194 GLuint index = static_cast<GLuint>(c.index); |
| 1195 GLuint binding = static_cast<GLuint>(c.binding); |
| 1196 |
| 1197 error::Error error = DoUniformBlockBinding(program, index, binding); |
| 1198 if (error != error::kNoError) { |
| 1199 return error; |
| 1200 } |
| 1201 |
| 1202 return error::kNoError; |
| 1203 } |
| 1204 |
| 1205 error::Error GLES2DecoderPassthroughImpl::HandleVertexAttribIPointer( |
| 1206 uint32_t immediate_data_size, |
| 1207 const void* cmd_data) { |
| 1208 const gles2::cmds::VertexAttribIPointer& c = |
| 1209 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); |
| 1210 GLuint index = static_cast<GLuint>(c.indx); |
| 1211 GLint size = static_cast<GLint>(c.size); |
| 1212 GLenum type = static_cast<GLenum>(c.type); |
| 1213 GLsizei stride = static_cast<GLsizei>(c.stride); |
| 1214 GLsizei offset = static_cast<GLsizei>(c.offset); |
| 1215 const void* ptr = reinterpret_cast<const void*>(offset); |
| 1216 |
| 1217 error::Error error = DoVertexAttribIPointer(index, size, type, stride, ptr); |
| 1218 if (error != error::kNoError) { |
| 1219 return error; |
| 1220 } |
| 1221 |
| 1222 return error::kNoError; |
| 1223 } |
| 1224 |
| 1225 error::Error GLES2DecoderPassthroughImpl::HandleVertexAttribPointer( |
| 1226 uint32_t immediate_data_size, |
| 1227 const void* cmd_data) { |
| 1228 const gles2::cmds::VertexAttribPointer& c = |
| 1229 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); |
| 1230 GLuint index = static_cast<GLuint>(c.indx); |
| 1231 GLint size = static_cast<GLint>(c.size); |
| 1232 GLenum type = static_cast<GLenum>(c.type); |
| 1233 GLboolean normalized = static_cast<GLenum>(c.normalized); |
| 1234 GLsizei stride = static_cast<GLsizei>(c.stride); |
| 1235 GLsizei offset = static_cast<GLsizei>(c.offset); |
| 1236 const void* ptr = reinterpret_cast<const void*>(offset); |
| 1237 |
| 1238 error::Error error = |
| 1239 DoVertexAttribPointer(index, size, type, normalized, stride, ptr); |
| 1240 if (error != error::kNoError) { |
| 1241 return error; |
| 1242 } |
| 1243 |
| 1244 return error::kNoError; |
| 1245 } |
| 1246 |
| 1247 error::Error GLES2DecoderPassthroughImpl::HandleWaitSync( |
| 1248 uint32_t immediate_data_size, |
| 1249 const void* cmd_data) { |
| 1250 const gles2::cmds::WaitSync& c = |
| 1251 *static_cast<const gles2::cmds::WaitSync*>(cmd_data); |
| 1252 const GLuint sync = static_cast<GLuint>(c.sync); |
| 1253 const GLbitfield flags = static_cast<GLbitfield>(c.flags); |
| 1254 const GLuint64 timeout = c.timeout(); |
| 1255 |
| 1256 error::Error error = DoWaitSync(sync, flags, timeout); |
| 1257 if (error != error::kNoError) { |
| 1258 return error; |
| 1259 } |
| 1260 |
| 1261 return error::kNoError; |
| 1262 } |
| 1263 |
| 1264 error::Error GLES2DecoderPassthroughImpl::HandleQueryCounterEXT( |
| 1265 uint32_t immediate_data_size, |
| 1266 const void* cmd_data) { |
| 1267 const gles2::cmds::QueryCounterEXT& c = |
| 1268 *static_cast<const gles2::cmds::QueryCounterEXT*>(cmd_data); |
| 1269 GLuint id = static_cast<GLuint>(c.id); |
| 1270 GLenum target = static_cast<GLenum>(c.target); |
| 1271 |
| 1272 error::Error error = DoQueryCounterEXT(id, target); |
| 1273 if (error != error::kNoError) { |
| 1274 return error; |
| 1275 } |
| 1276 |
| 1277 return error::kNoError; |
| 1278 } |
| 1279 |
| 1280 error::Error GLES2DecoderPassthroughImpl::HandleBeginQueryEXT( |
| 1281 uint32_t immediate_data_size, |
| 1282 const void* cmd_data) { |
| 1283 const gles2::cmds::BeginQueryEXT& c = |
| 1284 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data); |
| 1285 GLenum target = static_cast<GLenum>(c.target); |
| 1286 GLuint id = static_cast<GLuint>(c.id); |
| 1287 |
| 1288 error::Error error = DoBeginQueryEXT(target, id); |
| 1289 if (error != error::kNoError) { |
| 1290 return error; |
| 1291 } |
| 1292 |
| 1293 return error::kNoError; |
| 1294 } |
| 1295 |
| 1296 error::Error GLES2DecoderPassthroughImpl::HandleEndQueryEXT( |
| 1297 uint32_t immediate_data_size, |
| 1298 const void* cmd_data) { |
| 1299 const gles2::cmds::EndQueryEXT& c = |
| 1300 *static_cast<const gles2::cmds::EndQueryEXT*>(cmd_data); |
| 1301 GLenum target = static_cast<GLenum>(c.target); |
| 1302 |
| 1303 error::Error error = DoEndQueryEXT(target); |
| 1304 if (error != error::kNoError) { |
| 1305 return error; |
| 1306 } |
| 1307 |
| 1308 return error::kNoError; |
| 1309 } |
| 1310 |
| 1311 error::Error GLES2DecoderPassthroughImpl::HandleSetDisjointValueSyncCHROMIUM( |
| 1312 uint32_t immediate_data_size, |
| 1313 const void* cmd_data) { |
| 1314 const gles2::cmds::SetDisjointValueSyncCHROMIUM& c = |
| 1315 *static_cast<const gles2::cmds::SetDisjointValueSyncCHROMIUM*>(cmd_data); |
| 1316 DisjointValueSync* sync = GetSharedMemoryAs<DisjointValueSync*>( |
| 1317 c.sync_data_shm_id, c.sync_data_shm_offset, sizeof(*sync)); |
| 1318 if (!sync) { |
| 1319 return error::kOutOfBounds; |
| 1320 } |
| 1321 error::Error error = DoSetDisjointValueSyncCHROMIUM(sync); |
| 1322 if (error != error::kNoError) { |
| 1323 return error; |
| 1324 } |
| 1325 return error::kNoError; |
| 1326 } |
| 1327 |
| 1328 error::Error GLES2DecoderPassthroughImpl::HandleInsertEventMarkerEXT( |
| 1329 uint32_t immediate_data_size, |
| 1330 const void* cmd_data) { |
| 1331 const gles2::cmds::InsertEventMarkerEXT& c = |
| 1332 *static_cast<const gles2::cmds::InsertEventMarkerEXT*>(cmd_data); |
| 1333 GLuint bucket_id = static_cast<GLuint>(c.bucket_id); |
| 1334 Bucket* bucket = GetBucket(bucket_id); |
| 1335 if (!bucket || bucket->size() == 0) { |
| 1336 return error::kInvalidArguments; |
| 1337 } |
| 1338 std::string str; |
| 1339 if (!bucket->GetAsString(&str)) { |
| 1340 return error::kInvalidArguments; |
| 1341 } |
| 1342 error::Error error = DoInsertEventMarkerEXT(0, str.c_str()); |
| 1343 if (error != error::kNoError) { |
| 1344 return error; |
| 1345 } |
| 1346 return error::kNoError; |
| 1347 } |
| 1348 |
| 1349 error::Error GLES2DecoderPassthroughImpl::HandlePushGroupMarkerEXT( |
| 1350 uint32_t immediate_data_size, |
| 1351 const void* cmd_data) { |
| 1352 const gles2::cmds::PushGroupMarkerEXT& c = |
| 1353 *static_cast<const gles2::cmds::PushGroupMarkerEXT*>(cmd_data); |
| 1354 GLuint bucket_id = static_cast<GLuint>(c.bucket_id); |
| 1355 Bucket* bucket = GetBucket(bucket_id); |
| 1356 if (!bucket || bucket->size() == 0) { |
| 1357 return error::kInvalidArguments; |
| 1358 } |
| 1359 std::string str; |
| 1360 if (!bucket->GetAsString(&str)) { |
| 1361 return error::kInvalidArguments; |
| 1362 } |
| 1363 error::Error error = DoPushGroupMarkerEXT(0, str.c_str()); |
| 1364 if (error != error::kNoError) { |
| 1365 return error; |
| 1366 } |
| 1367 return error::kNoError; |
| 1368 } |
| 1369 error::Error GLES2DecoderPassthroughImpl::HandleEnableFeatureCHROMIUM( |
| 1370 uint32_t immediate_data_size, |
| 1371 const void* cmd_data) { |
| 1372 const gles2::cmds::EnableFeatureCHROMIUM& c = |
| 1373 *static_cast<const gles2::cmds::EnableFeatureCHROMIUM*>(cmd_data); |
| 1374 Bucket* bucket = GetBucket(c.bucket_id); |
| 1375 if (!bucket || bucket->size() == 0) { |
| 1376 return error::kInvalidArguments; |
| 1377 } |
| 1378 typedef cmds::EnableFeatureCHROMIUM::Result Result; |
| 1379 Result* result = GetSharedMemoryAs<Result*>( |
| 1380 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 1381 if (!result) { |
| 1382 return error::kOutOfBounds; |
| 1383 } |
| 1384 // Check that the client initialized the result. |
| 1385 if (*result != 0) { |
| 1386 return error::kInvalidArguments; |
| 1387 } |
| 1388 std::string feature_str; |
| 1389 if (!bucket->GetAsString(&feature_str)) { |
| 1390 return error::kInvalidArguments; |
| 1391 } |
| 1392 error::Error error = DoEnableFeatureCHROMIUM(feature_str.c_str()); |
| 1393 if (error != error::kNoError) { |
| 1394 return error; |
| 1395 } |
| 1396 |
| 1397 *result = 1; // true. |
| 1398 return error::kNoError; |
| 1399 } |
| 1400 error::Error GLES2DecoderPassthroughImpl::HandleMapBufferRange( |
| 1401 uint32_t immediate_data_size, |
| 1402 const void* cmd_data) { |
| 1403 const gles2::cmds::MapBufferRange& c = |
| 1404 *static_cast<const gles2::cmds::MapBufferRange*>(cmd_data); |
| 1405 GLenum target = static_cast<GLenum>(c.target); |
| 1406 GLbitfield access = static_cast<GLbitfield>(c.access); |
| 1407 GLintptr offset = static_cast<GLintptr>(c.offset); |
| 1408 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); |
| 1409 |
| 1410 typedef cmds::MapBufferRange::Result Result; |
| 1411 Result* result = GetSharedMemoryAs<Result*>( |
| 1412 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 1413 if (!result) { |
| 1414 return error::kOutOfBounds; |
| 1415 } |
| 1416 if (*result != 0) { |
| 1417 *result = 0; |
| 1418 return error::kInvalidArguments; |
| 1419 } |
| 1420 uint8_t* mem = |
| 1421 GetSharedMemoryAs<uint8_t*>(c.data_shm_id, c.data_shm_offset, size); |
| 1422 if (!mem) { |
| 1423 return error::kOutOfBounds; |
| 1424 } |
| 1425 |
| 1426 void* ptr = nullptr; |
| 1427 error::Error error = DoMapBufferRange(target, offset, size, access, &ptr); |
| 1428 if (error != error::kNoError) { |
| 1429 return error; |
| 1430 } |
| 1431 |
| 1432 *result = 1; |
| 1433 return error::kNoError; |
| 1434 } |
| 1435 |
| 1436 error::Error GLES2DecoderPassthroughImpl::HandleUnmapBuffer( |
| 1437 uint32_t immediate_data_size, |
| 1438 const void* cmd_data) { |
| 1439 const gles2::cmds::UnmapBuffer& c = |
| 1440 *static_cast<const gles2::cmds::UnmapBuffer*>(cmd_data); |
| 1441 GLenum target = static_cast<GLenum>(c.target); |
| 1442 error::Error error = DoUnmapBuffer(target); |
| 1443 if (error != error::kNoError) { |
| 1444 return error; |
| 1445 } |
| 1446 return error::kNoError; |
| 1447 } |
| 1448 |
| 1449 error::Error GLES2DecoderPassthroughImpl::HandleResizeCHROMIUM( |
| 1450 uint32_t immediate_data_size, |
| 1451 const void* cmd_data) { |
| 1452 const gles2::cmds::ResizeCHROMIUM& c = |
| 1453 *static_cast<const gles2::cmds::ResizeCHROMIUM*>(cmd_data); |
| 1454 GLuint width = static_cast<GLuint>(c.width); |
| 1455 GLuint height = static_cast<GLuint>(c.height); |
| 1456 GLfloat scale_factor = static_cast<GLfloat>(c.scale_factor); |
| 1457 GLboolean has_alpha = static_cast<GLboolean>(c.alpha); |
| 1458 error::Error error = DoResizeCHROMIUM(width, height, scale_factor, has_alpha); |
| 1459 if (error != error::kNoError) { |
| 1460 return error; |
| 1461 } |
| 1462 return error::kNoError; |
| 1463 } |
| 1464 |
| 1465 error::Error |
| 1466 GLES2DecoderPassthroughImpl::HandleGetRequestableExtensionsCHROMIUM( |
| 1467 uint32_t immediate_data_size, |
| 1468 const void* cmd_data) { |
| 1469 const gles2::cmds::GetRequestableExtensionsCHROMIUM& c = |
| 1470 *static_cast<const gles2::cmds::GetRequestableExtensionsCHROMIUM*>( |
| 1471 cmd_data); |
| 1472 const char* str = nullptr; |
| 1473 error::Error error = DoGetRequestableExtensionsCHROMIUM(&str); |
| 1474 if (error != error::kNoError) { |
| 1475 return error; |
| 1476 } |
| 1477 if (!str) { |
| 1478 return error::kOutOfBounds; |
| 1479 } |
| 1480 Bucket* bucket = CreateBucket(c.bucket_id); |
| 1481 bucket->SetFromString(str); |
| 1482 |
| 1483 return error::kNoError; |
| 1484 } |
| 1485 |
| 1486 error::Error GLES2DecoderPassthroughImpl::HandleRequestExtensionCHROMIUM( |
| 1487 uint32_t immediate_data_size, |
| 1488 const void* cmd_data) { |
| 1489 const gles2::cmds::RequestExtensionCHROMIUM& c = |
| 1490 *static_cast<const gles2::cmds::RequestExtensionCHROMIUM*>(cmd_data); |
| 1491 Bucket* bucket = GetBucket(c.bucket_id); |
| 1492 if (!bucket || bucket->size() == 0) { |
| 1493 return error::kInvalidArguments; |
| 1494 } |
| 1495 std::string feature_str; |
| 1496 if (!bucket->GetAsString(&feature_str)) { |
| 1497 return error::kInvalidArguments; |
| 1498 } |
| 1499 error::Error error = DoRequestExtensionCHROMIUM(feature_str.c_str()); |
| 1500 if (error != error::kNoError) { |
| 1501 return error; |
| 1502 } |
| 1503 return error::kNoError; |
| 1504 } |
| 1505 |
| 1506 error::Error GLES2DecoderPassthroughImpl::HandleGetProgramInfoCHROMIUM( |
| 1507 uint32_t immediate_data_size, |
| 1508 const void* cmd_data) { |
| 1509 const gles2::cmds::GetProgramInfoCHROMIUM& c = |
| 1510 *static_cast<const gles2::cmds::GetProgramInfoCHROMIUM*>(cmd_data); |
| 1511 GLuint program = static_cast<GLuint>(c.program); |
| 1512 |
| 1513 uint32_t bucket_id = c.bucket_id; |
| 1514 Bucket* bucket = CreateBucket(bucket_id); |
| 1515 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail. |
| 1516 |
| 1517 std::vector<uint8_t> data; |
| 1518 error::Error error = DoGetProgramInfoCHROMIUM(program, &data); |
| 1519 if (error != error::kNoError) { |
| 1520 return error; |
| 1521 } |
| 1522 |
| 1523 bucket->SetSize(data.size()); |
| 1524 bucket->SetData(data.data(), 0, data.size()); |
| 1525 |
| 1526 return error::kNoError; |
| 1527 } |
| 1528 |
| 1529 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformBlocksCHROMIUM( |
| 1530 uint32_t immediate_data_size, |
| 1531 const void* cmd_data) { |
| 1532 const gles2::cmds::GetUniformBlocksCHROMIUM& c = |
| 1533 *static_cast<const gles2::cmds::GetUniformBlocksCHROMIUM*>(cmd_data); |
| 1534 GLuint program = static_cast<GLuint>(c.program); |
| 1535 |
| 1536 uint32_t bucket_id = c.bucket_id; |
| 1537 Bucket* bucket = CreateBucket(bucket_id); |
| 1538 bucket->SetSize(sizeof(UniformBlocksHeader)); // in case we fail. |
| 1539 |
| 1540 std::vector<uint8_t> data; |
| 1541 error::Error error = DoGetUniformBlocksCHROMIUM(program, &data); |
| 1542 if (error != error::kNoError) { |
| 1543 return error; |
| 1544 } |
| 1545 |
| 1546 bucket->SetSize(data.size()); |
| 1547 bucket->SetData(data.data(), 0, data.size()); |
| 1548 |
| 1549 return error::kNoError; |
| 1550 } |
| 1551 |
| 1552 error::Error |
| 1553 GLES2DecoderPassthroughImpl::HandleGetTransformFeedbackVaryingsCHROMIUM( |
| 1554 uint32_t immediate_data_size, |
| 1555 const void* cmd_data) { |
| 1556 const gles2::cmds::GetTransformFeedbackVaryingsCHROMIUM& c = |
| 1557 *static_cast<const gles2::cmds::GetTransformFeedbackVaryingsCHROMIUM*>( |
| 1558 cmd_data); |
| 1559 GLuint program = static_cast<GLuint>(c.program); |
| 1560 |
| 1561 uint32_t bucket_id = c.bucket_id; |
| 1562 Bucket* bucket = CreateBucket(bucket_id); |
| 1563 bucket->SetSize(sizeof(TransformFeedbackVaryingsHeader)); // in case we fail. |
| 1564 |
| 1565 std::vector<uint8_t> data; |
| 1566 error::Error error = DoGetTransformFeedbackVaryingsCHROMIUM(program, &data); |
| 1567 if (error != error::kNoError) { |
| 1568 return error; |
| 1569 } |
| 1570 |
| 1571 bucket->SetSize(data.size()); |
| 1572 bucket->SetData(data.data(), 0, data.size()); |
| 1573 |
| 1574 return error::kNoError; |
| 1575 } |
| 1576 |
| 1577 error::Error GLES2DecoderPassthroughImpl::HandleGetUniformsES3CHROMIUM( |
| 1578 uint32_t immediate_data_size, |
| 1579 const void* cmd_data) { |
| 1580 const gles2::cmds::GetUniformsES3CHROMIUM& c = |
| 1581 *static_cast<const gles2::cmds::GetUniformsES3CHROMIUM*>(cmd_data); |
| 1582 GLuint program = static_cast<GLuint>(c.program); |
| 1583 |
| 1584 uint32_t bucket_id = c.bucket_id; |
| 1585 Bucket* bucket = CreateBucket(bucket_id); |
| 1586 bucket->SetSize(sizeof(UniformsES3Header)); // in case we fail. |
| 1587 |
| 1588 std::vector<uint8_t> data; |
| 1589 error::Error error = DoGetUniformsES3CHROMIUM(program, &data); |
| 1590 if (error != error::kNoError) { |
| 1591 return error; |
| 1592 } |
| 1593 |
| 1594 bucket->SetSize(data.size()); |
| 1595 bucket->SetData(data.data(), 0, data.size()); |
| 1596 |
| 1597 return error::kNoError; |
| 1598 } |
| 1599 |
| 1600 error::Error GLES2DecoderPassthroughImpl::HandleGetTranslatedShaderSourceANGLE( |
| 1601 uint32_t immediate_data_size, |
| 1602 const void* cmd_data) { |
| 1603 const gles2::cmds::GetTranslatedShaderSourceANGLE& c = |
| 1604 *static_cast<const gles2::cmds::GetTranslatedShaderSourceANGLE*>( |
| 1605 cmd_data); |
| 1606 GLuint shader = static_cast<GLuint>(c.shader); |
| 1607 |
| 1608 std::string source; |
| 1609 error::Error error = DoGetTranslatedShaderSourceANGLE(shader, &source); |
| 1610 if (error != error::kNoError) { |
| 1611 return error; |
| 1612 } |
| 1613 |
| 1614 Bucket* bucket = CreateBucket(c.bucket_id); |
| 1615 bucket->SetFromString(source.c_str()); |
| 1616 |
| 1617 return error::kNoError; |
| 1618 } |
| 1619 error::Error GLES2DecoderPassthroughImpl::HandlePostSubBufferCHROMIUM( |
| 1620 uint32_t immediate_data_size, |
| 1621 const void* cmd_data) { |
| 1622 const gles2::cmds::PostSubBufferCHROMIUM& c = |
| 1623 *static_cast<const gles2::cmds::PostSubBufferCHROMIUM*>(cmd_data); |
| 1624 GLint x = static_cast<GLint>(c.x); |
| 1625 GLint y = static_cast<GLint>(c.y); |
| 1626 GLint width = static_cast<GLint>(c.width); |
| 1627 GLint height = static_cast<GLint>(c.height); |
| 1628 error::Error error = DoPostSubBufferCHROMIUM(x, y, width, height); |
| 1629 if (error != error::kNoError) { |
| 1630 return error; |
| 1631 } |
| 1632 return error::kNoError; |
| 1633 } |
| 1634 error::Error GLES2DecoderPassthroughImpl::HandleDrawArraysInstancedANGLE( |
| 1635 uint32_t immediate_data_size, |
| 1636 const void* cmd_data) { |
| 1637 const gles2::cmds::DrawArraysInstancedANGLE& c = |
| 1638 *static_cast<const gles2::cmds::DrawArraysInstancedANGLE*>(cmd_data); |
| 1639 GLenum mode = static_cast<GLenum>(c.mode); |
| 1640 GLint first = static_cast<GLint>(c.first); |
| 1641 GLsizei count = static_cast<GLsizei>(c.count); |
| 1642 GLsizei primcount = static_cast<GLsizei>(c.primcount); |
| 1643 error::Error error = |
| 1644 DoDrawArraysInstancedANGLE(mode, first, count, primcount); |
| 1645 if (error != error::kNoError) { |
| 1646 return error; |
| 1647 } |
| 1648 return error::kNoError; |
| 1649 } |
| 1650 |
| 1651 error::Error GLES2DecoderPassthroughImpl::HandleDrawElementsInstancedANGLE( |
| 1652 uint32_t immediate_data_size, |
| 1653 const void* cmd_data) { |
| 1654 const gles2::cmds::DrawElementsInstancedANGLE& c = |
| 1655 *static_cast<const gles2::cmds::DrawElementsInstancedANGLE*>(cmd_data); |
| 1656 GLenum mode = static_cast<GLenum>(c.mode); |
| 1657 GLsizei count = static_cast<GLsizei>(c.count); |
| 1658 GLenum type = static_cast<GLenum>(c.type); |
| 1659 const GLvoid* indices = |
| 1660 reinterpret_cast<const GLvoid*>(static_cast<uintptr_t>(c.index_offset)); |
| 1661 GLsizei primcount = static_cast<GLsizei>(c.primcount); |
| 1662 error::Error error = |
| 1663 DoDrawElementsInstancedANGLE(mode, count, type, indices, primcount); |
| 1664 if (error != error::kNoError) { |
| 1665 return error; |
| 1666 } |
| 1667 return error::kNoError; |
| 1668 } |
| 1669 |
| 1670 error::Error GLES2DecoderPassthroughImpl::HandleVertexAttribDivisorANGLE( |
| 1671 uint32_t immediate_data_size, |
| 1672 const void* cmd_data) { |
| 1673 const gles2::cmds::VertexAttribDivisorANGLE& c = |
| 1674 *static_cast<const gles2::cmds::VertexAttribDivisorANGLE*>(cmd_data); |
| 1675 GLuint index = static_cast<GLuint>(c.index); |
| 1676 GLuint divisor = static_cast<GLuint>(c.divisor); |
| 1677 error::Error error = DoVertexAttribDivisorANGLE(index, divisor); |
| 1678 if (error != error::kNoError) { |
| 1679 return error; |
| 1680 } |
| 1681 return error::kNoError; |
| 1682 } |
| 1683 |
| 1684 error::Error GLES2DecoderPassthroughImpl::HandleGenMailboxCHROMIUM( |
| 1685 uint32_t immediate_data_size, |
| 1686 const void* cmd_data) { |
| 1687 const gles2::cmds::GenMailboxCHROMIUM& c = |
| 1688 *static_cast<const gles2::cmds::GenMailboxCHROMIUM*>(cmd_data); |
| 1689 (void)c; |
| 1690 return error::kUnknownCommand; |
| 1691 } |
| 1692 |
| 1693 error::Error |
| 1694 GLES2DecoderPassthroughImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( |
| 1695 uint32_t immediate_data_size, |
| 1696 const void* cmd_data) { |
| 1697 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c = *static_cast< |
| 1698 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate*>(cmd_data); |
| 1699 GLenum target = static_cast<GLenum>(c.target); |
| 1700 uint32_t data_size; |
| 1701 if (!GLES2Util::ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { |
| 1702 return error::kOutOfBounds; |
| 1703 } |
| 1704 if (data_size > immediate_data_size) { |
| 1705 return error::kOutOfBounds; |
| 1706 } |
| 1707 const GLbyte* mailbox = |
| 1708 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); |
| 1709 if (mailbox == NULL) { |
| 1710 return error::kOutOfBounds; |
| 1711 } |
| 1712 uint32_t client_id = c.client_id; |
| 1713 error::Error error = |
| 1714 DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); |
| 1715 if (error != error::kNoError) { |
| 1716 return error; |
| 1717 } |
| 1718 |
| 1719 return error::kNoError; |
| 1720 } |
| 1721 |
| 1722 error::Error |
| 1723 GLES2DecoderPassthroughImpl::HandleBindUniformLocationCHROMIUMBucket( |
| 1724 uint32_t immediate_data_size, |
| 1725 const void* cmd_data) { |
| 1726 const gles2::cmds::BindUniformLocationCHROMIUMBucket& c = |
| 1727 *static_cast<const gles2::cmds::BindUniformLocationCHROMIUMBucket*>( |
| 1728 cmd_data); |
| 1729 GLuint program = static_cast<GLuint>(c.program); |
| 1730 GLint location = static_cast<GLint>(c.location); |
| 1731 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 1732 if (!bucket || bucket->size() == 0) { |
| 1733 return error::kInvalidArguments; |
| 1734 } |
| 1735 std::string name_str; |
| 1736 if (!bucket->GetAsString(&name_str)) { |
| 1737 return error::kInvalidArguments; |
| 1738 } |
| 1739 error::Error error = |
| 1740 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); |
| 1741 if (error != error::kNoError) { |
| 1742 return error; |
| 1743 } |
| 1744 return error::kNoError; |
| 1745 } |
| 1746 |
| 1747 error::Error GLES2DecoderPassthroughImpl::HandleTraceBeginCHROMIUM( |
| 1748 uint32_t immediate_data_size, |
| 1749 const void* cmd_data) { |
| 1750 const gles2::cmds::TraceBeginCHROMIUM& c = |
| 1751 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); |
| 1752 Bucket* category_bucket = GetBucket(c.category_bucket_id); |
| 1753 Bucket* name_bucket = GetBucket(c.name_bucket_id); |
| 1754 if (!category_bucket || category_bucket->size() == 0 || !name_bucket || |
| 1755 name_bucket->size() == 0) { |
| 1756 return error::kInvalidArguments; |
| 1757 } |
| 1758 |
| 1759 std::string category_name; |
| 1760 std::string trace_name; |
| 1761 if (!category_bucket->GetAsString(&category_name) || |
| 1762 !name_bucket->GetAsString(&trace_name)) { |
| 1763 return error::kInvalidArguments; |
| 1764 } |
| 1765 |
| 1766 error::Error error = |
| 1767 DoTraceBeginCHROMIUM(category_name.c_str(), trace_name.c_str()); |
| 1768 if (error != error::kNoError) { |
| 1769 return error; |
| 1770 } |
| 1771 return error::kNoError; |
| 1772 } |
| 1773 |
| 1774 error::Error GLES2DecoderPassthroughImpl::HandleInsertFenceSyncCHROMIUM( |
| 1775 uint32_t immediate_data_size, |
| 1776 const void* cmd_data) { |
| 1777 const gles2::cmds::InsertFenceSyncCHROMIUM& c = |
| 1778 *static_cast<const gles2::cmds::InsertFenceSyncCHROMIUM*>(cmd_data); |
| 1779 GLuint64 release_count = c.release_count(); |
| 1780 error::Error error = DoInsertFenceSyncCHROMIUM(release_count); |
| 1781 if (error != error::kNoError) { |
| 1782 return error; |
| 1783 } |
| 1784 return error::kNoError; |
| 1785 } |
| 1786 error::Error GLES2DecoderPassthroughImpl::HandleGenSyncTokenCHROMIUMImmediate( |
| 1787 uint32_t immediate_data_size, |
| 1788 const void* cmd_data) { |
| 1789 const gles2::cmds::GenSyncTokenCHROMIUMImmediate& c = |
| 1790 *static_cast<const gles2::cmds::GenSyncTokenCHROMIUMImmediate*>(cmd_data); |
| 1791 (void)c; |
| 1792 return error::kUnknownCommand; |
| 1793 } |
| 1794 |
| 1795 error::Error |
| 1796 GLES2DecoderPassthroughImpl::HandleGenUnverifiedSyncTokenCHROMIUMImmediate( |
| 1797 uint32_t immediate_data_size, |
| 1798 const void* cmd_data) { |
| 1799 const gles2::cmds::GenUnverifiedSyncTokenCHROMIUMImmediate& c = |
| 1800 *static_cast<const gles2::cmds::GenUnverifiedSyncTokenCHROMIUMImmediate*>( |
| 1801 cmd_data); |
| 1802 (void)c; |
| 1803 return error::kUnknownCommand; |
| 1804 } |
| 1805 |
| 1806 error::Error |
| 1807 GLES2DecoderPassthroughImpl::HandleVerifySyncTokensCHROMIUMImmediate( |
| 1808 uint32_t immediate_data_size, |
| 1809 const void* cmd_data) { |
| 1810 const gles2::cmds::VerifySyncTokensCHROMIUMImmediate& c = |
| 1811 *static_cast<const gles2::cmds::VerifySyncTokensCHROMIUMImmediate*>( |
| 1812 cmd_data); |
| 1813 (void)c; |
| 1814 return error::kUnknownCommand; |
| 1815 } |
| 1816 |
| 1817 error::Error GLES2DecoderPassthroughImpl::HandleWaitSyncTokenCHROMIUM( |
| 1818 uint32_t immediate_data_size, |
| 1819 const void* cmd_data) { |
| 1820 const gles2::cmds::WaitSyncTokenCHROMIUM& c = |
| 1821 *static_cast<const gles2::cmds::WaitSyncTokenCHROMIUM*>(cmd_data); |
| 1822 CommandBufferNamespace namespace_id = |
| 1823 static_cast<gpu::CommandBufferNamespace>(c.namespace_id); |
| 1824 CommandBufferId command_buffer_id = |
| 1825 CommandBufferId::FromUnsafeValue(c.command_buffer_id()); |
| 1826 const uint64_t release_count = c.release_count(); |
| 1827 |
| 1828 const CommandBufferNamespace kMinNamespaceId = |
| 1829 CommandBufferNamespace::INVALID; |
| 1830 const CommandBufferNamespace kMaxNamespaceId = |
| 1831 CommandBufferNamespace::NUM_COMMAND_BUFFER_NAMESPACES; |
| 1832 if ((namespace_id < static_cast<int32_t>(kMinNamespaceId)) || |
| 1833 (namespace_id >= static_cast<int32_t>(kMaxNamespaceId))) { |
| 1834 namespace_id = gpu::CommandBufferNamespace::INVALID; |
| 1835 } |
| 1836 |
| 1837 error::Error error = |
| 1838 DoWaitSyncTokenCHROMIUM(namespace_id, command_buffer_id, release_count); |
| 1839 if (error != error::kNoError) { |
| 1840 return error; |
| 1841 } |
| 1842 return error::kNoError; |
| 1843 } |
| 1844 |
| 1845 error::Error GLES2DecoderPassthroughImpl::HandleDiscardBackbufferCHROMIUM( |
| 1846 uint32_t immediate_data_size, |
| 1847 const void* cmd_data) { |
| 1848 const gles2::cmds::DiscardBackbufferCHROMIUM& c = |
| 1849 *static_cast<const gles2::cmds::DiscardBackbufferCHROMIUM*>(cmd_data); |
| 1850 (void)c; |
| 1851 error::Error error = DoDiscardBackbufferCHROMIUM(); |
| 1852 if (error != error::kNoError) { |
| 1853 return error; |
| 1854 } |
| 1855 return error::kNoError; |
| 1856 } |
| 1857 |
| 1858 error::Error GLES2DecoderPassthroughImpl::HandleScheduleOverlayPlaneCHROMIUM( |
| 1859 uint32_t immediate_data_size, |
| 1860 const void* cmd_data) { |
| 1861 const gles2::cmds::ScheduleOverlayPlaneCHROMIUM& c = |
| 1862 *static_cast<const gles2::cmds::ScheduleOverlayPlaneCHROMIUM*>(cmd_data); |
| 1863 GLint plane_z_order = static_cast<GLint>(c.plane_z_order); |
| 1864 GLenum plane_transform = static_cast<GLenum>(c.plane_transform); |
| 1865 GLuint overlay_texture_id = static_cast<GLuint>(c.overlay_texture_id); |
| 1866 GLint bounds_x = static_cast<GLint>(c.bounds_x); |
| 1867 GLint bounds_y = static_cast<GLint>(c.bounds_y); |
| 1868 GLint bounds_width = static_cast<GLint>(c.bounds_width); |
| 1869 GLint bounds_height = static_cast<GLint>(c.bounds_height); |
| 1870 GLfloat uv_x = static_cast<GLfloat>(c.uv_x); |
| 1871 GLfloat uv_y = static_cast<GLfloat>(c.uv_x); |
| 1872 GLfloat uv_width = static_cast<GLfloat>(c.uv_x); |
| 1873 GLfloat uv_height = static_cast<GLfloat>(c.uv_x); |
| 1874 error::Error error = DoScheduleOverlayPlaneCHROMIUM( |
| 1875 plane_z_order, plane_transform, overlay_texture_id, bounds_x, bounds_y, |
| 1876 bounds_width, bounds_height, uv_x, uv_y, uv_width, uv_height); |
| 1877 if (error != error::kNoError) { |
| 1878 return error; |
| 1879 } |
| 1880 return error::kNoError; |
| 1881 } |
| 1882 |
| 1883 error::Error GLES2DecoderPassthroughImpl::HandleScheduleCALayerCHROMIUM( |
| 1884 uint32_t immediate_data_size, |
| 1885 const void* cmd_data) { |
| 1886 const gles2::cmds::ScheduleCALayerCHROMIUM& c = |
| 1887 *static_cast<const gles2::cmds::ScheduleCALayerCHROMIUM*>(cmd_data); |
| 1888 const GLfloat* mem = GetSharedMemoryAs<const GLfloat*>(c.shm_id, c.shm_offset, |
| 1889 28 * sizeof(GLfloat)); |
| 1890 if (!mem) { |
| 1891 return error::kOutOfBounds; |
| 1892 } |
| 1893 GLuint contents_texture_id = static_cast<GLint>(c.contents_texture_id); |
| 1894 const GLfloat* contents_rect = mem; |
| 1895 GLfloat opacity = static_cast<GLfloat>(c.opacity); |
| 1896 GLuint background_color = static_cast<GLuint>(c.background_color); |
| 1897 GLuint edge_aa_mask = static_cast<GLuint>(c.edge_aa_mask); |
| 1898 const GLfloat* bounds_rect = mem + 4; |
| 1899 GLboolean is_clipped = static_cast<GLboolean>(c.is_clipped); |
| 1900 const GLfloat* clip_rect = mem + 8; |
| 1901 GLint sorting_context_id = static_cast<GLint>(c.sorting_context_id); |
| 1902 const GLfloat* transform = mem + 12; |
| 1903 error::Error error = DoScheduleCALayerCHROMIUM( |
| 1904 contents_texture_id, contents_rect, opacity, background_color, |
| 1905 edge_aa_mask, bounds_rect, is_clipped, clip_rect, sorting_context_id, |
| 1906 transform); |
| 1907 if (error != error::kNoError) { |
| 1908 return error; |
| 1909 } |
| 1910 return error::kNoError; |
| 1911 } |
| 1912 |
| 1913 error::Error GLES2DecoderPassthroughImpl::HandleGenPathsCHROMIUM( |
| 1914 uint32_t immediate_data_size, |
| 1915 const void* cmd_data) { |
| 1916 const gles2::cmds::GenPathsCHROMIUM& c = |
| 1917 *static_cast<const gles2::cmds::GenPathsCHROMIUM*>(cmd_data); |
| 1918 GLuint path = static_cast<GLuint>(c.first_client_id); |
| 1919 GLsizei range = static_cast<GLsizei>(c.range); |
| 1920 error::Error error = DoGenPathsCHROMIUM(path, range); |
| 1921 if (error != error::kNoError) { |
| 1922 return error; |
| 1923 } |
| 1924 return error::kNoError; |
| 1925 } |
| 1926 |
| 1927 error::Error GLES2DecoderPassthroughImpl::HandleDeletePathsCHROMIUM( |
| 1928 uint32_t immediate_data_size, |
| 1929 const void* cmd_data) { |
| 1930 const gles2::cmds::DeletePathsCHROMIUM& c = |
| 1931 *static_cast<const gles2::cmds::DeletePathsCHROMIUM*>(cmd_data); |
| 1932 GLuint path = static_cast<GLuint>(c.first_client_id); |
| 1933 GLsizei range = static_cast<GLsizei>(c.range); |
| 1934 error::Error error = DoDeletePathsCHROMIUM(path, range); |
| 1935 if (error != error::kNoError) { |
| 1936 return error; |
| 1937 } |
| 1938 return error::kNoError; |
| 1939 } |
| 1940 |
| 1941 error::Error GLES2DecoderPassthroughImpl::HandlePathCommandsCHROMIUM( |
| 1942 uint32_t immediate_data_size, |
| 1943 const void* cmd_data) { |
| 1944 const gles2::cmds::PathCommandsCHROMIUM& c = |
| 1945 *static_cast<const gles2::cmds::PathCommandsCHROMIUM*>(cmd_data); |
| 1946 GLuint path = static_cast<GLuint>(c.path); |
| 1947 GLsizei num_commands = static_cast<GLsizei>(c.numCommands); |
| 1948 const GLubyte* commands = nullptr; |
| 1949 if (num_commands > 0) { |
| 1950 uint32_t commands_shm_id = static_cast<uint32_t>(c.commands_shm_id); |
| 1951 uint32_t commands_shm_offset = static_cast<uint32_t>(c.commands_shm_offset); |
| 1952 if (commands_shm_id != 0 || commands_shm_offset != 0) { |
| 1953 commands = GetSharedMemoryAs<const GLubyte*>( |
| 1954 commands_shm_id, commands_shm_offset, num_commands); |
| 1955 } |
| 1956 if (!commands) { |
| 1957 return error::kOutOfBounds; |
| 1958 } |
| 1959 } |
| 1960 GLsizei num_coords = static_cast<GLsizei>(c.numCoords); |
| 1961 GLenum coord_type = static_cast<GLenum>(c.coordType); |
| 1962 const GLvoid* coords = nullptr; |
| 1963 GLsizei coords_bufsize = 0; |
| 1964 if (num_coords > 0) { |
| 1965 uint32_t coords_shm_id = static_cast<uint32_t>(c.coords_shm_id); |
| 1966 uint32_t coords_shm_offset = static_cast<uint32_t>(c.coords_shm_offset); |
| 1967 if (coords_shm_id != 0 || coords_shm_offset != 0) { |
| 1968 unsigned int memory_size = 0; |
| 1969 coords = GetSharedMemoryAndSizeAs<const GLvoid*>( |
| 1970 coords_shm_id, coords_shm_offset, &memory_size); |
| 1971 coords_bufsize = static_cast<GLsizei>(memory_size); |
| 1972 } |
| 1973 |
| 1974 if (!coords) { |
| 1975 return error::kOutOfBounds; |
| 1976 } |
| 1977 } |
| 1978 |
| 1979 error::Error error = |
| 1980 DoPathCommandsCHROMIUM(path, num_commands, commands, num_coords, |
| 1981 coord_type, coords, coords_bufsize); |
| 1982 if (error != error::kNoError) { |
| 1983 return error; |
| 1984 } |
| 1985 |
| 1986 return error::kNoError; |
| 1987 } |
| 1988 |
| 1989 error::Error GLES2DecoderPassthroughImpl::HandlePathParameterfCHROMIUM( |
| 1990 uint32_t immediate_data_size, |
| 1991 const void* cmd_data) { |
| 1992 const gles2::cmds::PathParameterfCHROMIUM& c = |
| 1993 *static_cast<const gles2::cmds::PathParameterfCHROMIUM*>(cmd_data); |
| 1994 GLuint path = static_cast<GLuint>(c.path); |
| 1995 GLenum pname = static_cast<GLenum>(c.pname); |
| 1996 GLfloat value = static_cast<GLfloat>(c.value); |
| 1997 error::Error error = DoPathParameterfCHROMIUM(path, pname, value); |
| 1998 if (error != error::kNoError) { |
| 1999 return error; |
| 2000 } |
| 2001 return error::kNoError; |
| 2002 } |
| 2003 |
| 2004 error::Error GLES2DecoderPassthroughImpl::HandlePathParameteriCHROMIUM( |
| 2005 uint32_t immediate_data_size, |
| 2006 const void* cmd_data) { |
| 2007 const gles2::cmds::PathParameteriCHROMIUM& c = |
| 2008 *static_cast<const gles2::cmds::PathParameteriCHROMIUM*>(cmd_data); |
| 2009 GLuint path = static_cast<GLuint>(c.path); |
| 2010 GLenum pname = static_cast<GLenum>(c.pname); |
| 2011 GLint value = static_cast<GLint>(c.value); |
| 2012 error::Error error = DoPathParameteriCHROMIUM(path, pname, value); |
| 2013 if (error != error::kNoError) { |
| 2014 return error; |
| 2015 } |
| 2016 return error::kNoError; |
| 2017 } |
| 2018 |
| 2019 error::Error GLES2DecoderPassthroughImpl::HandleStencilFillPathCHROMIUM( |
| 2020 uint32_t immediate_data_size, |
| 2021 const void* cmd_data) { |
| 2022 const gles2::cmds::StencilFillPathCHROMIUM& c = |
| 2023 *static_cast<const gles2::cmds::StencilFillPathCHROMIUM*>(cmd_data); |
| 2024 GLuint path = static_cast<GLuint>(c.path); |
| 2025 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 2026 GLuint mask = static_cast<GLuint>(c.mask); |
| 2027 error::Error error = DoStencilFillPathCHROMIUM(path, fill_mode, mask); |
| 2028 if (error != error::kNoError) { |
| 2029 return error; |
| 2030 } |
| 2031 return error::kNoError; |
| 2032 } |
| 2033 |
| 2034 error::Error GLES2DecoderPassthroughImpl::HandleStencilStrokePathCHROMIUM( |
| 2035 uint32_t immediate_data_size, |
| 2036 const void* cmd_data) { |
| 2037 const gles2::cmds::StencilStrokePathCHROMIUM& c = |
| 2038 *static_cast<const gles2::cmds::StencilStrokePathCHROMIUM*>(cmd_data); |
| 2039 GLuint path = static_cast<GLuint>(c.path); |
| 2040 GLint reference = static_cast<GLint>(c.reference); |
| 2041 GLuint mask = static_cast<GLuint>(c.mask); |
| 2042 error::Error error = DoStencilStrokePathCHROMIUM(path, reference, mask); |
| 2043 if (error != error::kNoError) { |
| 2044 return error; |
| 2045 } |
| 2046 return error::kNoError; |
| 2047 } |
| 2048 |
| 2049 error::Error GLES2DecoderPassthroughImpl::HandleCoverFillPathCHROMIUM( |
| 2050 uint32_t immediate_data_size, |
| 2051 const void* cmd_data) { |
| 2052 const gles2::cmds::CoverFillPathCHROMIUM& c = |
| 2053 *static_cast<const gles2::cmds::CoverFillPathCHROMIUM*>(cmd_data); |
| 2054 GLuint path = static_cast<GLuint>(c.path); |
| 2055 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2056 error::Error error = DoCoverFillPathCHROMIUM(path, cover_mode); |
| 2057 if (error != error::kNoError) { |
| 2058 return error; |
| 2059 } |
| 2060 return error::kNoError; |
| 2061 } |
| 2062 |
| 2063 error::Error GLES2DecoderPassthroughImpl::HandleCoverStrokePathCHROMIUM( |
| 2064 uint32_t immediate_data_size, |
| 2065 const void* cmd_data) { |
| 2066 const gles2::cmds::CoverStrokePathCHROMIUM& c = |
| 2067 *static_cast<const gles2::cmds::CoverStrokePathCHROMIUM*>(cmd_data); |
| 2068 GLuint path = static_cast<GLuint>(c.path); |
| 2069 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2070 error::Error error = DoCoverStrokePathCHROMIUM(path, cover_mode); |
| 2071 if (error != error::kNoError) { |
| 2072 return error; |
| 2073 } |
| 2074 return error::kNoError; |
| 2075 } |
| 2076 |
| 2077 error::Error |
| 2078 GLES2DecoderPassthroughImpl::HandleStencilThenCoverFillPathCHROMIUM( |
| 2079 uint32_t immediate_data_size, |
| 2080 const void* cmd_data) { |
| 2081 const gles2::cmds::StencilThenCoverFillPathCHROMIUM& c = |
| 2082 *static_cast<const gles2::cmds::StencilThenCoverFillPathCHROMIUM*>( |
| 2083 cmd_data); |
| 2084 GLuint path = static_cast<GLuint>(c.path); |
| 2085 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 2086 GLuint mask = static_cast<GLuint>(c.mask); |
| 2087 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2088 error::Error error = |
| 2089 DoStencilThenCoverFillPathCHROMIUM(path, fill_mode, mask, cover_mode); |
| 2090 if (error != error::kNoError) { |
| 2091 return error; |
| 2092 } |
| 2093 return error::kNoError; |
| 2094 } |
| 2095 |
| 2096 error::Error |
| 2097 GLES2DecoderPassthroughImpl::HandleStencilThenCoverStrokePathCHROMIUM( |
| 2098 uint32_t immediate_data_size, |
| 2099 const void* cmd_data) { |
| 2100 const gles2::cmds::StencilThenCoverStrokePathCHROMIUM& c = |
| 2101 *static_cast<const gles2::cmds::StencilThenCoverStrokePathCHROMIUM*>( |
| 2102 cmd_data); |
| 2103 GLuint path = static_cast<GLuint>(c.path); |
| 2104 GLint reference = static_cast<GLint>(c.reference); |
| 2105 GLuint mask = static_cast<GLuint>(c.mask); |
| 2106 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2107 error::Error error = |
| 2108 DoStencilThenCoverStrokePathCHROMIUM(path, reference, mask, cover_mode); |
| 2109 if (error != error::kNoError) { |
| 2110 return error; |
| 2111 } |
| 2112 return error::kNoError; |
| 2113 } |
| 2114 |
| 2115 error::Error |
| 2116 GLES2DecoderPassthroughImpl::HandleStencilFillPathInstancedCHROMIUM( |
| 2117 uint32_t immediate_data_size, |
| 2118 const void* cmd_data) { |
| 2119 const gles2::cmds::StencilFillPathInstancedCHROMIUM& c = |
| 2120 *static_cast<const gles2::cmds::StencilFillPathInstancedCHROMIUM*>( |
| 2121 cmd_data); |
| 2122 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 2123 GLenum path_name_type = static_cast<GLuint>(c.pathNameType); |
| 2124 const GLvoid* paths = nullptr; |
| 2125 GLsizei paths_bufsize = 0; |
| 2126 if (num_paths > 0) { |
| 2127 uint32_t paths_shm_id = static_cast<uint32_t>(c.paths_shm_id); |
| 2128 uint32_t paths_shm_offset = static_cast<uint32_t>(c.paths_shm_offset); |
| 2129 if (paths_shm_id != 0 || paths_shm_offset != 0) { |
| 2130 unsigned int memory_size = 0; |
| 2131 paths = GetSharedMemoryAndSizeAs<const GLvoid*>( |
| 2132 paths_shm_id, paths_shm_offset, &memory_size); |
| 2133 paths_bufsize = static_cast<GLsizei>(memory_size); |
| 2134 } |
| 2135 |
| 2136 if (!paths) { |
| 2137 return error::kOutOfBounds; |
| 2138 } |
| 2139 } |
| 2140 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 2141 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 2142 GLuint mask = static_cast<GLuint>(c.mask); |
| 2143 GLenum transform_type = static_cast<GLuint>(c.transformType); |
| 2144 const GLfloat* transform_values = nullptr; |
| 2145 GLsizei transform_values_bufsize = 0; |
| 2146 if (c.transformValues_shm_id != 0 || c.transformValues_shm_offset != 0) { |
| 2147 unsigned int memory_size = 0; |
| 2148 transform_values = GetSharedMemoryAndSizeAs<const GLfloat*>( |
| 2149 c.transformValues_shm_id, c.transformValues_shm_offset, &memory_size); |
| 2150 transform_values_bufsize = static_cast<GLsizei>(memory_size); |
| 2151 } |
| 2152 if (!transform_values) { |
| 2153 return error::kOutOfBounds; |
| 2154 } |
| 2155 |
| 2156 error::Error error = DoStencilFillPathInstancedCHROMIUM( |
| 2157 num_paths, path_name_type, paths, paths_bufsize, path_base, fill_mode, |
| 2158 mask, transform_type, transform_values, transform_values_bufsize); |
| 2159 if (error != error::kNoError) { |
| 2160 return error; |
| 2161 } |
| 2162 |
| 2163 return error::kNoError; |
| 2164 } |
| 2165 |
| 2166 error::Error |
| 2167 GLES2DecoderPassthroughImpl::HandleStencilStrokePathInstancedCHROMIUM( |
| 2168 uint32_t immediate_data_size, |
| 2169 const void* cmd_data) { |
| 2170 const gles2::cmds::StencilStrokePathInstancedCHROMIUM& c = |
| 2171 *static_cast<const gles2::cmds::StencilStrokePathInstancedCHROMIUM*>( |
| 2172 cmd_data); |
| 2173 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 2174 GLenum path_name_type = static_cast<GLuint>(c.pathNameType); |
| 2175 const GLvoid* paths = nullptr; |
| 2176 GLsizei paths_bufsize = 0; |
| 2177 if (num_paths > 0) { |
| 2178 uint32_t paths_shm_id = static_cast<uint32_t>(c.paths_shm_id); |
| 2179 uint32_t paths_shm_offset = static_cast<uint32_t>(c.paths_shm_offset); |
| 2180 if (paths_shm_id != 0 || paths_shm_offset != 0) { |
| 2181 unsigned int memory_size = 0; |
| 2182 paths = GetSharedMemoryAndSizeAs<const GLvoid*>( |
| 2183 paths_shm_id, paths_shm_offset, &memory_size); |
| 2184 paths_bufsize = static_cast<GLsizei>(memory_size); |
| 2185 } |
| 2186 |
| 2187 if (!paths) { |
| 2188 return error::kOutOfBounds; |
| 2189 } |
| 2190 } |
| 2191 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 2192 GLint reference = static_cast<GLint>(c.reference); |
| 2193 GLuint mask = static_cast<GLuint>(c.mask); |
| 2194 GLenum transform_type = static_cast<GLuint>(c.transformType); |
| 2195 const GLfloat* transform_values = nullptr; |
| 2196 GLsizei transform_values_bufsize = 0; |
| 2197 if (c.transformValues_shm_id != 0 || c.transformValues_shm_offset != 0) { |
| 2198 unsigned int memory_size = 0; |
| 2199 transform_values = GetSharedMemoryAndSizeAs<const GLfloat*>( |
| 2200 c.transformValues_shm_id, c.transformValues_shm_offset, &memory_size); |
| 2201 transform_values_bufsize = static_cast<GLsizei>(memory_size); |
| 2202 } |
| 2203 if (!transform_values) { |
| 2204 return error::kOutOfBounds; |
| 2205 } |
| 2206 |
| 2207 error::Error error = DoStencilStrokePathInstancedCHROMIUM( |
| 2208 num_paths, path_name_type, paths, paths_bufsize, path_base, reference, |
| 2209 mask, transform_type, transform_values, transform_values_bufsize); |
| 2210 if (error != error::kNoError) { |
| 2211 return error; |
| 2212 } |
| 2213 |
| 2214 return error::kNoError; |
| 2215 } |
| 2216 |
| 2217 error::Error GLES2DecoderPassthroughImpl::HandleCoverFillPathInstancedCHROMIUM( |
| 2218 uint32_t immediate_data_size, |
| 2219 const void* cmd_data) { |
| 2220 const gles2::cmds::CoverFillPathInstancedCHROMIUM& c = |
| 2221 *static_cast<const gles2::cmds::CoverFillPathInstancedCHROMIUM*>( |
| 2222 cmd_data); |
| 2223 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 2224 GLenum path_name_type = static_cast<GLuint>(c.pathNameType); |
| 2225 const GLvoid* paths = nullptr; |
| 2226 GLsizei paths_bufsize = 0; |
| 2227 if (num_paths > 0) { |
| 2228 uint32_t paths_shm_id = static_cast<uint32_t>(c.paths_shm_id); |
| 2229 uint32_t paths_shm_offset = static_cast<uint32_t>(c.paths_shm_offset); |
| 2230 if (paths_shm_id != 0 || paths_shm_offset != 0) { |
| 2231 unsigned int memory_size = 0; |
| 2232 paths = GetSharedMemoryAndSizeAs<const GLvoid*>( |
| 2233 paths_shm_id, paths_shm_offset, &memory_size); |
| 2234 paths_bufsize = static_cast<GLsizei>(memory_size); |
| 2235 } |
| 2236 |
| 2237 if (!paths) { |
| 2238 return error::kOutOfBounds; |
| 2239 } |
| 2240 } |
| 2241 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 2242 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2243 GLenum transform_type = static_cast<GLuint>(c.transformType); |
| 2244 const GLfloat* transform_values = nullptr; |
| 2245 GLsizei transform_values_bufsize = 0; |
| 2246 if (c.transformValues_shm_id != 0 || c.transformValues_shm_offset != 0) { |
| 2247 unsigned int memory_size = 0; |
| 2248 transform_values = GetSharedMemoryAndSizeAs<const GLfloat*>( |
| 2249 c.transformValues_shm_id, c.transformValues_shm_offset, &memory_size); |
| 2250 transform_values_bufsize = static_cast<GLsizei>(memory_size); |
| 2251 } |
| 2252 if (!transform_values) { |
| 2253 return error::kOutOfBounds; |
| 2254 } |
| 2255 |
| 2256 error::Error error = DoCoverFillPathInstancedCHROMIUM( |
| 2257 num_paths, path_name_type, paths, paths_bufsize, path_base, cover_mode, |
| 2258 transform_type, transform_values, transform_values_bufsize); |
| 2259 if (error != error::kNoError) { |
| 2260 return error; |
| 2261 } |
| 2262 |
| 2263 return error::kNoError; |
| 2264 } |
| 2265 |
| 2266 error::Error |
| 2267 GLES2DecoderPassthroughImpl::HandleCoverStrokePathInstancedCHROMIUM( |
| 2268 uint32_t immediate_data_size, |
| 2269 const void* cmd_data) { |
| 2270 const gles2::cmds::CoverStrokePathInstancedCHROMIUM& c = |
| 2271 *static_cast<const gles2::cmds::CoverStrokePathInstancedCHROMIUM*>( |
| 2272 cmd_data); |
| 2273 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 2274 GLenum path_name_type = static_cast<GLuint>(c.pathNameType); |
| 2275 const GLvoid* paths = nullptr; |
| 2276 GLsizei paths_bufsize = 0; |
| 2277 if (num_paths > 0) { |
| 2278 uint32_t paths_shm_id = static_cast<uint32_t>(c.paths_shm_id); |
| 2279 uint32_t paths_shm_offset = static_cast<uint32_t>(c.paths_shm_offset); |
| 2280 if (paths_shm_id != 0 || paths_shm_offset != 0) { |
| 2281 unsigned int memory_size = 0; |
| 2282 paths = GetSharedMemoryAndSizeAs<const GLvoid*>( |
| 2283 paths_shm_id, paths_shm_offset, &memory_size); |
| 2284 paths_bufsize = static_cast<GLsizei>(memory_size); |
| 2285 } |
| 2286 |
| 2287 if (!paths) { |
| 2288 return error::kOutOfBounds; |
| 2289 } |
| 2290 } |
| 2291 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 2292 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2293 GLenum transform_type = static_cast<GLuint>(c.transformType); |
| 2294 const GLfloat* transform_values = nullptr; |
| 2295 GLsizei transform_values_bufsize = 0; |
| 2296 if (c.transformValues_shm_id != 0 || c.transformValues_shm_offset != 0) { |
| 2297 unsigned int memory_size = 0; |
| 2298 transform_values = GetSharedMemoryAndSizeAs<const GLfloat*>( |
| 2299 c.transformValues_shm_id, c.transformValues_shm_offset, &memory_size); |
| 2300 transform_values_bufsize = static_cast<GLsizei>(memory_size); |
| 2301 } |
| 2302 if (!transform_values) { |
| 2303 return error::kOutOfBounds; |
| 2304 } |
| 2305 |
| 2306 error::Error error = DoCoverStrokePathInstancedCHROMIUM( |
| 2307 num_paths, path_name_type, paths, paths_bufsize, path_base, cover_mode, |
| 2308 transform_type, transform_values, transform_values_bufsize); |
| 2309 if (error != error::kNoError) { |
| 2310 return error; |
| 2311 } |
| 2312 |
| 2313 return error::kNoError; |
| 2314 } |
| 2315 |
| 2316 error::Error |
| 2317 GLES2DecoderPassthroughImpl::HandleStencilThenCoverFillPathInstancedCHROMIUM( |
| 2318 uint32_t immediate_data_size, |
| 2319 const void* cmd_data) { |
| 2320 const gles2::cmds::StencilThenCoverFillPathInstancedCHROMIUM& c = |
| 2321 *static_cast< |
| 2322 const gles2::cmds::StencilThenCoverFillPathInstancedCHROMIUM*>( |
| 2323 cmd_data); |
| 2324 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 2325 GLenum path_name_type = static_cast<GLuint>(c.pathNameType); |
| 2326 const GLvoid* paths = nullptr; |
| 2327 GLsizei paths_bufsize = 0; |
| 2328 if (num_paths > 0) { |
| 2329 uint32_t paths_shm_id = static_cast<uint32_t>(c.paths_shm_id); |
| 2330 uint32_t paths_shm_offset = static_cast<uint32_t>(c.paths_shm_offset); |
| 2331 if (paths_shm_id != 0 || paths_shm_offset != 0) { |
| 2332 unsigned int memory_size = 0; |
| 2333 paths = GetSharedMemoryAndSizeAs<const GLvoid*>( |
| 2334 paths_shm_id, paths_shm_offset, &memory_size); |
| 2335 paths_bufsize = static_cast<GLsizei>(memory_size); |
| 2336 } |
| 2337 |
| 2338 if (!paths) { |
| 2339 return error::kOutOfBounds; |
| 2340 } |
| 2341 } |
| 2342 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 2343 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2344 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 2345 GLuint mask = static_cast<GLuint>(c.mask); |
| 2346 GLenum transform_type = static_cast<GLuint>(c.transformType); |
| 2347 const GLfloat* transform_values = nullptr; |
| 2348 GLsizei transform_values_bufsize = 0; |
| 2349 if (c.transformValues_shm_id != 0 || c.transformValues_shm_offset != 0) { |
| 2350 unsigned int memory_size = 0; |
| 2351 transform_values = GetSharedMemoryAndSizeAs<const GLfloat*>( |
| 2352 c.transformValues_shm_id, c.transformValues_shm_offset, &memory_size); |
| 2353 transform_values_bufsize = static_cast<GLsizei>(memory_size); |
| 2354 } |
| 2355 if (!transform_values) { |
| 2356 return error::kOutOfBounds; |
| 2357 } |
| 2358 |
| 2359 error::Error error = DoStencilThenCoverFillPathInstancedCHROMIUM( |
| 2360 num_paths, path_name_type, paths, paths_bufsize, path_base, cover_mode, |
| 2361 fill_mode, mask, transform_type, transform_values, |
| 2362 transform_values_bufsize); |
| 2363 if (error != error::kNoError) { |
| 2364 return error; |
| 2365 } |
| 2366 |
| 2367 return error::kNoError; |
| 2368 } |
| 2369 |
| 2370 error::Error |
| 2371 GLES2DecoderPassthroughImpl::HandleStencilThenCoverStrokePathInstancedCHROMIUM( |
| 2372 uint32_t immediate_data_size, |
| 2373 const void* cmd_data) { |
| 2374 const gles2::cmds::StencilThenCoverStrokePathInstancedCHROMIUM& c = |
| 2375 *static_cast< |
| 2376 const gles2::cmds::StencilThenCoverStrokePathInstancedCHROMIUM*>( |
| 2377 cmd_data); |
| 2378 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 2379 GLenum path_name_type = static_cast<GLuint>(c.pathNameType); |
| 2380 const GLvoid* paths = nullptr; |
| 2381 GLsizei paths_bufsize = 0; |
| 2382 if (num_paths > 0) { |
| 2383 uint32_t paths_shm_id = static_cast<uint32_t>(c.paths_shm_id); |
| 2384 uint32_t paths_shm_offset = static_cast<uint32_t>(c.paths_shm_offset); |
| 2385 if (paths_shm_id != 0 || paths_shm_offset != 0) { |
| 2386 unsigned int memory_size = 0; |
| 2387 paths = GetSharedMemoryAndSizeAs<const GLvoid*>( |
| 2388 paths_shm_id, paths_shm_offset, &memory_size); |
| 2389 paths_bufsize = static_cast<GLsizei>(memory_size); |
| 2390 } |
| 2391 |
| 2392 if (!paths) { |
| 2393 return error::kOutOfBounds; |
| 2394 } |
| 2395 } |
| 2396 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 2397 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 2398 GLint reference = static_cast<GLint>(c.reference); |
| 2399 GLuint mask = static_cast<GLuint>(c.mask); |
| 2400 GLenum transform_type = static_cast<GLuint>(c.transformType); |
| 2401 const GLfloat* transform_values = nullptr; |
| 2402 GLsizei transform_values_bufsize = 0; |
| 2403 if (c.transformValues_shm_id != 0 || c.transformValues_shm_offset != 0) { |
| 2404 unsigned int memory_size = 0; |
| 2405 transform_values = GetSharedMemoryAndSizeAs<const GLfloat*>( |
| 2406 c.transformValues_shm_id, c.transformValues_shm_offset, &memory_size); |
| 2407 transform_values_bufsize = static_cast<GLsizei>(memory_size); |
| 2408 } |
| 2409 if (!transform_values) { |
| 2410 return error::kOutOfBounds; |
| 2411 } |
| 2412 |
| 2413 error::Error error = DoStencilThenCoverStrokePathInstancedCHROMIUM( |
| 2414 num_paths, path_name_type, paths, paths_bufsize, path_base, cover_mode, |
| 2415 reference, mask, transform_type, transform_values, |
| 2416 transform_values_bufsize); |
| 2417 if (error != error::kNoError) { |
| 2418 return error; |
| 2419 } |
| 2420 |
| 2421 return error::kNoError; |
| 2422 } |
| 2423 |
| 2424 error::Error |
| 2425 GLES2DecoderPassthroughImpl::HandleBindFragmentInputLocationCHROMIUMBucket( |
| 2426 uint32_t immediate_data_size, |
| 2427 const void* cmd_data) { |
| 2428 const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket& c = |
| 2429 *static_cast<const gles2::cmds::BindFragmentInputLocationCHROMIUMBucket*>( |
| 2430 cmd_data); |
| 2431 GLuint program = static_cast<GLuint>(c.program); |
| 2432 GLint location = static_cast<GLint>(c.location); |
| 2433 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 2434 if (!bucket || bucket->size() == 0) { |
| 2435 return error::kInvalidArguments; |
| 2436 } |
| 2437 std::string name_str; |
| 2438 if (!bucket->GetAsString(&name_str)) { |
| 2439 return error::kInvalidArguments; |
| 2440 } |
| 2441 error::Error error = |
| 2442 DoBindFragmentInputLocationCHROMIUM(program, location, name_str.c_str()); |
| 2443 if (error != error::kNoError) { |
| 2444 return error; |
| 2445 } |
| 2446 return error::kNoError; |
| 2447 } |
| 2448 |
| 2449 error::Error |
| 2450 GLES2DecoderPassthroughImpl::HandleProgramPathFragmentInputGenCHROMIUM( |
| 2451 uint32_t immediate_data_size, |
| 2452 const void* cmd_data) { |
| 2453 const gles2::cmds::ProgramPathFragmentInputGenCHROMIUM& c = |
| 2454 *static_cast<const gles2::cmds::ProgramPathFragmentInputGenCHROMIUM*>( |
| 2455 cmd_data); |
| 2456 GLint program = static_cast<GLint>(c.program); |
| 2457 GLint location = static_cast<GLint>(c.location); |
| 2458 GLenum gen_mode = static_cast<GLint>(c.genMode); |
| 2459 GLint components = static_cast<GLint>(c.components); |
| 2460 const GLfloat* coeffs = nullptr; |
| 2461 GLsizei coeffs_bufsize = 0; |
| 2462 if (c.coeffs_shm_id != 0 || c.coeffs_shm_offset != 0) { |
| 2463 unsigned int memory_size = 0; |
| 2464 coeffs = GetSharedMemoryAndSizeAs<const GLfloat*>( |
| 2465 c.coeffs_shm_id, c.coeffs_shm_offset, &memory_size); |
| 2466 coeffs_bufsize = static_cast<GLsizei>(memory_size); |
| 2467 } |
| 2468 if (!coeffs) { |
| 2469 return error::kOutOfBounds; |
| 2470 } |
| 2471 error::Error error = DoProgramPathFragmentInputGenCHROMIUM( |
| 2472 program, location, gen_mode, components, coeffs, coeffs_bufsize); |
| 2473 if (error != error::kNoError) { |
| 2474 return error; |
| 2475 } |
| 2476 return error::kNoError; |
| 2477 } |
| 2478 error::Error |
| 2479 GLES2DecoderPassthroughImpl::HandleBindFragDataLocationIndexedEXTBucket( |
| 2480 uint32_t immediate_data_size, |
| 2481 const void* cmd_data) { |
| 2482 const gles2::cmds::BindFragDataLocationIndexedEXTBucket& c = |
| 2483 *static_cast<const gles2::cmds::BindFragDataLocationIndexedEXTBucket*>( |
| 2484 cmd_data); |
| 2485 GLuint program = static_cast<GLuint>(c.program); |
| 2486 GLuint colorNumber = static_cast<GLuint>(c.colorNumber); |
| 2487 GLuint index = static_cast<GLuint>(c.index); |
| 2488 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 2489 if (!bucket || bucket->size() == 0) { |
| 2490 return error::kInvalidArguments; |
| 2491 } |
| 2492 std::string name_str; |
| 2493 if (!bucket->GetAsString(&name_str)) { |
| 2494 return error::kInvalidArguments; |
| 2495 } |
| 2496 error::Error error = DoBindFragDataLocationIndexedEXT( |
| 2497 program, colorNumber, index, name_str.c_str()); |
| 2498 if (error != error::kNoError) { |
| 2499 return error; |
| 2500 } |
| 2501 return error::kNoError; |
| 2502 } |
| 2503 error::Error GLES2DecoderPassthroughImpl::HandleBindFragDataLocationEXTBucket( |
| 2504 uint32_t immediate_data_size, |
| 2505 const void* cmd_data) { |
| 2506 const gles2::cmds::BindFragDataLocationEXTBucket& c = |
| 2507 *static_cast<const gles2::cmds::BindFragDataLocationEXTBucket*>(cmd_data); |
| 2508 GLuint program = static_cast<GLuint>(c.program); |
| 2509 GLuint colorNumber = static_cast<GLuint>(c.colorNumber); |
| 2510 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 2511 if (!bucket || bucket->size() == 0) { |
| 2512 return error::kInvalidArguments; |
| 2513 } |
| 2514 std::string name_str; |
| 2515 if (!bucket->GetAsString(&name_str)) { |
| 2516 return error::kInvalidArguments; |
| 2517 } |
| 2518 error::Error error = |
| 2519 DoBindFragDataLocationEXT(program, colorNumber, name_str.c_str()); |
| 2520 if (error != error::kNoError) { |
| 2521 return error; |
| 2522 } |
| 2523 return error::kNoError; |
| 2524 } |
| 2525 error::Error GLES2DecoderPassthroughImpl::HandleGetFragDataIndexEXT( |
| 2526 uint32_t immediate_data_size, |
| 2527 const void* cmd_data) { |
| 2528 const gles2::cmds::GetFragDataIndexEXT& c = |
| 2529 *static_cast<const gles2::cmds::GetFragDataIndexEXT*>(cmd_data); |
| 2530 GLuint program = static_cast<GLuint>(c.program); |
| 2531 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 2532 if (!bucket) { |
| 2533 return error::kInvalidArguments; |
| 2534 } |
| 2535 std::string name_str; |
| 2536 if (!bucket->GetAsString(&name_str)) { |
| 2537 return error::kInvalidArguments; |
| 2538 } |
| 2539 GLint* index = GetSharedMemoryAs<GLint*>(c.index_shm_id, c.index_shm_offset, |
| 2540 sizeof(GLint)); |
| 2541 if (!index) { |
| 2542 return error::kOutOfBounds; |
| 2543 } |
| 2544 // Check that the client initialized the result. |
| 2545 if (*index != -1) { |
| 2546 return error::kInvalidArguments; |
| 2547 } |
| 2548 error::Error error = DoGetFragDataIndexEXT(program, name_str.c_str(), index); |
| 2549 if (error != error::kNoError) { |
| 2550 return error; |
| 2551 } |
| 2552 return error::kNoError; |
| 2553 } |
| 2554 |
| 2555 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_auto
gen.h" |
| 2556 |
| 2557 } // namespace gles2 |
| 2558 } // namespace gpu |
| 2559 |
| 2560 #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_PASSTHROUGH_HANDLERS_H_ |
OLD | NEW |