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