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