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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
11 #include <GLES2/gl2extchromium.h> 11 #include <GLES2/gl2extchromium.h>
12 #include <GLES3/gl3.h> 12 #include <GLES3/gl3.h>
13 #include <stddef.h>
14 #include <stdint.h>
13 #include <algorithm> 15 #include <algorithm>
14 #include <map> 16 #include <map>
15 #include <set> 17 #include <set>
16 #include <sstream> 18 #include <sstream>
17 #include <string> 19 #include <string>
18 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
19 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
20 #include "base/sys_info.h" 22 #include "base/sys_info.h"
21 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
22 #include "base/trace_event/memory_allocator_dump.h" 24 #include "base/trace_event/memory_allocator_dump.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (namespace_id == id_namespaces::kQueries) 283 if (namespace_id == id_namespaces::kQueries)
282 return query_id_allocator_.get(); 284 return query_id_allocator_.get();
283 NOTREACHED(); 285 NOTREACHED();
284 return NULL; 286 return NULL;
285 } 287 }
286 288
287 void* GLES2Implementation::GetResultBuffer() { 289 void* GLES2Implementation::GetResultBuffer() {
288 return transfer_buffer_->GetResultBuffer(); 290 return transfer_buffer_->GetResultBuffer();
289 } 291 }
290 292
291 int32 GLES2Implementation::GetResultShmId() { 293 int32_t GLES2Implementation::GetResultShmId() {
292 return transfer_buffer_->GetShmId(); 294 return transfer_buffer_->GetShmId();
293 } 295 }
294 296
295 uint32 GLES2Implementation::GetResultShmOffset() { 297 uint32_t GLES2Implementation::GetResultShmOffset() {
296 return transfer_buffer_->GetResultOffset(); 298 return transfer_buffer_->GetResultOffset();
297 } 299 }
298 300
299 void GLES2Implementation::FreeUnusedSharedMemory() { 301 void GLES2Implementation::FreeUnusedSharedMemory() {
300 mapped_memory_->FreeUnused(); 302 mapped_memory_->FreeUnused();
301 } 303 }
302 304
303 void GLES2Implementation::FreeEverything() { 305 void GLES2Implementation::FreeEverything() {
304 WaitForCmd(); 306 WaitForCmd();
305 query_tracker_->Shrink(); 307 query_tracker_->Shrink();
306 FreeUnusedSharedMemory(); 308 FreeUnusedSharedMemory();
307 transfer_buffer_->Free(); 309 transfer_buffer_->Free();
308 helper_->FreeRingBuffer(); 310 helper_->FreeRingBuffer();
309 } 311 }
310 312
311 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) { 313 void GLES2Implementation::RunIfContextNotLost(const base::Closure& callback) {
312 if (!helper_->IsContextLost()) 314 if (!helper_->IsContextLost())
313 callback.Run(); 315 callback.Run();
314 } 316 }
315 317
316 void GLES2Implementation::SignalSyncPoint(uint32 sync_point, 318 void GLES2Implementation::SignalSyncPoint(uint32_t sync_point,
317 const base::Closure& callback) { 319 const base::Closure& callback) {
318 gpu_control_->SignalSyncPoint( 320 gpu_control_->SignalSyncPoint(
319 sync_point, 321 sync_point,
320 base::Bind(&GLES2Implementation::RunIfContextNotLost, 322 base::Bind(&GLES2Implementation::RunIfContextNotLost,
321 weak_ptr_factory_.GetWeakPtr(), 323 weak_ptr_factory_.GetWeakPtr(),
322 callback)); 324 callback));
323 } 325 }
324 326
325 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token, 327 void GLES2Implementation::SignalSyncToken(const gpu::SyncToken& sync_token,
326 const base::Closure& callback) { 328 const base::Closure& callback) {
(...skipping 11 matching lines...) Expand all
338 intermediate_sync_token, 340 intermediate_sync_token,
339 base::Bind(&GLES2Implementation::RunIfContextNotLost, 341 base::Bind(&GLES2Implementation::RunIfContextNotLost,
340 weak_ptr_factory_.GetWeakPtr(), 342 weak_ptr_factory_.GetWeakPtr(),
341 callback)); 343 callback));
342 } else { 344 } else {
343 // Invalid sync token, just call the callback immediately. 345 // Invalid sync token, just call the callback immediately.
344 callback.Run(); 346 callback.Run();
345 } 347 }
346 } 348 }
347 349
348 void GLES2Implementation::SignalQuery(uint32 query, 350 void GLES2Implementation::SignalQuery(uint32_t query,
349 const base::Closure& callback) { 351 const base::Closure& callback) {
350 // Flush previously entered commands to ensure ordering with any 352 // Flush previously entered commands to ensure ordering with any
351 // glBeginQueryEXT() calls that may have been put into the context. 353 // glBeginQueryEXT() calls that may have been put into the context.
352 ShallowFlushCHROMIUM(); 354 ShallowFlushCHROMIUM();
353 gpu_control_->SignalQuery( 355 gpu_control_->SignalQuery(
354 query, 356 query,
355 base::Bind(&GLES2Implementation::RunIfContextNotLost, 357 base::Bind(&GLES2Implementation::RunIfContextNotLost,
356 weak_ptr_factory_.GetWeakPtr(), 358 weak_ptr_factory_.GetWeakPtr(),
357 callback)); 359 callback));
358 } 360 }
(...skipping 15 matching lines...) Expand all
374 ShallowFlushCHROMIUM(); 376 ShallowFlushCHROMIUM();
375 } 377 }
376 } 378 }
377 379
378 bool GLES2Implementation::OnMemoryDump( 380 bool GLES2Implementation::OnMemoryDump(
379 const base::trace_event::MemoryDumpArgs& args, 381 const base::trace_event::MemoryDumpArgs& args,
380 base::trace_event::ProcessMemoryDump* pmd) { 382 base::trace_event::ProcessMemoryDump* pmd) {
381 if (!transfer_buffer_->HaveBuffer()) 383 if (!transfer_buffer_->HaveBuffer())
382 return true; 384 return true;
383 385
384 const uint64 tracing_process_id = 386 const uint64_t tracing_process_id =
385 base::trace_event::MemoryDumpManager::GetInstance() 387 base::trace_event::MemoryDumpManager::GetInstance()
386 ->GetTracingProcessId(); 388 ->GetTracingProcessId();
387 389
388 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( 390 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(
389 base::StringPrintf("gpu/transfer_buffer_memory/buffer_%d", 391 base::StringPrintf("gpu/transfer_buffer_memory/buffer_%d",
390 transfer_buffer_->GetShmId())); 392 transfer_buffer_->GetShmId()));
391 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 393 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
392 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 394 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
393 transfer_buffer_->GetSize()); 395 transfer_buffer_->GetSize());
394 dump->AddScalar("free_size", 396 dump->AddScalar("free_size",
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 GPU_CLIENT_LOG("returned " << GLES2Util::GetStringError(err)); 469 GPU_CLIENT_LOG("returned " << GLES2Util::GetStringError(err));
468 return err; 470 return err;
469 } 471 }
470 472
471 GLenum GLES2Implementation::GetClientSideGLError() { 473 GLenum GLES2Implementation::GetClientSideGLError() {
472 if (error_bits_ == 0) { 474 if (error_bits_ == 0) {
473 return GL_NO_ERROR; 475 return GL_NO_ERROR;
474 } 476 }
475 477
476 GLenum error = GL_NO_ERROR; 478 GLenum error = GL_NO_ERROR;
477 for (uint32 mask = 1; mask != 0; mask = mask << 1) { 479 for (uint32_t mask = 1; mask != 0; mask = mask << 1) {
478 if ((error_bits_ & mask) != 0) { 480 if ((error_bits_ & mask) != 0) {
479 error = GLES2Util::GLErrorBitToGLError(mask); 481 error = GLES2Util::GLErrorBitToGLError(mask);
480 break; 482 break;
481 } 483 }
482 } 484 }
483 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error); 485 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error);
484 return error; 486 return error;
485 } 487 }
486 488
487 GLenum GLES2Implementation::GetGLError() { 489 GLenum GLES2Implementation::GetGLError() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 542 }
541 } 543 }
542 544
543 void GLES2Implementation::SetGLErrorInvalidEnum( 545 void GLES2Implementation::SetGLErrorInvalidEnum(
544 const char* function_name, GLenum value, const char* label) { 546 const char* function_name, GLenum value, const char* label) {
545 SetGLError(GL_INVALID_ENUM, function_name, 547 SetGLError(GL_INVALID_ENUM, function_name,
546 (std::string(label) + " was " + 548 (std::string(label) + " was " +
547 GLES2Util::GetStringEnum(value)).c_str()); 549 GLES2Util::GetStringEnum(value)).c_str());
548 } 550 }
549 551
550 bool GLES2Implementation::GetBucketContents(uint32 bucket_id, 552 bool GLES2Implementation::GetBucketContents(uint32_t bucket_id,
551 std::vector<int8>* data) { 553 std::vector<int8_t>* data) {
552 TRACE_EVENT0("gpu", "GLES2::GetBucketContents"); 554 TRACE_EVENT0("gpu", "GLES2::GetBucketContents");
553 DCHECK(data); 555 DCHECK(data);
554 const uint32 kStartSize = 32 * 1024; 556 const uint32_t kStartSize = 32 * 1024;
555 ScopedTransferBufferPtr buffer(kStartSize, helper_, transfer_buffer_); 557 ScopedTransferBufferPtr buffer(kStartSize, helper_, transfer_buffer_);
556 if (!buffer.valid()) { 558 if (!buffer.valid()) {
557 return false; 559 return false;
558 } 560 }
559 typedef cmd::GetBucketStart::Result Result; 561 typedef cmd::GetBucketStart::Result Result;
560 Result* result = GetResultAs<Result*>(); 562 Result* result = GetResultAs<Result*>();
561 if (!result) { 563 if (!result) {
562 return false; 564 return false;
563 } 565 }
564 *result = 0; 566 *result = 0;
565 helper_->GetBucketStart( 567 helper_->GetBucketStart(
566 bucket_id, GetResultShmId(), GetResultShmOffset(), 568 bucket_id, GetResultShmId(), GetResultShmOffset(),
567 buffer.size(), buffer.shm_id(), buffer.offset()); 569 buffer.size(), buffer.shm_id(), buffer.offset());
568 WaitForCmd(); 570 WaitForCmd();
569 uint32 size = *result; 571 uint32_t size = *result;
570 data->resize(size); 572 data->resize(size);
571 if (size > 0u) { 573 if (size > 0u) {
572 uint32 offset = 0; 574 uint32_t offset = 0;
573 while (size) { 575 while (size) {
574 if (!buffer.valid()) { 576 if (!buffer.valid()) {
575 buffer.Reset(size); 577 buffer.Reset(size);
576 if (!buffer.valid()) { 578 if (!buffer.valid()) {
577 return false; 579 return false;
578 } 580 }
579 helper_->GetBucketData( 581 helper_->GetBucketData(
580 bucket_id, offset, buffer.size(), buffer.shm_id(), buffer.offset()); 582 bucket_id, offset, buffer.size(), buffer.shm_id(), buffer.offset());
581 WaitForCmd(); 583 WaitForCmd();
582 } 584 }
583 uint32 size_to_copy = std::min(size, buffer.size()); 585 uint32_t size_to_copy = std::min(size, buffer.size());
584 memcpy(&(*data)[offset], buffer.address(), size_to_copy); 586 memcpy(&(*data)[offset], buffer.address(), size_to_copy);
585 offset += size_to_copy; 587 offset += size_to_copy;
586 size -= size_to_copy; 588 size -= size_to_copy;
587 buffer.Release(); 589 buffer.Release();
588 } 590 }
589 // Free the bucket. This is not required but it does free up the memory. 591 // Free the bucket. This is not required but it does free up the memory.
590 // and we don't have to wait for the result so from the client's perspective 592 // and we don't have to wait for the result so from the client's perspective
591 // it's cheap. 593 // it's cheap.
592 helper_->SetBucketSize(bucket_id, 0); 594 helper_->SetBucketSize(bucket_id, 0);
593 } 595 }
594 return true; 596 return true;
595 } 597 }
596 598
597 void GLES2Implementation::SetBucketContents( 599 void GLES2Implementation::SetBucketContents(uint32_t bucket_id,
598 uint32 bucket_id, const void* data, size_t size) { 600 const void* data,
601 size_t size) {
599 DCHECK(data); 602 DCHECK(data);
600 helper_->SetBucketSize(bucket_id, size); 603 helper_->SetBucketSize(bucket_id, size);
601 if (size > 0u) { 604 if (size > 0u) {
602 uint32 offset = 0; 605 uint32_t offset = 0;
603 while (size) { 606 while (size) {
604 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); 607 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
605 if (!buffer.valid()) { 608 if (!buffer.valid()) {
606 return; 609 return;
607 } 610 }
608 memcpy(buffer.address(), static_cast<const int8*>(data) + offset, 611 memcpy(buffer.address(), static_cast<const int8_t*>(data) + offset,
609 buffer.size()); 612 buffer.size());
610 helper_->SetBucketData( 613 helper_->SetBucketData(
611 bucket_id, offset, buffer.size(), buffer.shm_id(), buffer.offset()); 614 bucket_id, offset, buffer.size(), buffer.shm_id(), buffer.offset());
612 offset += buffer.size(); 615 offset += buffer.size();
613 size -= buffer.size(); 616 size -= buffer.size();
614 } 617 }
615 } 618 }
616 } 619 }
617 620
618 void GLES2Implementation::SetBucketAsCString( 621 void GLES2Implementation::SetBucketAsCString(uint32_t bucket_id,
619 uint32 bucket_id, const char* str) { 622 const char* str) {
620 // NOTE: strings are passed NULL terminated. That means the empty 623 // NOTE: strings are passed NULL terminated. That means the empty
621 // string will have a size of 1 and no-string will have a size of 0 624 // string will have a size of 1 and no-string will have a size of 0
622 if (str) { 625 if (str) {
623 SetBucketContents(bucket_id, str, strlen(str) + 1); 626 SetBucketContents(bucket_id, str, strlen(str) + 1);
624 } else { 627 } else {
625 helper_->SetBucketSize(bucket_id, 0); 628 helper_->SetBucketSize(bucket_id, 0);
626 } 629 }
627 } 630 }
628 631
629 bool GLES2Implementation::GetBucketAsString( 632 bool GLES2Implementation::GetBucketAsString(uint32_t bucket_id,
630 uint32 bucket_id, std::string* str) { 633 std::string* str) {
631 DCHECK(str); 634 DCHECK(str);
632 std::vector<int8> data; 635 std::vector<int8_t> data;
633 // NOTE: strings are passed NULL terminated. That means the empty 636 // NOTE: strings are passed NULL terminated. That means the empty
634 // string will have a size of 1 and no-string will have a size of 0 637 // string will have a size of 1 and no-string will have a size of 0
635 if (!GetBucketContents(bucket_id, &data)) { 638 if (!GetBucketContents(bucket_id, &data)) {
636 return false; 639 return false;
637 } 640 }
638 if (data.empty()) { 641 if (data.empty()) {
639 return false; 642 return false;
640 } 643 }
641 str->assign(&data[0], &data[0] + data.size() - 1); 644 str->assign(&data[0], &data[0] + data.size() - 1);
642 return true; 645 return true;
643 } 646 }
644 647
645 void GLES2Implementation::SetBucketAsString( 648 void GLES2Implementation::SetBucketAsString(uint32_t bucket_id,
646 uint32 bucket_id, const std::string& str) { 649 const std::string& str) {
647 // NOTE: strings are passed NULL terminated. That means the empty 650 // NOTE: strings are passed NULL terminated. That means the empty
648 // string will have a size of 1 and no-string will have a size of 0 651 // string will have a size of 1 and no-string will have a size of 0
649 SetBucketContents(bucket_id, str.c_str(), str.size() + 1); 652 SetBucketContents(bucket_id, str.c_str(), str.size() + 1);
650 } 653 }
651 654
652 void GLES2Implementation::Disable(GLenum cap) { 655 void GLES2Implementation::Disable(GLenum cap) {
653 GPU_CLIENT_SINGLE_THREAD_CHECK(); 656 GPU_CLIENT_SINGLE_THREAD_CHECK();
654 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDisable(" 657 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDisable("
655 << GLES2Util::GetStringCapability(cap) << ")"); 658 << GLES2Util::GetStringCapability(cap) << ")");
656 bool changed = false; 659 bool changed = false;
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 helper_->SetBucketSize(kResultBucketId, 0); 1437 helper_->SetBucketSize(kResultBucketId, 0);
1435 CheckGLError(); 1438 CheckGLError();
1436 } 1439 }
1437 1440
1438 void GLES2Implementation::GetVertexAttribPointerv( 1441 void GLES2Implementation::GetVertexAttribPointerv(
1439 GLuint index, GLenum pname, void** ptr) { 1442 GLuint index, GLenum pname, void** ptr) {
1440 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1443 GPU_CLIENT_SINGLE_THREAD_CHECK();
1441 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribPointer(" 1444 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribPointer("
1442 << index << ", " << GLES2Util::GetStringVertexPointer(pname) << ", " 1445 << index << ", " << GLES2Util::GetStringVertexPointer(pname) << ", "
1443 << static_cast<void*>(ptr) << ")"); 1446 << static_cast<void*>(ptr) << ")");
1444 GPU_CLIENT_LOG_CODE_BLOCK(int32 num_results = 1); 1447 GPU_CLIENT_LOG_CODE_BLOCK(int32_t num_results = 1);
1445 if (!vertex_array_object_manager_->GetAttribPointer(index, pname, ptr)) { 1448 if (!vertex_array_object_manager_->GetAttribPointer(index, pname, ptr)) {
1446 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv"); 1449 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv");
1447 typedef cmds::GetVertexAttribPointerv::Result Result; 1450 typedef cmds::GetVertexAttribPointerv::Result Result;
1448 Result* result = GetResultAs<Result*>(); 1451 Result* result = GetResultAs<Result*>();
1449 if (!result) { 1452 if (!result) {
1450 return; 1453 return;
1451 } 1454 }
1452 result->SetNumResults(0); 1455 result->SetNumResults(0);
1453 helper_->GetVertexAttribPointerv( 1456 helper_->GetVertexAttribPointerv(
1454 index, pname, GetResultShmId(), GetResultShmOffset()); 1457 index, pname, GetResultShmId(), GetResultShmOffset());
1455 WaitForCmd(); 1458 WaitForCmd();
1456 result->CopyResult(ptr); 1459 result->CopyResult(ptr);
1457 GPU_CLIENT_LOG_CODE_BLOCK(num_results = result->GetNumResults()); 1460 GPU_CLIENT_LOG_CODE_BLOCK(num_results = result->GetNumResults());
1458 } 1461 }
1459 GPU_CLIENT_LOG_CODE_BLOCK({ 1462 GPU_CLIENT_LOG_CODE_BLOCK({
1460 for (int32 i = 0; i < num_results; ++i) { 1463 for (int32_t i = 0; i < num_results; ++i) {
1461 GPU_CLIENT_LOG(" " << i << ": " << ptr[i]); 1464 GPU_CLIENT_LOG(" " << i << ": " << ptr[i]);
1462 } 1465 }
1463 }); 1466 });
1464 CheckGLError(); 1467 CheckGLError();
1465 } 1468 }
1466 1469
1467 bool GLES2Implementation::DeleteProgramHelper(GLuint program) { 1470 bool GLES2Implementation::DeleteProgramHelper(GLuint program) {
1468 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds( 1471 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds(
1469 this, 1, &program, &GLES2Implementation::DeleteProgramStub)) { 1472 this, 1, &program, &GLES2Implementation::DeleteProgramStub)) {
1470 SetGLError( 1473 SetGLError(
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 if (GetBoundPixelTransferBuffer(target, "glBufferSubData", &buffer_id)) { 1989 if (GetBoundPixelTransferBuffer(target, "glBufferSubData", &buffer_id)) {
1987 if (!buffer_id) { 1990 if (!buffer_id) {
1988 return; 1991 return;
1989 } 1992 }
1990 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); 1993 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id);
1991 if (!buffer) { 1994 if (!buffer) {
1992 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer"); 1995 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer");
1993 return; 1996 return;
1994 } 1997 }
1995 1998
1996 int32 end = 0; 1999 int32_t end = 0;
1997 int32 buffer_size = buffer->size(); 2000 int32_t buffer_size = buffer->size();
1998 if (!SafeAddInt32(offset, size, &end) || end > buffer_size) { 2001 if (!SafeAddInt32(offset, size, &end) || end > buffer_size) {
1999 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range"); 2002 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range");
2000 return; 2003 return;
2001 } 2004 }
2002 2005
2003 if (buffer->address() && data) 2006 if (buffer->address() && data)
2004 memcpy(static_cast<uint8*>(buffer->address()) + offset, data, size); 2007 memcpy(static_cast<uint8_t*>(buffer->address()) + offset, data, size);
2005 return; 2008 return;
2006 } 2009 }
2007 2010
2008 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); 2011 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
2009 BufferSubDataHelperImpl(target, offset, size, data, &buffer); 2012 BufferSubDataHelperImpl(target, offset, size, data, &buffer);
2010 } 2013 }
2011 2014
2012 void GLES2Implementation::BufferSubDataHelperImpl( 2015 void GLES2Implementation::BufferSubDataHelperImpl(
2013 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, 2016 GLenum target, GLintptr offset, GLsizeiptr size, const void* data,
2014 ScopedTransferBufferPtr* buffer) { 2017 ScopedTransferBufferPtr* buffer) {
2015 DCHECK(buffer); 2018 DCHECK(buffer);
2016 DCHECK_GT(size, 0); 2019 DCHECK_GT(size, 0);
2017 2020
2018 const int8* source = static_cast<const int8*>(data); 2021 const int8_t* source = static_cast<const int8_t*>(data);
2019 while (size) { 2022 while (size) {
2020 if (!buffer->valid() || buffer->size() == 0) { 2023 if (!buffer->valid() || buffer->size() == 0) {
2021 buffer->Reset(size); 2024 buffer->Reset(size);
2022 if (!buffer->valid()) { 2025 if (!buffer->valid()) {
2023 return; 2026 return;
2024 } 2027 }
2025 } 2028 }
2026 memcpy(buffer->address(), source, buffer->size()); 2029 memcpy(buffer->address(), source, buffer->size());
2027 helper_->BufferSubData( 2030 helper_->BufferSubData(
2028 target, offset, buffer->size(), buffer->shm_id(), buffer->offset()); 2031 target, offset, buffer->size(), buffer->shm_id(), buffer->offset());
2029 offset += buffer->size(); 2032 offset += buffer->size();
2030 source += buffer->size(); 2033 source += buffer->size();
2031 size -= buffer->size(); 2034 size -= buffer->size();
2032 buffer->Release(); 2035 buffer->Release();
2033 } 2036 }
2034 } 2037 }
2035 2038
2036 void GLES2Implementation::BufferSubData( 2039 void GLES2Implementation::BufferSubData(
2037 GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { 2040 GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
2038 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2041 GPU_CLIENT_SINGLE_THREAD_CHECK();
2039 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBufferSubData(" 2042 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glBufferSubData("
2040 << GLES2Util::GetStringBufferTarget(target) << ", " 2043 << GLES2Util::GetStringBufferTarget(target) << ", "
2041 << offset << ", " << size << ", " 2044 << offset << ", " << size << ", "
2042 << static_cast<const void*>(data) << ")"); 2045 << static_cast<const void*>(data) << ")");
2043 BufferSubDataHelper(target, offset, size, data); 2046 BufferSubDataHelper(target, offset, size, data);
2044 CheckGLError(); 2047 CheckGLError();
2045 } 2048 }
2046 2049
2047 void GLES2Implementation::RemoveTransferBuffer(BufferTracker::Buffer* buffer) { 2050 void GLES2Implementation::RemoveTransferBuffer(BufferTracker::Buffer* buffer) {
2048 int32 token = buffer->last_usage_token(); 2051 int32_t token = buffer->last_usage_token();
2049 2052
2050 if (token) { 2053 if (token) {
2051 if (helper_->HasTokenPassed(token)) 2054 if (helper_->HasTokenPassed(token))
2052 buffer_tracker_->Free(buffer); 2055 buffer_tracker_->Free(buffer);
2053 else 2056 else
2054 buffer_tracker_->FreePendingToken(buffer, token); 2057 buffer_tracker_->FreePendingToken(buffer, token);
2055 } else { 2058 } else {
2056 buffer_tracker_->Free(buffer); 2059 buffer_tracker_->Free(buffer);
2057 } 2060 }
2058 2061
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 kResultBucketId); 2282 kResultBucketId);
2280 // Free the bucket. This is not required but it does free up the memory. 2283 // Free the bucket. This is not required but it does free up the memory.
2281 // and we don't have to wait for the result so from the client's perspective 2284 // and we don't have to wait for the result so from the client's perspective
2282 // it's cheap. 2285 // it's cheap.
2283 helper_->SetBucketSize(kResultBucketId, 0); 2286 helper_->SetBucketSize(kResultBucketId, 0);
2284 CheckGLError(); 2287 CheckGLError();
2285 } 2288 }
2286 2289
2287 namespace { 2290 namespace {
2288 2291
2289 void CopyRectToBuffer( 2292 void CopyRectToBuffer(const void* pixels,
2290 const void* pixels, 2293 uint32_t height,
2291 uint32 height, 2294 uint32_t unpadded_row_size,
2292 uint32 unpadded_row_size, 2295 uint32_t pixels_padded_row_size,
2293 uint32 pixels_padded_row_size, 2296 void* buffer,
2294 void* buffer, 2297 uint32_t buffer_padded_row_size) {
2295 uint32 buffer_padded_row_size) { 2298 const int8_t* source = static_cast<const int8_t*>(pixels);
2296 const int8* source = static_cast<const int8*>(pixels); 2299 int8_t* dest = static_cast<int8_t*>(buffer);
2297 int8* dest = static_cast<int8*>(buffer);
2298 if (pixels_padded_row_size != buffer_padded_row_size) { 2300 if (pixels_padded_row_size != buffer_padded_row_size) {
2299 // the last row is copied unpadded at the end 2301 // the last row is copied unpadded at the end
2300 for (; height > 1; --height) { 2302 for (; height > 1; --height) {
2301 memcpy(dest, source, buffer_padded_row_size); 2303 memcpy(dest, source, buffer_padded_row_size);
2302 dest += buffer_padded_row_size; 2304 dest += buffer_padded_row_size;
2303 source += pixels_padded_row_size; 2305 source += pixels_padded_row_size;
2304 } 2306 }
2305 memcpy(dest, source, unpadded_row_size); 2307 memcpy(dest, source, unpadded_row_size);
2306 } else { 2308 } else {
2307 uint32 size = (height - 1) * pixels_padded_row_size + unpadded_row_size; 2309 uint32_t size = (height - 1) * pixels_padded_row_size + unpadded_row_size;
2308 memcpy(dest, source, size); 2310 memcpy(dest, source, size);
2309 } 2311 }
2310 } 2312 }
2311 2313
2312 } // anonymous namespace 2314 } // anonymous namespace
2313 2315
2314 void GLES2Implementation::TexImage2D( 2316 void GLES2Implementation::TexImage2D(
2315 GLenum target, GLint level, GLint internalformat, GLsizei width, 2317 GLenum target, GLint level, GLint internalformat, GLsizei width,
2316 GLsizei height, GLint border, GLenum format, GLenum type, 2318 GLsizei height, GLint border, GLenum format, GLenum type,
2317 const void* pixels) { 2319 const void* pixels) {
2318 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2320 GPU_CLIENT_SINGLE_THREAD_CHECK();
2319 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D(" 2321 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D("
2320 << GLES2Util::GetStringTextureTarget(target) << ", " 2322 << GLES2Util::GetStringTextureTarget(target) << ", "
2321 << level << ", " 2323 << level << ", "
2322 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " 2324 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
2323 << width << ", " << height << ", " << border << ", " 2325 << width << ", " << height << ", " << border << ", "
2324 << GLES2Util::GetStringTextureFormat(format) << ", " 2326 << GLES2Util::GetStringTextureFormat(format) << ", "
2325 << GLES2Util::GetStringPixelType(type) << ", " 2327 << GLES2Util::GetStringPixelType(type) << ", "
2326 << static_cast<const void*>(pixels) << ")"); 2328 << static_cast<const void*>(pixels) << ")");
2327 if (level < 0 || height < 0 || width < 0) { 2329 if (level < 0 || height < 0 || width < 0) {
2328 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0"); 2330 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0");
2329 return; 2331 return;
2330 } 2332 }
2331 if (border != 0) { 2333 if (border != 0) {
2332 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0"); 2334 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "border != 0");
2333 return; 2335 return;
2334 } 2336 }
2335 uint32 size; 2337 uint32_t size;
2336 uint32 unpadded_row_size; 2338 uint32_t unpadded_row_size;
2337 uint32 padded_row_size; 2339 uint32_t padded_row_size;
2338 if (!GLES2Util::ComputeImageDataSizes( 2340 if (!GLES2Util::ComputeImageDataSizes(
2339 width, height, 1, format, type, unpack_alignment_, &size, 2341 width, height, 1, format, type, unpack_alignment_, &size,
2340 &unpadded_row_size, &padded_row_size)) { 2342 &unpadded_row_size, &padded_row_size)) {
2341 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); 2343 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
2342 return; 2344 return;
2343 } 2345 }
2344 2346
2345 // If there's a pixel unpack buffer bound use it when issuing TexImage2D. 2347 // If there's a pixel unpack buffer bound use it when issuing TexImage2D.
2346 if (bound_pixel_unpack_transfer_buffer_id_) { 2348 if (bound_pixel_unpack_transfer_buffer_id_) {
2347 GLuint offset = ToGLuint(pixels); 2349 GLuint offset = ToGLuint(pixels);
(...skipping 13 matching lines...) Expand all
2361 // If there's no data just issue TexImage2D 2363 // If there's no data just issue TexImage2D
2362 if (!pixels) { 2364 if (!pixels) {
2363 helper_->TexImage2D( 2365 helper_->TexImage2D(
2364 target, level, internalformat, width, height, format, type, 2366 target, level, internalformat, width, height, format, type,
2365 0, 0); 2367 0, 0);
2366 CheckGLError(); 2368 CheckGLError();
2367 return; 2369 return;
2368 } 2370 }
2369 2371
2370 // compute the advance bytes per row for the src pixels 2372 // compute the advance bytes per row for the src pixels
2371 uint32 src_padded_row_size; 2373 uint32_t src_padded_row_size;
2372 if (unpack_row_length_ > 0) { 2374 if (unpack_row_length_ > 0) {
2373 if (!GLES2Util::ComputeImagePaddedRowSize( 2375 if (!GLES2Util::ComputeImagePaddedRowSize(
2374 unpack_row_length_, format, type, unpack_alignment_, 2376 unpack_row_length_, format, type, unpack_alignment_,
2375 &src_padded_row_size)) { 2377 &src_padded_row_size)) {
2376 SetGLError( 2378 SetGLError(
2377 GL_INVALID_VALUE, "glTexImage2D", "unpack row length too large"); 2379 GL_INVALID_VALUE, "glTexImage2D", "unpack row length too large");
2378 return; 2380 return;
2379 } 2381 }
2380 } else { 2382 } else {
2381 src_padded_row_size = padded_row_size; 2383 src_padded_row_size = padded_row_size;
2382 } 2384 }
2383 2385
2384 // advance pixels pointer past the skip rows and skip pixels 2386 // advance pixels pointer past the skip rows and skip pixels
2385 pixels = reinterpret_cast<const int8*>(pixels) + 2387 pixels = reinterpret_cast<const int8_t*>(pixels) +
2386 unpack_skip_rows_ * src_padded_row_size; 2388 unpack_skip_rows_ * src_padded_row_size;
2387 if (unpack_skip_pixels_) { 2389 if (unpack_skip_pixels_) {
2388 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type); 2390 uint32_t group_size = GLES2Util::ComputeImageGroupSize(format, type);
2389 pixels = reinterpret_cast<const int8*>(pixels) + 2391 pixels = reinterpret_cast<const int8_t*>(pixels) +
2390 unpack_skip_pixels_ * group_size; 2392 unpack_skip_pixels_ * group_size;
2391 } 2393 }
2392 2394
2393 // Check if we can send it all at once. 2395 // Check if we can send it all at once.
2394 int32_t shm_id = 0; 2396 int32_t shm_id = 0;
2395 uint32_t shm_offset = 0; 2397 uint32_t shm_offset = 0;
2396 void* buffer_pointer = nullptr; 2398 void* buffer_pointer = nullptr;
2397 2399
2398 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); 2400 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_);
2399 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); 2401 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get());
2400 2402
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 << GLES2Util::GetStringPixelType(type) << ", " 2451 << GLES2Util::GetStringPixelType(type) << ", "
2450 << static_cast<const void*>(pixels) << ")"); 2452 << static_cast<const void*>(pixels) << ")");
2451 if (level < 0 || height < 0 || width < 0 || depth < 0) { 2453 if (level < 0 || height < 0 || width < 0 || depth < 0) {
2452 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "dimension < 0"); 2454 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "dimension < 0");
2453 return; 2455 return;
2454 } 2456 }
2455 if (border != 0) { 2457 if (border != 0) {
2456 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "border != 0"); 2458 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "border != 0");
2457 return; 2459 return;
2458 } 2460 }
2459 uint32 size; 2461 uint32_t size;
2460 uint32 unpadded_row_size; 2462 uint32_t unpadded_row_size;
2461 uint32 padded_row_size; 2463 uint32_t padded_row_size;
2462 if (!GLES2Util::ComputeImageDataSizes( 2464 if (!GLES2Util::ComputeImageDataSizes(
2463 width, height, depth, format, type, unpack_alignment_, &size, 2465 width, height, depth, format, type, unpack_alignment_, &size,
2464 &unpadded_row_size, &padded_row_size)) { 2466 &unpadded_row_size, &padded_row_size)) {
2465 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "image size too large"); 2467 SetGLError(GL_INVALID_VALUE, "glTexImage3D", "image size too large");
2466 return; 2468 return;
2467 } 2469 }
2468 2470
2469 // If there's a pixel unpack buffer bound use it when issuing TexImage3D. 2471 // If there's a pixel unpack buffer bound use it when issuing TexImage3D.
2470 if (bound_pixel_unpack_transfer_buffer_id_) { 2472 if (bound_pixel_unpack_transfer_buffer_id_) {
2471 GLuint offset = ToGLuint(pixels); 2473 GLuint offset = ToGLuint(pixels);
(...skipping 13 matching lines...) Expand all
2485 // If there's no data just issue TexImage3D 2487 // If there's no data just issue TexImage3D
2486 if (!pixels) { 2488 if (!pixels) {
2487 helper_->TexImage3D( 2489 helper_->TexImage3D(
2488 target, level, internalformat, width, height, depth, format, type, 2490 target, level, internalformat, width, height, depth, format, type,
2489 0, 0); 2491 0, 0);
2490 CheckGLError(); 2492 CheckGLError();
2491 return; 2493 return;
2492 } 2494 }
2493 2495
2494 // compute the advance bytes per row for the src pixels 2496 // compute the advance bytes per row for the src pixels
2495 uint32 src_padded_row_size; 2497 uint32_t src_padded_row_size;
2496 if (unpack_row_length_ > 0) { 2498 if (unpack_row_length_ > 0) {
2497 if (!GLES2Util::ComputeImagePaddedRowSize( 2499 if (!GLES2Util::ComputeImagePaddedRowSize(
2498 unpack_row_length_, format, type, unpack_alignment_, 2500 unpack_row_length_, format, type, unpack_alignment_,
2499 &src_padded_row_size)) { 2501 &src_padded_row_size)) {
2500 SetGLError( 2502 SetGLError(
2501 GL_INVALID_VALUE, "glTexImage3D", "unpack row length too large"); 2503 GL_INVALID_VALUE, "glTexImage3D", "unpack row length too large");
2502 return; 2504 return;
2503 } 2505 }
2504 } else { 2506 } else {
2505 src_padded_row_size = padded_row_size; 2507 src_padded_row_size = padded_row_size;
2506 } 2508 }
2507 uint32 src_height = unpack_image_height_ > 0 ? unpack_image_height_ : height; 2509 uint32_t src_height =
2510 unpack_image_height_ > 0 ? unpack_image_height_ : height;
2508 2511
2509 // advance pixels pointer past the skip images/rows/pixels 2512 // advance pixels pointer past the skip images/rows/pixels
2510 pixels = reinterpret_cast<const int8*>(pixels) + 2513 pixels = reinterpret_cast<const int8_t*>(pixels) +
2511 unpack_skip_images_ * src_padded_row_size * src_height + 2514 unpack_skip_images_ * src_padded_row_size * src_height +
2512 unpack_skip_rows_ * src_padded_row_size; 2515 unpack_skip_rows_ * src_padded_row_size;
2513 if (unpack_skip_pixels_) { 2516 if (unpack_skip_pixels_) {
2514 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type); 2517 uint32_t group_size = GLES2Util::ComputeImageGroupSize(format, type);
2515 pixels = reinterpret_cast<const int8*>(pixels) + 2518 pixels = reinterpret_cast<const int8_t*>(pixels) +
2516 unpack_skip_pixels_ * group_size; 2519 unpack_skip_pixels_ * group_size;
2517 } 2520 }
2518 2521
2519 // Check if we can send it all at once. 2522 // Check if we can send it all at once.
2520 int32_t shm_id = 0; 2523 int32_t shm_id = 0;
2521 uint32_t shm_offset = 0; 2524 uint32_t shm_offset = 0;
2522 void* buffer_pointer = nullptr; 2525 void* buffer_pointer = nullptr;
2523 2526
2524 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_); 2527 ScopedTransferBufferPtr transfer_alloc(size, helper_, transfer_buffer_);
2525 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get()); 2528 ScopedMappedMemoryPtr mapped_alloc(0, helper_, mapped_memory_.get());
2526 2529
2527 if (transfer_alloc.valid() && transfer_alloc.size() >= size) { 2530 if (transfer_alloc.valid() && transfer_alloc.size() >= size) {
2528 shm_id = transfer_alloc.shm_id(); 2531 shm_id = transfer_alloc.shm_id();
2529 shm_offset = transfer_alloc.offset(); 2532 shm_offset = transfer_alloc.offset();
2530 buffer_pointer = transfer_alloc.address(); 2533 buffer_pointer = transfer_alloc.address();
2531 } else if (size < max_extra_transfer_buffer_size_) { 2534 } else if (size < max_extra_transfer_buffer_size_) {
2532 mapped_alloc.Reset(size); 2535 mapped_alloc.Reset(size);
2533 if (mapped_alloc.valid()) { 2536 if (mapped_alloc.valid()) {
2534 transfer_alloc.Discard(); 2537 transfer_alloc.Discard();
2535 2538
2536 mapped_alloc.SetFlushAfterRelease(true); 2539 mapped_alloc.SetFlushAfterRelease(true);
2537 shm_id = mapped_alloc.shm_id(); 2540 shm_id = mapped_alloc.shm_id();
2538 shm_offset = mapped_alloc.offset(); 2541 shm_offset = mapped_alloc.offset();
2539 buffer_pointer = mapped_alloc.address(); 2542 buffer_pointer = mapped_alloc.address();
2540 } 2543 }
2541 } 2544 }
2542 2545
2543 if (buffer_pointer) { 2546 if (buffer_pointer) {
2544 for (GLsizei z = 0; z < depth; ++z) { 2547 for (GLsizei z = 0; z < depth; ++z) {
2545 // Only the last row of the last image is unpadded. 2548 // Only the last row of the last image is unpadded.
2546 uint32 src_unpadded_row_size = 2549 uint32_t src_unpadded_row_size =
2547 (z == depth - 1) ? unpadded_row_size : src_padded_row_size; 2550 (z == depth - 1) ? unpadded_row_size : src_padded_row_size;
2548 CopyRectToBuffer( 2551 CopyRectToBuffer(
2549 pixels, height, src_unpadded_row_size, src_padded_row_size, 2552 pixels, height, src_unpadded_row_size, src_padded_row_size,
2550 buffer_pointer, padded_row_size); 2553 buffer_pointer, padded_row_size);
2551 pixels = reinterpret_cast<const int8*>(pixels) + 2554 pixels = reinterpret_cast<const int8_t*>(pixels) +
2552 src_padded_row_size * src_height; 2555 src_padded_row_size * src_height;
2553 buffer_pointer = reinterpret_cast<int8*>(buffer_pointer) + 2556 buffer_pointer =
2554 padded_row_size * height; 2557 reinterpret_cast<int8_t*>(buffer_pointer) + padded_row_size * height;
2555 } 2558 }
2556 helper_->TexImage3D( 2559 helper_->TexImage3D(
2557 target, level, internalformat, width, height, depth, format, type, 2560 target, level, internalformat, width, height, depth, format, type,
2558 shm_id, shm_offset); 2561 shm_id, shm_offset);
2559 CheckGLError(); 2562 CheckGLError();
2560 return; 2563 return;
2561 } 2564 }
2562 2565
2563 // No, so send it using TexSubImage3D. 2566 // No, so send it using TexSubImage3D.
2564 helper_->TexImage3D( 2567 helper_->TexImage3D(
(...skipping 20 matching lines...) Expand all
2585 << static_cast<const void*>(pixels) << ")"); 2588 << static_cast<const void*>(pixels) << ")");
2586 2589
2587 if (level < 0 || height < 0 || width < 0) { 2590 if (level < 0 || height < 0 || width < 0) {
2588 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "dimension < 0"); 2591 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "dimension < 0");
2589 return; 2592 return;
2590 } 2593 }
2591 if (height == 0 || width == 0) { 2594 if (height == 0 || width == 0) {
2592 return; 2595 return;
2593 } 2596 }
2594 2597
2595 uint32 temp_size; 2598 uint32_t temp_size;
2596 uint32 unpadded_row_size; 2599 uint32_t unpadded_row_size;
2597 uint32 padded_row_size; 2600 uint32_t padded_row_size;
2598 if (!GLES2Util::ComputeImageDataSizes( 2601 if (!GLES2Util::ComputeImageDataSizes(
2599 width, height, 1, format, type, unpack_alignment_, &temp_size, 2602 width, height, 1, format, type, unpack_alignment_, &temp_size,
2600 &unpadded_row_size, &padded_row_size)) { 2603 &unpadded_row_size, &padded_row_size)) {
2601 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "size to large"); 2604 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "size to large");
2602 return; 2605 return;
2603 } 2606 }
2604 2607
2605 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D. 2608 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D.
2606 if (bound_pixel_unpack_transfer_buffer_id_) { 2609 if (bound_pixel_unpack_transfer_buffer_id_) {
2607 GLuint offset = ToGLuint(pixels); 2610 GLuint offset = ToGLuint(pixels);
2608 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( 2611 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
2609 bound_pixel_unpack_transfer_buffer_id_, 2612 bound_pixel_unpack_transfer_buffer_id_,
2610 "glTexSubImage2D", offset, temp_size); 2613 "glTexSubImage2D", offset, temp_size);
2611 if (buffer && buffer->shm_id() != -1) { 2614 if (buffer && buffer->shm_id() != -1) {
2612 helper_->TexSubImage2D( 2615 helper_->TexSubImage2D(
2613 target, level, xoffset, yoffset, width, height, format, type, 2616 target, level, xoffset, yoffset, width, height, format, type,
2614 buffer->shm_id(), buffer->shm_offset() + offset, false); 2617 buffer->shm_id(), buffer->shm_offset() + offset, false);
2615 buffer->set_last_usage_token(helper_->InsertToken()); 2618 buffer->set_last_usage_token(helper_->InsertToken());
2616 CheckGLError(); 2619 CheckGLError();
2617 } 2620 }
2618 return; 2621 return;
2619 } 2622 }
2620 2623
2621 // compute the advance bytes per row for the src pixels 2624 // compute the advance bytes per row for the src pixels
2622 uint32 src_padded_row_size; 2625 uint32_t src_padded_row_size;
2623 if (unpack_row_length_ > 0) { 2626 if (unpack_row_length_ > 0) {
2624 if (!GLES2Util::ComputeImagePaddedRowSize( 2627 if (!GLES2Util::ComputeImagePaddedRowSize(
2625 unpack_row_length_, format, type, unpack_alignment_, 2628 unpack_row_length_, format, type, unpack_alignment_,
2626 &src_padded_row_size)) { 2629 &src_padded_row_size)) {
2627 SetGLError( 2630 SetGLError(
2628 GL_INVALID_VALUE, "glTexImage2D", "unpack row length too large"); 2631 GL_INVALID_VALUE, "glTexImage2D", "unpack row length too large");
2629 return; 2632 return;
2630 } 2633 }
2631 } else { 2634 } else {
2632 src_padded_row_size = padded_row_size; 2635 src_padded_row_size = padded_row_size;
2633 } 2636 }
2634 2637
2635 // advance pixels pointer past the skip rows and skip pixels 2638 // advance pixels pointer past the skip rows and skip pixels
2636 pixels = reinterpret_cast<const int8*>(pixels) + 2639 pixels = reinterpret_cast<const int8_t*>(pixels) +
2637 unpack_skip_rows_ * src_padded_row_size; 2640 unpack_skip_rows_ * src_padded_row_size;
2638 if (unpack_skip_pixels_) { 2641 if (unpack_skip_pixels_) {
2639 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type); 2642 uint32_t group_size = GLES2Util::ComputeImageGroupSize(format, type);
2640 pixels = reinterpret_cast<const int8*>(pixels) + 2643 pixels = reinterpret_cast<const int8_t*>(pixels) +
2641 unpack_skip_pixels_ * group_size; 2644 unpack_skip_pixels_ * group_size;
2642 } 2645 }
2643 2646
2644 ScopedTransferBufferPtr buffer(temp_size, helper_, transfer_buffer_); 2647 ScopedTransferBufferPtr buffer(temp_size, helper_, transfer_buffer_);
2645 TexSubImage2DImpl( 2648 TexSubImage2DImpl(
2646 target, level, xoffset, yoffset, width, height, format, type, 2649 target, level, xoffset, yoffset, width, height, format, type,
2647 unpadded_row_size, pixels, src_padded_row_size, GL_FALSE, &buffer, 2650 unpadded_row_size, pixels, src_padded_row_size, GL_FALSE, &buffer,
2648 padded_row_size); 2651 padded_row_size);
2649 CheckGLError(); 2652 CheckGLError();
2650 } 2653 }
2651 2654
(...skipping 12 matching lines...) Expand all
2664 << static_cast<const void*>(pixels) << ")"); 2667 << static_cast<const void*>(pixels) << ")");
2665 2668
2666 if (level < 0 || height < 0 || width < 0 || depth < 0) { 2669 if (level < 0 || height < 0 || width < 0 || depth < 0) {
2667 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "dimension < 0"); 2670 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "dimension < 0");
2668 return; 2671 return;
2669 } 2672 }
2670 if (height == 0 || width == 0 || depth == 0) { 2673 if (height == 0 || width == 0 || depth == 0) {
2671 return; 2674 return;
2672 } 2675 }
2673 2676
2674 uint32 temp_size; 2677 uint32_t temp_size;
2675 uint32 unpadded_row_size; 2678 uint32_t unpadded_row_size;
2676 uint32 padded_row_size; 2679 uint32_t padded_row_size;
2677 if (!GLES2Util::ComputeImageDataSizes( 2680 if (!GLES2Util::ComputeImageDataSizes(
2678 width, height, depth, format, type, unpack_alignment_, &temp_size, 2681 width, height, depth, format, type, unpack_alignment_, &temp_size,
2679 &unpadded_row_size, &padded_row_size)) { 2682 &unpadded_row_size, &padded_row_size)) {
2680 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "size to large"); 2683 SetGLError(GL_INVALID_VALUE, "glTexSubImage3D", "size to large");
2681 return; 2684 return;
2682 } 2685 }
2683 2686
2684 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D. 2687 // If there's a pixel unpack buffer bound use it when issuing TexSubImage2D.
2685 if (bound_pixel_unpack_transfer_buffer_id_) { 2688 if (bound_pixel_unpack_transfer_buffer_id_) {
2686 GLuint offset = ToGLuint(pixels); 2689 GLuint offset = ToGLuint(pixels);
2687 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( 2690 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
2688 bound_pixel_unpack_transfer_buffer_id_, 2691 bound_pixel_unpack_transfer_buffer_id_,
2689 "glTexSubImage3D", offset, temp_size); 2692 "glTexSubImage3D", offset, temp_size);
2690 if (buffer && buffer->shm_id() != -1) { 2693 if (buffer && buffer->shm_id() != -1) {
2691 helper_->TexSubImage3D( 2694 helper_->TexSubImage3D(
2692 target, level, xoffset, yoffset, zoffset, width, height, depth, 2695 target, level, xoffset, yoffset, zoffset, width, height, depth,
2693 format, type, buffer->shm_id(), buffer->shm_offset() + offset, false); 2696 format, type, buffer->shm_id(), buffer->shm_offset() + offset, false);
2694 buffer->set_last_usage_token(helper_->InsertToken()); 2697 buffer->set_last_usage_token(helper_->InsertToken());
2695 CheckGLError(); 2698 CheckGLError();
2696 } 2699 }
2697 return; 2700 return;
2698 } 2701 }
2699 2702
2700 // compute the advance bytes per row for the src pixels 2703 // compute the advance bytes per row for the src pixels
2701 uint32 src_padded_row_size; 2704 uint32_t src_padded_row_size;
2702 if (unpack_row_length_ > 0) { 2705 if (unpack_row_length_ > 0) {
2703 if (!GLES2Util::ComputeImagePaddedRowSize( 2706 if (!GLES2Util::ComputeImagePaddedRowSize(
2704 unpack_row_length_, format, type, unpack_alignment_, 2707 unpack_row_length_, format, type, unpack_alignment_,
2705 &src_padded_row_size)) { 2708 &src_padded_row_size)) {
2706 SetGLError( 2709 SetGLError(
2707 GL_INVALID_VALUE, "glTexImage3D", "unpack row length too large"); 2710 GL_INVALID_VALUE, "glTexImage3D", "unpack row length too large");
2708 return; 2711 return;
2709 } 2712 }
2710 } else { 2713 } else {
2711 src_padded_row_size = padded_row_size; 2714 src_padded_row_size = padded_row_size;
2712 } 2715 }
2713 uint32 src_height = unpack_image_height_ > 0 ? unpack_image_height_ : height; 2716 uint32_t src_height =
2717 unpack_image_height_ > 0 ? unpack_image_height_ : height;
2714 2718
2715 // advance pixels pointer past the skip images/rows/pixels 2719 // advance pixels pointer past the skip images/rows/pixels
2716 pixels = reinterpret_cast<const int8*>(pixels) + 2720 pixels = reinterpret_cast<const int8_t*>(pixels) +
2717 unpack_skip_images_ * src_padded_row_size * src_height + 2721 unpack_skip_images_ * src_padded_row_size * src_height +
2718 unpack_skip_rows_ * src_padded_row_size; 2722 unpack_skip_rows_ * src_padded_row_size;
2719 if (unpack_skip_pixels_) { 2723 if (unpack_skip_pixels_) {
2720 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type); 2724 uint32_t group_size = GLES2Util::ComputeImageGroupSize(format, type);
2721 pixels = reinterpret_cast<const int8*>(pixels) + 2725 pixels = reinterpret_cast<const int8_t*>(pixels) +
2722 unpack_skip_pixels_ * group_size; 2726 unpack_skip_pixels_ * group_size;
2723 } 2727 }
2724 2728
2725 ScopedTransferBufferPtr buffer(temp_size, helper_, transfer_buffer_); 2729 ScopedTransferBufferPtr buffer(temp_size, helper_, transfer_buffer_);
2726 TexSubImage3DImpl( 2730 TexSubImage3DImpl(
2727 target, level, xoffset, yoffset, zoffset, width, height, depth, 2731 target, level, xoffset, yoffset, zoffset, width, height, depth,
2728 format, type, unpadded_row_size, pixels, src_padded_row_size, GL_FALSE, 2732 format, type, unpadded_row_size, pixels, src_padded_row_size, GL_FALSE,
2729 &buffer, padded_row_size); 2733 &buffer, padded_row_size);
2730 CheckGLError(); 2734 CheckGLError();
2731 } 2735 }
2732 2736
2733 static GLint ComputeNumRowsThatFitInBuffer( 2737 static GLint ComputeNumRowsThatFitInBuffer(uint32_t padded_row_size,
2734 uint32 padded_row_size, uint32 unpadded_row_size, 2738 uint32_t unpadded_row_size,
2735 unsigned int size, GLsizei remaining_rows) { 2739 unsigned int size,
2740 GLsizei remaining_rows) {
2736 DCHECK_GE(unpadded_row_size, 0u); 2741 DCHECK_GE(unpadded_row_size, 0u);
2737 if (padded_row_size == 0) { 2742 if (padded_row_size == 0) {
2738 return 1; 2743 return 1;
2739 } 2744 }
2740 GLint num_rows = size / padded_row_size; 2745 GLint num_rows = size / padded_row_size;
2741 if (num_rows + 1 == remaining_rows && 2746 if (num_rows + 1 == remaining_rows &&
2742 size - num_rows * padded_row_size >= unpadded_row_size) { 2747 size - num_rows * padded_row_size >= unpadded_row_size) {
2743 num_rows++; 2748 num_rows++;
2744 } 2749 }
2745 return num_rows; 2750 return num_rows;
2746 } 2751 }
2747 2752
2748 void GLES2Implementation::TexSubImage2DImpl( 2753 void GLES2Implementation::TexSubImage2DImpl(GLenum target,
2749 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, 2754 GLint level,
2750 GLsizei height, GLenum format, GLenum type, uint32 unpadded_row_size, 2755 GLint xoffset,
2751 const void* pixels, uint32 pixels_padded_row_size, GLboolean internal, 2756 GLint yoffset,
2752 ScopedTransferBufferPtr* buffer, uint32 buffer_padded_row_size) { 2757 GLsizei width,
2758 GLsizei height,
2759 GLenum format,
2760 GLenum type,
2761 uint32_t unpadded_row_size,
2762 const void* pixels,
2763 uint32_t pixels_padded_row_size,
2764 GLboolean internal,
2765 ScopedTransferBufferPtr* buffer,
2766 uint32_t buffer_padded_row_size) {
2753 DCHECK(buffer); 2767 DCHECK(buffer);
2754 DCHECK_GE(level, 0); 2768 DCHECK_GE(level, 0);
2755 DCHECK_GT(height, 0); 2769 DCHECK_GT(height, 0);
2756 DCHECK_GT(width, 0); 2770 DCHECK_GT(width, 0);
2757 2771
2758 const int8* source = reinterpret_cast<const int8*>(pixels); 2772 const int8_t* source = reinterpret_cast<const int8_t*>(pixels);
2759 // Transfer by rows. 2773 // Transfer by rows.
2760 while (height) { 2774 while (height) {
2761 unsigned int desired_size = 2775 unsigned int desired_size =
2762 buffer_padded_row_size * (height - 1) + unpadded_row_size; 2776 buffer_padded_row_size * (height - 1) + unpadded_row_size;
2763 if (!buffer->valid() || buffer->size() == 0) { 2777 if (!buffer->valid() || buffer->size() == 0) {
2764 buffer->Reset(desired_size); 2778 buffer->Reset(desired_size);
2765 if (!buffer->valid()) { 2779 if (!buffer->valid()) {
2766 return; 2780 return;
2767 } 2781 }
2768 } 2782 }
2769 2783
2770 GLint num_rows = ComputeNumRowsThatFitInBuffer( 2784 GLint num_rows = ComputeNumRowsThatFitInBuffer(
2771 buffer_padded_row_size, unpadded_row_size, buffer->size(), height); 2785 buffer_padded_row_size, unpadded_row_size, buffer->size(), height);
2772 num_rows = std::min(num_rows, height); 2786 num_rows = std::min(num_rows, height);
2773 CopyRectToBuffer( 2787 CopyRectToBuffer(
2774 source, num_rows, unpadded_row_size, pixels_padded_row_size, 2788 source, num_rows, unpadded_row_size, pixels_padded_row_size,
2775 buffer->address(), buffer_padded_row_size); 2789 buffer->address(), buffer_padded_row_size);
2776 helper_->TexSubImage2D( 2790 helper_->TexSubImage2D(
2777 target, level, xoffset, yoffset, width, num_rows, format, type, 2791 target, level, xoffset, yoffset, width, num_rows, format, type,
2778 buffer->shm_id(), buffer->offset(), internal); 2792 buffer->shm_id(), buffer->offset(), internal);
2779 buffer->Release(); 2793 buffer->Release();
2780 yoffset += num_rows; 2794 yoffset += num_rows;
2781 source += num_rows * pixels_padded_row_size; 2795 source += num_rows * pixels_padded_row_size;
2782 height -= num_rows; 2796 height -= num_rows;
2783 } 2797 }
2784 } 2798 }
2785 2799
2786 void GLES2Implementation::TexSubImage3DImpl( 2800 void GLES2Implementation::TexSubImage3DImpl(GLenum target,
2787 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei zoffset, 2801 GLint level,
2788 GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, 2802 GLint xoffset,
2789 uint32 unpadded_row_size, const void* pixels, uint32 pixels_padded_row_size, 2803 GLint yoffset,
2790 GLboolean internal, ScopedTransferBufferPtr* buffer, 2804 GLsizei zoffset,
2791 uint32 buffer_padded_row_size) { 2805 GLsizei width,
2806 GLsizei height,
2807 GLsizei depth,
2808 GLenum format,
2809 GLenum type,
2810 uint32_t unpadded_row_size,
2811 const void* pixels,
2812 uint32_t pixels_padded_row_size,
2813 GLboolean internal,
2814 ScopedTransferBufferPtr* buffer,
2815 uint32_t buffer_padded_row_size) {
2792 DCHECK(buffer); 2816 DCHECK(buffer);
2793 DCHECK_GE(level, 0); 2817 DCHECK_GE(level, 0);
2794 DCHECK_GT(height, 0); 2818 DCHECK_GT(height, 0);
2795 DCHECK_GT(width, 0); 2819 DCHECK_GT(width, 0);
2796 DCHECK_GT(depth, 0); 2820 DCHECK_GT(depth, 0);
2797 const int8* source = reinterpret_cast<const int8*>(pixels); 2821 const int8_t* source = reinterpret_cast<const int8_t*>(pixels);
2798 GLsizei total_rows = height * depth; 2822 GLsizei total_rows = height * depth;
2799 GLint row_index = 0, depth_index = 0; 2823 GLint row_index = 0, depth_index = 0;
2800 while (total_rows) { 2824 while (total_rows) {
2801 // Each time, we either copy one or more images, or copy one or more rows 2825 // Each time, we either copy one or more images, or copy one or more rows
2802 // within a single image, depending on the buffer size limit. 2826 // within a single image, depending on the buffer size limit.
2803 GLsizei max_rows; 2827 GLsizei max_rows;
2804 unsigned int desired_size; 2828 unsigned int desired_size;
2805 if (row_index > 0) { 2829 if (row_index > 0) {
2806 // We are in the middle of an image. Send the remaining of the image. 2830 // We are in the middle of an image. Send the remaining of the image.
2807 max_rows = height - row_index; 2831 max_rows = height - row_index;
(...skipping 24 matching lines...) Expand all
2832 if (num_images > 0) { 2856 if (num_images > 0) {
2833 num_rows = num_images * height; 2857 num_rows = num_images * height;
2834 my_height = height; 2858 my_height = height;
2835 my_depth = num_images; 2859 my_depth = num_images;
2836 } else { 2860 } else {
2837 my_height = num_rows; 2861 my_height = num_rows;
2838 my_depth = 1; 2862 my_depth = 1;
2839 } 2863 }
2840 2864
2841 if (num_images > 0) { 2865 if (num_images > 0) {
2842 int8* buffer_pointer = reinterpret_cast<int8*>(buffer->address()); 2866 int8_t* buffer_pointer = reinterpret_cast<int8_t*>(buffer->address());
2843 uint32 src_height = 2867 uint32_t src_height =
2844 unpack_image_height_ > 0 ? unpack_image_height_ : height; 2868 unpack_image_height_ > 0 ? unpack_image_height_ : height;
2845 uint32 image_size_dst = buffer_padded_row_size * height; 2869 uint32_t image_size_dst = buffer_padded_row_size * height;
2846 uint32 image_size_src = pixels_padded_row_size * src_height; 2870 uint32_t image_size_src = pixels_padded_row_size * src_height;
2847 for (GLint ii = 0; ii < num_images; ++ii) { 2871 for (GLint ii = 0; ii < num_images; ++ii) {
2848 uint32 my_unpadded_row_size; 2872 uint32_t my_unpadded_row_size;
2849 if (total_rows == num_rows && ii + 1 == num_images) 2873 if (total_rows == num_rows && ii + 1 == num_images)
2850 my_unpadded_row_size = unpadded_row_size; 2874 my_unpadded_row_size = unpadded_row_size;
2851 else 2875 else
2852 my_unpadded_row_size = pixels_padded_row_size; 2876 my_unpadded_row_size = pixels_padded_row_size;
2853 CopyRectToBuffer( 2877 CopyRectToBuffer(
2854 source + ii * image_size_src, my_height, my_unpadded_row_size, 2878 source + ii * image_size_src, my_height, my_unpadded_row_size,
2855 pixels_padded_row_size, buffer_pointer + ii * image_size_dst, 2879 pixels_padded_row_size, buffer_pointer + ii * image_size_dst,
2856 buffer_padded_row_size); 2880 buffer_padded_row_size);
2857 } 2881 }
2858 } else { 2882 } else {
2859 uint32 my_unpadded_row_size; 2883 uint32_t my_unpadded_row_size;
2860 if (total_rows == num_rows) 2884 if (total_rows == num_rows)
2861 my_unpadded_row_size = unpadded_row_size; 2885 my_unpadded_row_size = unpadded_row_size;
2862 else 2886 else
2863 my_unpadded_row_size = pixels_padded_row_size; 2887 my_unpadded_row_size = pixels_padded_row_size;
2864 CopyRectToBuffer( 2888 CopyRectToBuffer(
2865 source, my_height, my_unpadded_row_size, pixels_padded_row_size, 2889 source, my_height, my_unpadded_row_size, pixels_padded_row_size,
2866 buffer->address(), buffer_padded_row_size); 2890 buffer->address(), buffer_padded_row_size);
2867 } 2891 }
2868 helper_->TexSubImage3D( 2892 helper_->TexSubImage3D(
2869 target, level, xoffset, yoffset + row_index, zoffset + depth_index, 2893 target, level, xoffset, yoffset + row_index, zoffset + depth_index,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 GetResultShmId(), GetResultShmOffset()); 2935 GetResultShmId(), GetResultShmOffset());
2912 WaitForCmd(); 2936 WaitForCmd();
2913 if (result->success) { 2937 if (result->success) {
2914 if (size) { 2938 if (size) {
2915 *size = result->size; 2939 *size = result->size;
2916 } 2940 }
2917 if (type) { 2941 if (type) {
2918 *type = result->type; 2942 *type = result->type;
2919 } 2943 }
2920 if (length || name) { 2944 if (length || name) {
2921 std::vector<int8> str; 2945 std::vector<int8_t> str;
2922 GetBucketContents(kResultBucketId, &str); 2946 GetBucketContents(kResultBucketId, &str);
2923 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1, 2947 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1,
2924 std::max(static_cast<size_t>(0), 2948 std::max(static_cast<size_t>(0),
2925 str.size() - 1)); 2949 str.size() - 1));
2926 if (length) { 2950 if (length) {
2927 *length = max_size; 2951 *length = max_size;
2928 } 2952 }
2929 if (name && bufsize > 0) { 2953 if (name && bufsize > 0) {
2930 memcpy(name, &str[0], max_size); 2954 memcpy(name, &str[0], max_size);
2931 name[max_size] = '\0'; 2955 name[max_size] = '\0';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 GetResultShmId(), GetResultShmOffset()); 3006 GetResultShmId(), GetResultShmOffset());
2983 WaitForCmd(); 3007 WaitForCmd();
2984 if (result->success) { 3008 if (result->success) {
2985 if (size) { 3009 if (size) {
2986 *size = result->size; 3010 *size = result->size;
2987 } 3011 }
2988 if (type) { 3012 if (type) {
2989 *type = result->type; 3013 *type = result->type;
2990 } 3014 }
2991 if (length || name) { 3015 if (length || name) {
2992 std::vector<int8> str; 3016 std::vector<int8_t> str;
2993 GetBucketContents(kResultBucketId, &str); 3017 GetBucketContents(kResultBucketId, &str);
2994 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1, 3018 GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1,
2995 std::max(static_cast<size_t>(0), 3019 std::max(static_cast<size_t>(0),
2996 str.size() - 1)); 3020 str.size() - 1));
2997 if (length) { 3021 if (length) {
2998 *length = max_size; 3022 *length = max_size;
2999 } 3023 }
3000 if (name && bufsize > 0) { 3024 if (name && bufsize > 0) {
3001 memcpy(name, &str[0], max_size); 3025 memcpy(name, &str[0], max_size);
3002 name[max_size] = '\0'; 3026 name[max_size] = '\0';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 *result = 0; 3076 *result = 0;
3053 helper_->GetActiveUniformBlockName(program, index, kResultBucketId, 3077 helper_->GetActiveUniformBlockName(program, index, kResultBucketId,
3054 GetResultShmId(), GetResultShmOffset()); 3078 GetResultShmId(), GetResultShmOffset());
3055 WaitForCmd(); 3079 WaitForCmd();
3056 if (*result) { 3080 if (*result) {
3057 if (bufsize == 0) { 3081 if (bufsize == 0) {
3058 if (length) { 3082 if (length) {
3059 *length = 0; 3083 *length = 0;
3060 } 3084 }
3061 } else if (length || name) { 3085 } else if (length || name) {
3062 std::vector<int8> str; 3086 std::vector<int8_t> str;
3063 GetBucketContents(kResultBucketId, &str); 3087 GetBucketContents(kResultBucketId, &str);
3064 DCHECK_GT(str.size(), 0u); 3088 DCHECK_GT(str.size(), 0u);
3065 GLsizei max_size = 3089 GLsizei max_size =
3066 std::min(bufsize, static_cast<GLsizei>(str.size())) - 1; 3090 std::min(bufsize, static_cast<GLsizei>(str.size())) - 1;
3067 if (length) { 3091 if (length) {
3068 *length = max_size; 3092 *length = max_size;
3069 } 3093 }
3070 if (name) { 3094 if (name) {
3071 memcpy(name, &str[0], max_size); 3095 memcpy(name, &str[0], max_size);
3072 name[max_size] = '\0'; 3096 name[max_size] = '\0';
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3214 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" 3238 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders("
3215 << program << ", " << maxcount << ", " 3239 << program << ", " << maxcount << ", "
3216 << static_cast<const void*>(count) << ", " 3240 << static_cast<const void*>(count) << ", "
3217 << static_cast<const void*>(shaders) << ", "); 3241 << static_cast<const void*>(shaders) << ", ");
3218 if (maxcount < 0) { 3242 if (maxcount < 0) {
3219 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); 3243 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0");
3220 return; 3244 return;
3221 } 3245 }
3222 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders"); 3246 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders");
3223 typedef cmds::GetAttachedShaders::Result Result; 3247 typedef cmds::GetAttachedShaders::Result Result;
3224 uint32 size = Result::ComputeSize(maxcount); 3248 uint32_t size = Result::ComputeSize(maxcount);
3225 Result* result = static_cast<Result*>(transfer_buffer_->Alloc(size)); 3249 Result* result = static_cast<Result*>(transfer_buffer_->Alloc(size));
3226 if (!result) { 3250 if (!result) {
3227 return; 3251 return;
3228 } 3252 }
3229 result->SetNumResults(0); 3253 result->SetNumResults(0);
3230 helper_->GetAttachedShaders( 3254 helper_->GetAttachedShaders(
3231 program, 3255 program,
3232 transfer_buffer_->GetShmId(), 3256 transfer_buffer_->GetShmId(),
3233 transfer_buffer_->GetOffset(result), 3257 transfer_buffer_->GetOffset(result),
3234 size); 3258 size);
3235 int32 token = helper_->InsertToken(); 3259 int32_t token = helper_->InsertToken();
3236 WaitForCmd(); 3260 WaitForCmd();
3237 if (count) { 3261 if (count) {
3238 *count = result->GetNumResults(); 3262 *count = result->GetNumResults();
3239 } 3263 }
3240 result->CopyResult(shaders); 3264 result->CopyResult(shaders);
3241 GPU_CLIENT_LOG_CODE_BLOCK({ 3265 GPU_CLIENT_LOG_CODE_BLOCK({
3242 for (int32 i = 0; i < result->GetNumResults(); ++i) { 3266 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
3243 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 3267 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
3244 } 3268 }
3245 }); 3269 });
3246 transfer_buffer_->FreePendingToken(result, token); 3270 transfer_buffer_->FreePendingToken(result, token);
3247 CheckGLError(); 3271 CheckGLError();
3248 } 3272 }
3249 3273
3250 void GLES2Implementation::GetShaderPrecisionFormat( 3274 void GLES2Implementation::GetShaderPrecisionFormat(
3251 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { 3275 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
3252 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3276 GPU_CLIENT_SINGLE_THREAD_CHECK();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 program, index, kResultBucketId, GetResultShmId(), GetResultShmOffset()); 3389 program, index, kResultBucketId, GetResultShmId(), GetResultShmOffset());
3366 WaitForCmd(); 3390 WaitForCmd();
3367 if (result->success) { 3391 if (result->success) {
3368 if (size) { 3392 if (size) {
3369 *size = result->size; 3393 *size = result->size;
3370 } 3394 }
3371 if (type) { 3395 if (type) {
3372 *type = result->type; 3396 *type = result->type;
3373 } 3397 }
3374 if (length || name) { 3398 if (length || name) {
3375 std::vector<int8> str; 3399 std::vector<int8_t> str;
3376 GetBucketContents(kResultBucketId, &str); 3400 GetBucketContents(kResultBucketId, &str);
3377 GLsizei max_size = std::min(bufsize, static_cast<GLsizei>(str.size())); 3401 GLsizei max_size = std::min(bufsize, static_cast<GLsizei>(str.size()));
3378 if (max_size > 0) { 3402 if (max_size > 0) {
3379 --max_size; 3403 --max_size;
3380 } 3404 }
3381 if (length) { 3405 if (length) {
3382 *length = max_size; 3406 *length = max_size;
3383 } 3407 }
3384 if (name) { 3408 if (name) {
3385 if (max_size > 0) { 3409 if (max_size > 0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3438 Result* result = GetResultAs<Result*>(); 3462 Result* result = GetResultAs<Result*>();
3439 if (!result) { 3463 if (!result) {
3440 return; 3464 return;
3441 } 3465 }
3442 result->SetNumResults(0); 3466 result->SetNumResults(0);
3443 helper_->GetUniformfv( 3467 helper_->GetUniformfv(
3444 program, location, GetResultShmId(), GetResultShmOffset()); 3468 program, location, GetResultShmId(), GetResultShmOffset());
3445 WaitForCmd(); 3469 WaitForCmd();
3446 result->CopyResult(params); 3470 result->CopyResult(params);
3447 GPU_CLIENT_LOG_CODE_BLOCK({ 3471 GPU_CLIENT_LOG_CODE_BLOCK({
3448 for (int32 i = 0; i < result->GetNumResults(); ++i) { 3472 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
3449 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 3473 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
3450 } 3474 }
3451 }); 3475 });
3452 CheckGLError(); 3476 CheckGLError();
3453 } 3477 }
3454 3478
3455 void GLES2Implementation::GetUniformiv( 3479 void GLES2Implementation::GetUniformiv(
3456 GLuint program, GLint location, GLint* params) { 3480 GLuint program, GLint location, GLint* params) {
3457 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3481 GPU_CLIENT_SINGLE_THREAD_CHECK();
3458 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformiv(" 3482 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformiv("
3459 << program << ", " << location << ", " 3483 << program << ", " << location << ", "
3460 << static_cast<const void*>(params) << ")"); 3484 << static_cast<const void*>(params) << ")");
3461 TRACE_EVENT0("gpu", "GLES2::GetUniformiv"); 3485 TRACE_EVENT0("gpu", "GLES2::GetUniformiv");
3462 typedef cmds::GetUniformiv::Result Result; 3486 typedef cmds::GetUniformiv::Result Result;
3463 Result* result = GetResultAs<Result*>(); 3487 Result* result = GetResultAs<Result*>();
3464 if (!result) { 3488 if (!result) {
3465 return; 3489 return;
3466 } 3490 }
3467 result->SetNumResults(0); 3491 result->SetNumResults(0);
3468 helper_->GetUniformiv( 3492 helper_->GetUniformiv(
3469 program, location, GetResultShmId(), GetResultShmOffset()); 3493 program, location, GetResultShmId(), GetResultShmOffset());
3470 WaitForCmd(); 3494 WaitForCmd();
3471 GetResultAs<cmds::GetUniformiv::Result*>()->CopyResult(params); 3495 GetResultAs<cmds::GetUniformiv::Result*>()->CopyResult(params);
3472 GPU_CLIENT_LOG_CODE_BLOCK({ 3496 GPU_CLIENT_LOG_CODE_BLOCK({
3473 for (int32 i = 0; i < result->GetNumResults(); ++i) { 3497 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
3474 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 3498 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
3475 } 3499 }
3476 }); 3500 });
3477 CheckGLError(); 3501 CheckGLError();
3478 } 3502 }
3479 3503
3480 void GLES2Implementation::GetUniformuiv( 3504 void GLES2Implementation::GetUniformuiv(
3481 GLuint program, GLint location, GLuint* params) { 3505 GLuint program, GLint location, GLuint* params) {
3482 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3506 GPU_CLIENT_SINGLE_THREAD_CHECK();
3483 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformuiv(" 3507 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformuiv("
3484 << program << ", " << location << ", " 3508 << program << ", " << location << ", "
3485 << static_cast<const void*>(params) << ")"); 3509 << static_cast<const void*>(params) << ")");
3486 TRACE_EVENT0("gpu", "GLES2::GetUniformuiv"); 3510 TRACE_EVENT0("gpu", "GLES2::GetUniformuiv");
3487 typedef cmds::GetUniformuiv::Result Result; 3511 typedef cmds::GetUniformuiv::Result Result;
3488 Result* result = GetResultAs<Result*>(); 3512 Result* result = GetResultAs<Result*>();
3489 if (!result) { 3513 if (!result) {
3490 return; 3514 return;
3491 } 3515 }
3492 result->SetNumResults(0); 3516 result->SetNumResults(0);
3493 helper_->GetUniformuiv( 3517 helper_->GetUniformuiv(
3494 program, location, GetResultShmId(), GetResultShmOffset()); 3518 program, location, GetResultShmId(), GetResultShmOffset());
3495 WaitForCmd(); 3519 WaitForCmd();
3496 GetResultAs<cmds::GetUniformuiv::Result*>()->CopyResult(params); 3520 GetResultAs<cmds::GetUniformuiv::Result*>()->CopyResult(params);
3497 GPU_CLIENT_LOG_CODE_BLOCK({ 3521 GPU_CLIENT_LOG_CODE_BLOCK({
3498 for (int32 i = 0; i < result->GetNumResults(); ++i) { 3522 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
3499 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 3523 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
3500 } 3524 }
3501 }); 3525 });
3502 CheckGLError(); 3526 CheckGLError();
3503 } 3527 }
3504 3528
3505 void GLES2Implementation::ReadPixels( 3529 void GLES2Implementation::ReadPixels(
3506 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, 3530 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
3507 GLenum type, void* pixels) { 3531 GLenum type, void* pixels) {
3508 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3532 GPU_CLIENT_SINGLE_THREAD_CHECK();
(...skipping 13 matching lines...) Expand all
3522 3546
3523 // glReadPixel pads the size of each row of pixels by an amount specified by 3547 // glReadPixel pads the size of each row of pixels by an amount specified by
3524 // glPixelStorei. So, we have to take that into account both in the fact that 3548 // glPixelStorei. So, we have to take that into account both in the fact that
3525 // the pixels returned from the ReadPixel command will include that padding 3549 // the pixels returned from the ReadPixel command will include that padding
3526 // and that when we copy the results to the user's buffer we need to not 3550 // and that when we copy the results to the user's buffer we need to not
3527 // write those padding bytes but leave them as they are. 3551 // write those padding bytes but leave them as they are.
3528 3552
3529 TRACE_EVENT0("gpu", "GLES2::ReadPixels"); 3553 TRACE_EVENT0("gpu", "GLES2::ReadPixels");
3530 typedef cmds::ReadPixels::Result Result; 3554 typedef cmds::ReadPixels::Result Result;
3531 3555
3532 int8* dest = reinterpret_cast<int8*>(pixels); 3556 int8_t* dest = reinterpret_cast<int8_t*>(pixels);
3533 uint32 temp_size; 3557 uint32_t temp_size;
3534 uint32 unpadded_row_size; 3558 uint32_t unpadded_row_size;
3535 uint32 padded_row_size; 3559 uint32_t padded_row_size;
3536 if (!GLES2Util::ComputeImageDataSizes( 3560 if (!GLES2Util::ComputeImageDataSizes(
3537 width, 2, 1, format, type, pack_alignment_, &temp_size, 3561 width, 2, 1, format, type, pack_alignment_, &temp_size,
3538 &unpadded_row_size, &padded_row_size)) { 3562 &unpadded_row_size, &padded_row_size)) {
3539 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large."); 3563 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large.");
3540 return; 3564 return;
3541 } 3565 }
3542 3566
3543 if (bound_pixel_pack_buffer_) { 3567 if (bound_pixel_pack_buffer_) {
3544 GLuint offset = ToGLuint(pixels); 3568 GLuint offset = ToGLuint(pixels);
3545 helper_->ReadPixels( 3569 helper_->ReadPixels(
(...skipping 15 matching lines...) Expand all
3561 } 3585 }
3562 return; 3586 return;
3563 } 3587 }
3564 3588
3565 if (!pixels) { 3589 if (!pixels) {
3566 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL"); 3590 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL");
3567 return; 3591 return;
3568 } 3592 }
3569 3593
3570 // compute the advance bytes per row for the dst pixels 3594 // compute the advance bytes per row for the dst pixels
3571 uint32 dst_padded_row_size; 3595 uint32_t dst_padded_row_size;
3572 if (pack_row_length_ > 0) { 3596 if (pack_row_length_ > 0) {
3573 if (!GLES2Util::ComputeImagePaddedRowSize( 3597 if (!GLES2Util::ComputeImagePaddedRowSize(
3574 pack_row_length_, format, type, pack_alignment_, 3598 pack_row_length_, format, type, pack_alignment_,
3575 &dst_padded_row_size)) { 3599 &dst_padded_row_size)) {
3576 SetGLError( 3600 SetGLError(
3577 GL_INVALID_VALUE, "glReadPixels", "pack row length too large"); 3601 GL_INVALID_VALUE, "glReadPixels", "pack row length too large");
3578 return; 3602 return;
3579 } 3603 }
3580 } else { 3604 } else {
3581 dst_padded_row_size = padded_row_size; 3605 dst_padded_row_size = padded_row_size;
3582 } 3606 }
3583 3607
3584 // Advance pixels pointer past the skip rows and skip pixels 3608 // Advance pixels pointer past the skip rows and skip pixels
3585 dest += pack_skip_rows_ * dst_padded_row_size; 3609 dest += pack_skip_rows_ * dst_padded_row_size;
3586 if (pack_skip_pixels_) { 3610 if (pack_skip_pixels_) {
3587 uint32 group_size = GLES2Util::ComputeImageGroupSize(format, type); 3611 uint32_t group_size = GLES2Util::ComputeImageGroupSize(format, type);
3588 dest += pack_skip_pixels_ * group_size; 3612 dest += pack_skip_pixels_ * group_size;
3589 } 3613 }
3590 3614
3591 // Transfer by rows. 3615 // Transfer by rows.
3592 // The max rows we can transfer. 3616 // The max rows we can transfer.
3593 while (height) { 3617 while (height) {
3594 GLsizei desired_size = padded_row_size * (height - 1) + unpadded_row_size; 3618 GLsizei desired_size = padded_row_size * (height - 1) + unpadded_row_size;
3595 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_); 3619 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_);
3596 if (!buffer.valid()) { 3620 if (!buffer.valid()) {
3597 return; 3621 return;
(...skipping 11 matching lines...) Expand all
3609 helper_->ReadPixels( 3633 helper_->ReadPixels(
3610 xoffset, yoffset, width, num_rows, format, type, 3634 xoffset, yoffset, width, num_rows, format, type,
3611 buffer.shm_id(), buffer.offset(), 3635 buffer.shm_id(), buffer.offset(),
3612 GetResultShmId(), GetResultShmOffset(), 3636 GetResultShmId(), GetResultShmOffset(),
3613 false); 3637 false);
3614 WaitForCmd(); 3638 WaitForCmd();
3615 if (*result != 0) { 3639 if (*result != 0) {
3616 // when doing a y-flip we have to iterate through top-to-bottom chunks 3640 // when doing a y-flip we have to iterate through top-to-bottom chunks
3617 // of the dst. The service side handles reversing the rows within a 3641 // of the dst. The service side handles reversing the rows within a
3618 // chunk. 3642 // chunk.
3619 int8* rows_dst; 3643 int8_t* rows_dst;
3620 if (pack_reverse_row_order_) { 3644 if (pack_reverse_row_order_) {
3621 rows_dst = dest + (height - num_rows) * dst_padded_row_size; 3645 rows_dst = dest + (height - num_rows) * dst_padded_row_size;
3622 } else { 3646 } else {
3623 rows_dst = dest; 3647 rows_dst = dest;
3624 } 3648 }
3625 // We have to copy 1 row at a time to avoid writing pad bytes. 3649 // We have to copy 1 row at a time to avoid writing pad bytes.
3626 const int8* src = static_cast<const int8*>(buffer.address()); 3650 const int8_t* src = static_cast<const int8_t*>(buffer.address());
3627 for (GLint yy = 0; yy < num_rows; ++yy) { 3651 for (GLint yy = 0; yy < num_rows; ++yy) {
3628 memcpy(rows_dst, src, unpadded_row_size); 3652 memcpy(rows_dst, src, unpadded_row_size);
3629 rows_dst += dst_padded_row_size; 3653 rows_dst += dst_padded_row_size;
3630 src += padded_row_size; 3654 src += padded_row_size;
3631 } 3655 }
3632 if (!pack_reverse_row_order_) { 3656 if (!pack_reverse_row_order_) {
3633 dest = rows_dst; 3657 dest = rows_dst;
3634 } 3658 }
3635 } 3659 }
3636 // If it was not marked as successful exit. 3660 // If it was not marked as successful exit.
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
4242 CheckGLError(); 4266 CheckGLError();
4243 } 4267 }
4244 4268
4245 void GLES2Implementation::GetVertexAttribfv( 4269 void GLES2Implementation::GetVertexAttribfv(
4246 GLuint index, GLenum pname, GLfloat* params) { 4270 GLuint index, GLenum pname, GLfloat* params) {
4247 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4271 GPU_CLIENT_SINGLE_THREAD_CHECK();
4248 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribfv(" 4272 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribfv("
4249 << index << ", " 4273 << index << ", "
4250 << GLES2Util::GetStringVertexAttribute(pname) << ", " 4274 << GLES2Util::GetStringVertexAttribute(pname) << ", "
4251 << static_cast<const void*>(params) << ")"); 4275 << static_cast<const void*>(params) << ")");
4252 uint32 value = 0; 4276 uint32_t value = 0;
4253 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) { 4277 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) {
4254 *params = static_cast<GLfloat>(value); 4278 *params = static_cast<GLfloat>(value);
4255 return; 4279 return;
4256 } 4280 }
4257 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv"); 4281 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv");
4258 typedef cmds::GetVertexAttribfv::Result Result; 4282 typedef cmds::GetVertexAttribfv::Result Result;
4259 Result* result = GetResultAs<Result*>(); 4283 Result* result = GetResultAs<Result*>();
4260 if (!result) { 4284 if (!result) {
4261 return; 4285 return;
4262 } 4286 }
4263 result->SetNumResults(0); 4287 result->SetNumResults(0);
4264 helper_->GetVertexAttribfv( 4288 helper_->GetVertexAttribfv(
4265 index, pname, GetResultShmId(), GetResultShmOffset()); 4289 index, pname, GetResultShmId(), GetResultShmOffset());
4266 WaitForCmd(); 4290 WaitForCmd();
4267 result->CopyResult(params); 4291 result->CopyResult(params);
4268 GPU_CLIENT_LOG_CODE_BLOCK({ 4292 GPU_CLIENT_LOG_CODE_BLOCK({
4269 for (int32 i = 0; i < result->GetNumResults(); ++i) { 4293 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
4270 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 4294 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
4271 } 4295 }
4272 }); 4296 });
4273 CheckGLError(); 4297 CheckGLError();
4274 } 4298 }
4275 4299
4276 void GLES2Implementation::GetVertexAttribiv( 4300 void GLES2Implementation::GetVertexAttribiv(
4277 GLuint index, GLenum pname, GLint* params) { 4301 GLuint index, GLenum pname, GLint* params) {
4278 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4302 GPU_CLIENT_SINGLE_THREAD_CHECK();
4279 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribiv(" 4303 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribiv("
4280 << index << ", " 4304 << index << ", "
4281 << GLES2Util::GetStringVertexAttribute(pname) << ", " 4305 << GLES2Util::GetStringVertexAttribute(pname) << ", "
4282 << static_cast<const void*>(params) << ")"); 4306 << static_cast<const void*>(params) << ")");
4283 uint32 value = 0; 4307 uint32_t value = 0;
4284 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) { 4308 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) {
4285 *params = static_cast<GLint>(value); 4309 *params = static_cast<GLint>(value);
4286 return; 4310 return;
4287 } 4311 }
4288 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv"); 4312 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv");
4289 typedef cmds::GetVertexAttribiv::Result Result; 4313 typedef cmds::GetVertexAttribiv::Result Result;
4290 Result* result = GetResultAs<Result*>(); 4314 Result* result = GetResultAs<Result*>();
4291 if (!result) { 4315 if (!result) {
4292 return; 4316 return;
4293 } 4317 }
4294 result->SetNumResults(0); 4318 result->SetNumResults(0);
4295 helper_->GetVertexAttribiv( 4319 helper_->GetVertexAttribiv(
4296 index, pname, GetResultShmId(), GetResultShmOffset()); 4320 index, pname, GetResultShmId(), GetResultShmOffset());
4297 WaitForCmd(); 4321 WaitForCmd();
4298 result->CopyResult(params); 4322 result->CopyResult(params);
4299 GPU_CLIENT_LOG_CODE_BLOCK({ 4323 GPU_CLIENT_LOG_CODE_BLOCK({
4300 for (int32 i = 0; i < result->GetNumResults(); ++i) { 4324 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
4301 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 4325 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
4302 } 4326 }
4303 }); 4327 });
4304 CheckGLError(); 4328 CheckGLError();
4305 } 4329 }
4306 4330
4307 void GLES2Implementation::GetVertexAttribIiv( 4331 void GLES2Implementation::GetVertexAttribIiv(
4308 GLuint index, GLenum pname, GLint* params) { 4332 GLuint index, GLenum pname, GLint* params) {
4309 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4333 GPU_CLIENT_SINGLE_THREAD_CHECK();
4310 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribIiv(" 4334 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribIiv("
4311 << index << ", " 4335 << index << ", "
4312 << GLES2Util::GetStringVertexAttribute(pname) << ", " 4336 << GLES2Util::GetStringVertexAttribute(pname) << ", "
4313 << static_cast<const void*>(params) << ")"); 4337 << static_cast<const void*>(params) << ")");
4314 uint32 value = 0; 4338 uint32_t value = 0;
4315 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) { 4339 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) {
4316 *params = static_cast<GLint>(value); 4340 *params = static_cast<GLint>(value);
4317 return; 4341 return;
4318 } 4342 }
4319 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIiv"); 4343 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIiv");
4320 typedef cmds::GetVertexAttribiv::Result Result; 4344 typedef cmds::GetVertexAttribiv::Result Result;
4321 Result* result = GetResultAs<Result*>(); 4345 Result* result = GetResultAs<Result*>();
4322 if (!result) { 4346 if (!result) {
4323 return; 4347 return;
4324 } 4348 }
4325 result->SetNumResults(0); 4349 result->SetNumResults(0);
4326 helper_->GetVertexAttribIiv( 4350 helper_->GetVertexAttribIiv(
4327 index, pname, GetResultShmId(), GetResultShmOffset()); 4351 index, pname, GetResultShmId(), GetResultShmOffset());
4328 WaitForCmd(); 4352 WaitForCmd();
4329 result->CopyResult(params); 4353 result->CopyResult(params);
4330 GPU_CLIENT_LOG_CODE_BLOCK({ 4354 GPU_CLIENT_LOG_CODE_BLOCK({
4331 for (int32 i = 0; i < result->GetNumResults(); ++i) { 4355 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
4332 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 4356 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
4333 } 4357 }
4334 }); 4358 });
4335 CheckGLError(); 4359 CheckGLError();
4336 } 4360 }
4337 4361
4338 void GLES2Implementation::GetVertexAttribIuiv( 4362 void GLES2Implementation::GetVertexAttribIuiv(
4339 GLuint index, GLenum pname, GLuint* params) { 4363 GLuint index, GLenum pname, GLuint* params) {
4340 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4364 GPU_CLIENT_SINGLE_THREAD_CHECK();
4341 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribIuiv(" 4365 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribIuiv("
4342 << index << ", " 4366 << index << ", "
4343 << GLES2Util::GetStringVertexAttribute(pname) << ", " 4367 << GLES2Util::GetStringVertexAttribute(pname) << ", "
4344 << static_cast<const void*>(params) << ")"); 4368 << static_cast<const void*>(params) << ")");
4345 uint32 value = 0; 4369 uint32_t value = 0;
4346 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) { 4370 if (vertex_array_object_manager_->GetVertexAttrib(index, pname, &value)) {
4347 *params = static_cast<GLuint>(value); 4371 *params = static_cast<GLuint>(value);
4348 return; 4372 return;
4349 } 4373 }
4350 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIuiv"); 4374 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIuiv");
4351 typedef cmds::GetVertexAttribiv::Result Result; 4375 typedef cmds::GetVertexAttribiv::Result Result;
4352 Result* result = GetResultAs<Result*>(); 4376 Result* result = GetResultAs<Result*>();
4353 if (!result) { 4377 if (!result) {
4354 return; 4378 return;
4355 } 4379 }
4356 result->SetNumResults(0); 4380 result->SetNumResults(0);
4357 helper_->GetVertexAttribIuiv( 4381 helper_->GetVertexAttribIuiv(
4358 index, pname, GetResultShmId(), GetResultShmOffset()); 4382 index, pname, GetResultShmId(), GetResultShmOffset());
4359 WaitForCmd(); 4383 WaitForCmd();
4360 result->CopyResult(params); 4384 result->CopyResult(params);
4361 GPU_CLIENT_LOG_CODE_BLOCK({ 4385 GPU_CLIENT_LOG_CODE_BLOCK({
4362 for (int32 i = 0; i < result->GetNumResults(); ++i) { 4386 for (int32_t i = 0; i < result->GetNumResults(); ++i) {
4363 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 4387 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
4364 } 4388 }
4365 }); 4389 });
4366 CheckGLError(); 4390 CheckGLError();
4367 } 4391 }
4368 4392
4369 GLenum GLES2Implementation::GetGraphicsResetStatusKHR() { 4393 GLenum GLES2Implementation::GetGraphicsResetStatusKHR() {
4370 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4394 GPU_CLIENT_SINGLE_THREAD_CHECK();
4371 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetGraphicsResetStatusKHR()"); 4395 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetGraphicsResetStatusKHR()");
4372 // If we can't make command buffers then the context is lost. 4396 // If we can't make command buffers then the context is lost.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
4509 if (access != GL_WRITE_ONLY) { 4533 if (access != GL_WRITE_ONLY) {
4510 SetGLErrorInvalidEnum( 4534 SetGLErrorInvalidEnum(
4511 "glMapBufferSubDataCHROMIUM", access, "access"); 4535 "glMapBufferSubDataCHROMIUM", access, "access");
4512 return NULL; 4536 return NULL;
4513 } 4537 }
4514 if (!ValidateSize("glMapBufferSubDataCHROMIUM", size) || 4538 if (!ValidateSize("glMapBufferSubDataCHROMIUM", size) ||
4515 !ValidateOffset("glMapBufferSubDataCHROMIUM", offset)) { 4539 !ValidateOffset("glMapBufferSubDataCHROMIUM", offset)) {
4516 return NULL; 4540 return NULL;
4517 } 4541 }
4518 4542
4519 int32 shm_id; 4543 int32_t shm_id;
4520 unsigned int shm_offset; 4544 unsigned int shm_offset;
4521 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset); 4545 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
4522 if (!mem) { 4546 if (!mem) {
4523 SetGLError(GL_OUT_OF_MEMORY, "glMapBufferSubDataCHROMIUM", "out of memory"); 4547 SetGLError(GL_OUT_OF_MEMORY, "glMapBufferSubDataCHROMIUM", "out of memory");
4524 return NULL; 4548 return NULL;
4525 } 4549 }
4526 4550
4527 std::pair<MappedBufferMap::iterator, bool> result = 4551 std::pair<MappedBufferMap::iterator, bool> result =
4528 mapped_buffers_.insert(std::make_pair( 4552 mapped_buffers_.insert(std::make_pair(
4529 mem, 4553 mem,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4590 GLenum target, GLintptr offset, GLsizeiptr size, GLbitfield access) { 4614 GLenum target, GLintptr offset, GLsizeiptr size, GLbitfield access) {
4591 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4615 GPU_CLIENT_SINGLE_THREAD_CHECK();
4592 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferRange(" 4616 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferRange("
4593 << GLES2Util::GetStringEnum(target) << ", " << offset << ", " 4617 << GLES2Util::GetStringEnum(target) << ", " << offset << ", "
4594 << size << ", " << access << ")"); 4618 << size << ", " << access << ")");
4595 if (!ValidateSize("glMapBufferRange", size) || 4619 if (!ValidateSize("glMapBufferRange", size) ||
4596 !ValidateOffset("glMapBufferRange", offset)) { 4620 !ValidateOffset("glMapBufferRange", offset)) {
4597 return nullptr; 4621 return nullptr;
4598 } 4622 }
4599 4623
4600 int32 shm_id; 4624 int32_t shm_id;
4601 unsigned int shm_offset; 4625 unsigned int shm_offset;
4602 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset); 4626 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
4603 if (!mem) { 4627 if (!mem) {
4604 SetGLError(GL_OUT_OF_MEMORY, "glMapBufferRange", "out of memory"); 4628 SetGLError(GL_OUT_OF_MEMORY, "glMapBufferRange", "out of memory");
4605 return nullptr; 4629 return nullptr;
4606 } 4630 }
4607 4631
4608 typedef cmds::MapBufferRange::Result Result; 4632 typedef cmds::MapBufferRange::Result Result;
4609 Result* result = GetResultAs<Result*>(); 4633 Result* result = GetResultAs<Result*>();
4610 *result = 0; 4634 *result = 0;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4702 "glMapTexSubImage2DCHROMIUM", access, "access"); 4726 "glMapTexSubImage2DCHROMIUM", access, "access");
4703 return NULL; 4727 return NULL;
4704 } 4728 }
4705 // NOTE: target is NOT checked because the service will check it 4729 // NOTE: target is NOT checked because the service will check it
4706 // and we don't know what targets are valid. 4730 // and we don't know what targets are valid.
4707 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) { 4731 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) {
4708 SetGLError( 4732 SetGLError(
4709 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "bad dimensions"); 4733 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "bad dimensions");
4710 return NULL; 4734 return NULL;
4711 } 4735 }
4712 uint32 size; 4736 uint32_t size;
4713 if (!GLES2Util::ComputeImageDataSizes( 4737 if (!GLES2Util::ComputeImageDataSizes(
4714 width, height, 1, format, type, unpack_alignment_, &size, NULL, NULL)) { 4738 width, height, 1, format, type, unpack_alignment_, &size, NULL, NULL)) {
4715 SetGLError( 4739 SetGLError(
4716 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "image size too large"); 4740 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "image size too large");
4717 return NULL; 4741 return NULL;
4718 } 4742 }
4719 int32 shm_id; 4743 int32_t shm_id;
4720 unsigned int shm_offset; 4744 unsigned int shm_offset;
4721 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset); 4745 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
4722 if (!mem) { 4746 if (!mem) {
4723 SetGLError(GL_OUT_OF_MEMORY, "glMapTexSubImage2DCHROMIUM", "out of memory"); 4747 SetGLError(GL_OUT_OF_MEMORY, "glMapTexSubImage2DCHROMIUM", "out of memory");
4724 return NULL; 4748 return NULL;
4725 } 4749 }
4726 4750
4727 std::pair<MappedTextureMap::iterator, bool> result = 4751 std::pair<MappedTextureMap::iterator, bool> result =
4728 mapped_textures_.insert(std::make_pair( 4752 mapped_textures_.insert(std::make_pair(
4729 mem, 4753 mem,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4824 for (size_t ii = 0; ii < kNumChecks; ++ii) { 4848 for (size_t ii = 0; ii < kNumChecks; ++ii) {
4825 const ExtensionCheck& check = checks[ii]; 4849 const ExtensionCheck& check = checks[ii];
4826 if (*check.status == kUnavailableExtensionStatus && 4850 if (*check.status == kUnavailableExtensionStatus &&
4827 !strcmp(extension, check.extension)) { 4851 !strcmp(extension, check.extension)) {
4828 *check.status = kUnknownExtensionStatus; 4852 *check.status = kUnknownExtensionStatus;
4829 } 4853 }
4830 } 4854 }
4831 } 4855 }
4832 4856
4833 void GLES2Implementation::GetProgramInfoCHROMIUMHelper( 4857 void GLES2Implementation::GetProgramInfoCHROMIUMHelper(
4834 GLuint program, std::vector<int8>* result) { 4858 GLuint program,
4859 std::vector<int8_t>* result) {
4835 DCHECK(result); 4860 DCHECK(result);
4836 // Clear the bucket so if the command fails nothing will be in it. 4861 // Clear the bucket so if the command fails nothing will be in it.
4837 helper_->SetBucketSize(kResultBucketId, 0); 4862 helper_->SetBucketSize(kResultBucketId, 0);
4838 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId); 4863 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId);
4839 GetBucketContents(kResultBucketId, result); 4864 GetBucketContents(kResultBucketId, result);
4840 } 4865 }
4841 4866
4842 void GLES2Implementation::GetProgramInfoCHROMIUM( 4867 void GLES2Implementation::GetProgramInfoCHROMIUM(
4843 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { 4868 GLuint program, GLsizei bufsize, GLsizei* size, void* info) {
4844 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4869 GPU_CLIENT_SINGLE_THREAD_CHECK();
4845 if (bufsize < 0) { 4870 if (bufsize < 0) {
4846 SetGLError( 4871 SetGLError(
4847 GL_INVALID_VALUE, "glProgramInfoCHROMIUM", "bufsize less than 0."); 4872 GL_INVALID_VALUE, "glProgramInfoCHROMIUM", "bufsize less than 0.");
4848 return; 4873 return;
4849 } 4874 }
4850 if (size == NULL) { 4875 if (size == NULL) {
4851 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM", "size is null."); 4876 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM", "size is null.");
4852 return; 4877 return;
4853 } 4878 }
4854 // Make sure they've set size to 0 else the value will be undefined on 4879 // Make sure they've set size to 0 else the value will be undefined on
4855 // lost context. 4880 // lost context.
4856 DCHECK_EQ(0, *size); 4881 DCHECK_EQ(0, *size);
4857 std::vector<int8> result; 4882 std::vector<int8_t> result;
4858 GetProgramInfoCHROMIUMHelper(program, &result); 4883 GetProgramInfoCHROMIUMHelper(program, &result);
4859 if (result.empty()) { 4884 if (result.empty()) {
4860 return; 4885 return;
4861 } 4886 }
4862 *size = result.size(); 4887 *size = result.size();
4863 if (!info) { 4888 if (!info) {
4864 return; 4889 return;
4865 } 4890 }
4866 if (static_cast<size_t>(bufsize) < result.size()) { 4891 if (static_cast<size_t>(bufsize) < result.size()) {
4867 SetGLError(GL_INVALID_OPERATION, 4892 SetGLError(GL_INVALID_OPERATION,
4868 "glProgramInfoCHROMIUM", "bufsize is too small for result."); 4893 "glProgramInfoCHROMIUM", "bufsize is too small for result.");
4869 return; 4894 return;
4870 } 4895 }
4871 memcpy(info, &result[0], result.size()); 4896 memcpy(info, &result[0], result.size());
4872 } 4897 }
4873 4898
4874 void GLES2Implementation::GetUniformBlocksCHROMIUMHelper( 4899 void GLES2Implementation::GetUniformBlocksCHROMIUMHelper(
4875 GLuint program, std::vector<int8>* result) { 4900 GLuint program,
4901 std::vector<int8_t>* result) {
4876 DCHECK(result); 4902 DCHECK(result);
4877 // Clear the bucket so if the command fails nothing will be in it. 4903 // Clear the bucket so if the command fails nothing will be in it.
4878 helper_->SetBucketSize(kResultBucketId, 0); 4904 helper_->SetBucketSize(kResultBucketId, 0);
4879 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId); 4905 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId);
4880 GetBucketContents(kResultBucketId, result); 4906 GetBucketContents(kResultBucketId, result);
4881 } 4907 }
4882 4908
4883 void GLES2Implementation::GetUniformBlocksCHROMIUM( 4909 void GLES2Implementation::GetUniformBlocksCHROMIUM(
4884 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { 4910 GLuint program, GLsizei bufsize, GLsizei* size, void* info) {
4885 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4911 GPU_CLIENT_SINGLE_THREAD_CHECK();
4886 if (bufsize < 0) { 4912 if (bufsize < 0) {
4887 SetGLError( 4913 SetGLError(
4888 GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "bufsize less than 0."); 4914 GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "bufsize less than 0.");
4889 return; 4915 return;
4890 } 4916 }
4891 if (size == NULL) { 4917 if (size == NULL) {
4892 SetGLError(GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "size is null."); 4918 SetGLError(GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "size is null.");
4893 return; 4919 return;
4894 } 4920 }
4895 // Make sure they've set size to 0 else the value will be undefined on 4921 // Make sure they've set size to 0 else the value will be undefined on
4896 // lost context. 4922 // lost context.
4897 DCHECK_EQ(0, *size); 4923 DCHECK_EQ(0, *size);
4898 std::vector<int8> result; 4924 std::vector<int8_t> result;
4899 GetUniformBlocksCHROMIUMHelper(program, &result); 4925 GetUniformBlocksCHROMIUMHelper(program, &result);
4900 if (result.empty()) { 4926 if (result.empty()) {
4901 return; 4927 return;
4902 } 4928 }
4903 *size = result.size(); 4929 *size = result.size();
4904 if (!info) { 4930 if (!info) {
4905 return; 4931 return;
4906 } 4932 }
4907 if (static_cast<size_t>(bufsize) < result.size()) { 4933 if (static_cast<size_t>(bufsize) < result.size()) {
4908 SetGLError(GL_INVALID_OPERATION, "glGetUniformBlocksCHROMIUM", 4934 SetGLError(GL_INVALID_OPERATION, "glGetUniformBlocksCHROMIUM",
4909 "bufsize is too small for result."); 4935 "bufsize is too small for result.");
4910 return; 4936 return;
4911 } 4937 }
4912 memcpy(info, &result[0], result.size()); 4938 memcpy(info, &result[0], result.size());
4913 } 4939 }
4914 4940
4915 void GLES2Implementation::GetUniformsES3CHROMIUMHelper( 4941 void GLES2Implementation::GetUniformsES3CHROMIUMHelper(
4916 GLuint program, std::vector<int8>* result) { 4942 GLuint program,
4943 std::vector<int8_t>* result) {
4917 DCHECK(result); 4944 DCHECK(result);
4918 // Clear the bucket so if the command fails nothing will be in it. 4945 // Clear the bucket so if the command fails nothing will be in it.
4919 helper_->SetBucketSize(kResultBucketId, 0); 4946 helper_->SetBucketSize(kResultBucketId, 0);
4920 helper_->GetUniformsES3CHROMIUM(program, kResultBucketId); 4947 helper_->GetUniformsES3CHROMIUM(program, kResultBucketId);
4921 GetBucketContents(kResultBucketId, result); 4948 GetBucketContents(kResultBucketId, result);
4922 } 4949 }
4923 4950
4924 void GLES2Implementation::GetUniformsES3CHROMIUM( 4951 void GLES2Implementation::GetUniformsES3CHROMIUM(
4925 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { 4952 GLuint program, GLsizei bufsize, GLsizei* size, void* info) {
4926 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4953 GPU_CLIENT_SINGLE_THREAD_CHECK();
4927 if (bufsize < 0) { 4954 if (bufsize < 0) {
4928 SetGLError( 4955 SetGLError(
4929 GL_INVALID_VALUE, "glGetUniformsES3CHROMIUM", "bufsize less than 0."); 4956 GL_INVALID_VALUE, "glGetUniformsES3CHROMIUM", "bufsize less than 0.");
4930 return; 4957 return;
4931 } 4958 }
4932 if (size == NULL) { 4959 if (size == NULL) {
4933 SetGLError(GL_INVALID_VALUE, "glGetUniformsES3CHROMIUM", "size is null."); 4960 SetGLError(GL_INVALID_VALUE, "glGetUniformsES3CHROMIUM", "size is null.");
4934 return; 4961 return;
4935 } 4962 }
4936 // Make sure they've set size to 0 else the value will be undefined on 4963 // Make sure they've set size to 0 else the value will be undefined on
4937 // lost context. 4964 // lost context.
4938 DCHECK_EQ(0, *size); 4965 DCHECK_EQ(0, *size);
4939 std::vector<int8> result; 4966 std::vector<int8_t> result;
4940 GetUniformsES3CHROMIUMHelper(program, &result); 4967 GetUniformsES3CHROMIUMHelper(program, &result);
4941 if (result.empty()) { 4968 if (result.empty()) {
4942 return; 4969 return;
4943 } 4970 }
4944 *size = result.size(); 4971 *size = result.size();
4945 if (!info) { 4972 if (!info) {
4946 return; 4973 return;
4947 } 4974 }
4948 if (static_cast<size_t>(bufsize) < result.size()) { 4975 if (static_cast<size_t>(bufsize) < result.size()) {
4949 SetGLError(GL_INVALID_OPERATION, 4976 SetGLError(GL_INVALID_OPERATION,
4950 "glGetUniformsES3CHROMIUM", "bufsize is too small for result."); 4977 "glGetUniformsES3CHROMIUM", "bufsize is too small for result.");
4951 return; 4978 return;
4952 } 4979 }
4953 memcpy(info, &result[0], result.size()); 4980 memcpy(info, &result[0], result.size());
4954 } 4981 }
4955 4982
4956 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUMHelper( 4983 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUMHelper(
4957 GLuint program, std::vector<int8>* result) { 4984 GLuint program,
4985 std::vector<int8_t>* result) {
4958 DCHECK(result); 4986 DCHECK(result);
4959 // Clear the bucket so if the command fails nothing will be in it. 4987 // Clear the bucket so if the command fails nothing will be in it.
4960 helper_->SetBucketSize(kResultBucketId, 0); 4988 helper_->SetBucketSize(kResultBucketId, 0);
4961 helper_->GetTransformFeedbackVaryingsCHROMIUM(program, kResultBucketId); 4989 helper_->GetTransformFeedbackVaryingsCHROMIUM(program, kResultBucketId);
4962 GetBucketContents(kResultBucketId, result); 4990 GetBucketContents(kResultBucketId, result);
4963 } 4991 }
4964 4992
4965 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUM( 4993 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUM(
4966 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { 4994 GLuint program, GLsizei bufsize, GLsizei* size, void* info) {
4967 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4995 GPU_CLIENT_SINGLE_THREAD_CHECK();
4968 if (bufsize < 0) { 4996 if (bufsize < 0) {
4969 SetGLError(GL_INVALID_VALUE, "glGetTransformFeedbackVaryingsCHROMIUM", 4997 SetGLError(GL_INVALID_VALUE, "glGetTransformFeedbackVaryingsCHROMIUM",
4970 "bufsize less than 0."); 4998 "bufsize less than 0.");
4971 return; 4999 return;
4972 } 5000 }
4973 if (size == NULL) { 5001 if (size == NULL) {
4974 SetGLError(GL_INVALID_VALUE, "glGetTransformFeedbackVaryingsCHROMIUM", 5002 SetGLError(GL_INVALID_VALUE, "glGetTransformFeedbackVaryingsCHROMIUM",
4975 "size is null."); 5003 "size is null.");
4976 return; 5004 return;
4977 } 5005 }
4978 // Make sure they've set size to 0 else the value will be undefined on 5006 // Make sure they've set size to 0 else the value will be undefined on
4979 // lost context. 5007 // lost context.
4980 DCHECK_EQ(0, *size); 5008 DCHECK_EQ(0, *size);
4981 std::vector<int8> result; 5009 std::vector<int8_t> result;
4982 GetTransformFeedbackVaryingsCHROMIUMHelper(program, &result); 5010 GetTransformFeedbackVaryingsCHROMIUMHelper(program, &result);
4983 if (result.empty()) { 5011 if (result.empty()) {
4984 return; 5012 return;
4985 } 5013 }
4986 *size = result.size(); 5014 *size = result.size();
4987 if (!info) { 5015 if (!info) {
4988 return; 5016 return;
4989 } 5017 }
4990 if (static_cast<size_t>(bufsize) < result.size()) { 5018 if (static_cast<size_t>(bufsize) < result.size()) {
4991 SetGLError(GL_INVALID_OPERATION, "glGetTransformFeedbackVaryingsCHROMIUM", 5019 SetGLError(GL_INVALID_OPERATION, "glGetTransformFeedbackVaryingsCHROMIUM",
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
6100 return; 6128 return;
6101 } 6129 }
6102 if (num_coords < 0) { 6130 if (num_coords < 0) {
6103 SetGLError(GL_INVALID_VALUE, kFunctionName, "numCoords < 0"); 6131 SetGLError(GL_INVALID_VALUE, kFunctionName, "numCoords < 0");
6104 return; 6132 return;
6105 } 6133 }
6106 if (num_coords != 0 && !coords) { 6134 if (num_coords != 0 && !coords) {
6107 SetGLError(GL_INVALID_VALUE, kFunctionName, "missing coords"); 6135 SetGLError(GL_INVALID_VALUE, kFunctionName, "missing coords");
6108 return; 6136 return;
6109 } 6137 }
6110 uint32 coord_type_size = GLES2Util::GetGLTypeSizeForPathCoordType(coord_type); 6138 uint32_t coord_type_size =
6139 GLES2Util::GetGLTypeSizeForPathCoordType(coord_type);
6111 if (coord_type_size == 0) { 6140 if (coord_type_size == 0) {
6112 SetGLError(GL_INVALID_ENUM, kFunctionName, "invalid coordType"); 6141 SetGLError(GL_INVALID_ENUM, kFunctionName, "invalid coordType");
6113 return; 6142 return;
6114 } 6143 }
6115 if (num_commands == 0) { 6144 if (num_commands == 0) {
6116 // No commands must mean no coords, thus nothing to memcpy. Let 6145 // No commands must mean no coords, thus nothing to memcpy. Let
6117 // the service validate the call. Validate coord_type above, so 6146 // the service validate the call. Validate coord_type above, so
6118 // that the parameters will be checked the in the same order 6147 // that the parameters will be checked the in the same order
6119 // regardless of num_commands. 6148 // regardless of num_commands.
6120 helper_->PathCommandsCHROMIUM(path, num_commands, 0, 0, num_coords, 6149 helper_->PathCommandsCHROMIUM(path, num_commands, 0, 0, num_coords,
6121 coord_type, 0, 0); 6150 coord_type, 0, 0);
6122 CheckGLError(); 6151 CheckGLError();
6123 return; 6152 return;
6124 } 6153 }
6125 6154
6126 uint32 coords_size; 6155 uint32_t coords_size;
6127 if (!SafeMultiplyUint32(num_coords, coord_type_size, &coords_size)) { 6156 if (!SafeMultiplyUint32(num_coords, coord_type_size, &coords_size)) {
6128 SetGLError(GL_INVALID_OPERATION, kFunctionName, "overflow"); 6157 SetGLError(GL_INVALID_OPERATION, kFunctionName, "overflow");
6129 return; 6158 return;
6130 } 6159 }
6131 6160
6132 uint32 required_buffer_size; 6161 uint32_t required_buffer_size;
6133 if (!SafeAddUint32(coords_size, num_commands, &required_buffer_size)) { 6162 if (!SafeAddUint32(coords_size, num_commands, &required_buffer_size)) {
6134 SetGLError(GL_INVALID_OPERATION, kFunctionName, "overflow"); 6163 SetGLError(GL_INVALID_OPERATION, kFunctionName, "overflow");
6135 return; 6164 return;
6136 } 6165 }
6137 6166
6138 ScopedTransferBufferPtr buffer(required_buffer_size, helper_, 6167 ScopedTransferBufferPtr buffer(required_buffer_size, helper_,
6139 transfer_buffer_); 6168 transfer_buffer_);
6140 if (!buffer.valid() || buffer.size() < required_buffer_size) { 6169 if (!buffer.valid() || buffer.size() < required_buffer_size) {
6141 SetGLError(GL_OUT_OF_MEMORY, kFunctionName, "too large"); 6170 SetGLError(GL_OUT_OF_MEMORY, kFunctionName, "too large");
6142 return; 6171 return;
6143 } 6172 }
6144 6173
6145 uint32 coords_shm_id = 0; 6174 uint32_t coords_shm_id = 0;
6146 uint32 coords_shm_offset = 0; 6175 uint32_t coords_shm_offset = 0;
6147 // Copy coords first because they need more strict alignment. 6176 // Copy coords first because they need more strict alignment.
6148 if (coords_size > 0) { 6177 if (coords_size > 0) {
6149 unsigned char* coords_addr = static_cast<unsigned char*>(buffer.address()); 6178 unsigned char* coords_addr = static_cast<unsigned char*>(buffer.address());
6150 memcpy(coords_addr, coords, coords_size); 6179 memcpy(coords_addr, coords, coords_size);
6151 coords_shm_id = buffer.shm_id(); 6180 coords_shm_id = buffer.shm_id();
6152 coords_shm_offset = buffer.offset(); 6181 coords_shm_offset = buffer.offset();
6153 } 6182 }
6154 6183
6155 DCHECK(num_commands > 0); 6184 DCHECK(num_commands > 0);
6156 unsigned char* commands_addr = 6185 unsigned char* commands_addr =
6157 static_cast<unsigned char*>(buffer.address()) + coords_size; 6186 static_cast<unsigned char*>(buffer.address()) + coords_size;
6158 memcpy(commands_addr, commands, num_commands); 6187 memcpy(commands_addr, commands, num_commands);
6159 6188
6160 helper_->PathCommandsCHROMIUM(path, num_commands, buffer.shm_id(), 6189 helper_->PathCommandsCHROMIUM(path, num_commands, buffer.shm_id(),
6161 buffer.offset() + coords_size, num_coords, 6190 buffer.offset() + coords_size, num_coords,
6162 coord_type, coords_shm_id, coords_shm_offset); 6191 coord_type, coords_shm_id, coords_shm_offset);
6163 CheckGLError(); 6192 CheckGLError();
6164 } 6193 }
6165 6194
6166 bool GLES2Implementation::PrepareInstancedPathCommand( 6195 bool GLES2Implementation::PrepareInstancedPathCommand(
6167 const char* function_name, 6196 const char* function_name,
6168 GLsizei num_paths, 6197 GLsizei num_paths,
6169 GLenum path_name_type, 6198 GLenum path_name_type,
6170 const void* paths, 6199 const void* paths,
6171 GLenum transform_type, 6200 GLenum transform_type,
6172 const GLfloat* transform_values, 6201 const GLfloat* transform_values,
6173 ScopedTransferBufferPtr* buffer, 6202 ScopedTransferBufferPtr* buffer,
6174 uint32* out_paths_shm_id, 6203 uint32_t* out_paths_shm_id,
6175 size_t* out_paths_offset, 6204 size_t* out_paths_offset,
6176 uint32* out_transforms_shm_id, 6205 uint32_t* out_transforms_shm_id,
6177 size_t* out_transforms_offset) { 6206 size_t* out_transforms_offset) {
6178 if (num_paths < 0) { 6207 if (num_paths < 0) {
6179 SetGLError(GL_INVALID_VALUE, function_name, "numPaths < 0"); 6208 SetGLError(GL_INVALID_VALUE, function_name, "numPaths < 0");
6180 return false; 6209 return false;
6181 } 6210 }
6182 uint32 path_name_size = 6211 uint32_t path_name_size =
6183 GLES2Util::GetGLTypeSizeForGLPathNameType(path_name_type); 6212 GLES2Util::GetGLTypeSizeForGLPathNameType(path_name_type);
6184 6213
6185 if (path_name_size == 0) { 6214 if (path_name_size == 0) {
6186 SetGLError(GL_INVALID_ENUM, function_name, "invalid pathNameType"); 6215 SetGLError(GL_INVALID_ENUM, function_name, "invalid pathNameType");
6187 return false; 6216 return false;
6188 } 6217 }
6189 6218
6190 uint32 transforms_component_count = 6219 uint32_t transforms_component_count =
6191 GLES2Util::GetComponentCountForGLTransformType(transform_type); 6220 GLES2Util::GetComponentCountForGLTransformType(transform_type);
6192 6221
6193 if (transform_type != GL_NONE && transforms_component_count == 0) { 6222 if (transform_type != GL_NONE && transforms_component_count == 0) {
6194 SetGLError(GL_INVALID_ENUM, function_name, "invalid transformType"); 6223 SetGLError(GL_INVALID_ENUM, function_name, "invalid transformType");
6195 return false; 6224 return false;
6196 } 6225 }
6197 6226
6198 if (num_paths == 0) { 6227 if (num_paths == 0) {
6199 // This might still be a valid or an invalid GL call. Make an empty call to 6228 // This might still be a valid or an invalid GL call. Make an empty call to
6200 // the service side to check the rest of the parameters. We check the above 6229 // the service side to check the rest of the parameters. We check the above
(...skipping 11 matching lines...) Expand all
6212 if (!paths) { 6241 if (!paths) {
6213 SetGLError(GL_INVALID_VALUE, function_name, "missing paths"); 6242 SetGLError(GL_INVALID_VALUE, function_name, "missing paths");
6214 return false; 6243 return false;
6215 } 6244 }
6216 6245
6217 if (transform_type != GL_NONE && !transform_values) { 6246 if (transform_type != GL_NONE && !transform_values) {
6218 SetGLError(GL_INVALID_VALUE, function_name, "missing transforms"); 6247 SetGLError(GL_INVALID_VALUE, function_name, "missing transforms");
6219 return false; 6248 return false;
6220 } 6249 }
6221 6250
6222 uint32 paths_size; 6251 uint32_t paths_size;
6223 if (!SafeMultiplyUint32(path_name_size, num_paths, &paths_size)) { 6252 if (!SafeMultiplyUint32(path_name_size, num_paths, &paths_size)) {
6224 SetGLError(GL_INVALID_OPERATION, function_name, "overflow"); 6253 SetGLError(GL_INVALID_OPERATION, function_name, "overflow");
6225 return false; 6254 return false;
6226 } 6255 }
6227 6256
6228 // The multiplication below will not overflow. 6257 // The multiplication below will not overflow.
6229 DCHECK(transforms_component_count <= 12); 6258 DCHECK(transforms_component_count <= 12);
6230 uint32 one_transform_size = sizeof(GLfloat) * transforms_component_count; 6259 uint32_t one_transform_size = sizeof(GLfloat) * transforms_component_count;
6231 6260
6232 uint32 transforms_size; 6261 uint32_t transforms_size;
6233 if (!SafeMultiplyUint32(one_transform_size, num_paths, &transforms_size)) { 6262 if (!SafeMultiplyUint32(one_transform_size, num_paths, &transforms_size)) {
6234 SetGLError(GL_INVALID_OPERATION, function_name, "overflow"); 6263 SetGLError(GL_INVALID_OPERATION, function_name, "overflow");
6235 return false; 6264 return false;
6236 } 6265 }
6237 6266
6238 uint32 required_buffer_size; 6267 uint32_t required_buffer_size;
6239 if (!SafeAddUint32(transforms_size, paths_size, &required_buffer_size)) { 6268 if (!SafeAddUint32(transforms_size, paths_size, &required_buffer_size)) {
6240 SetGLError(GL_INVALID_OPERATION, function_name, "overflow"); 6269 SetGLError(GL_INVALID_OPERATION, function_name, "overflow");
6241 return false; 6270 return false;
6242 } 6271 }
6243 6272
6244 buffer->Reset(required_buffer_size); 6273 buffer->Reset(required_buffer_size);
6245 6274
6246 if (!buffer->valid() || buffer->size() < required_buffer_size) { 6275 if (!buffer->valid() || buffer->size() < required_buffer_size) {
6247 SetGLError(GL_OUT_OF_MEMORY, function_name, "too large"); 6276 SetGLError(GL_OUT_OF_MEMORY, function_name, "too large");
6248 return false; 6277 return false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6280 GLenum transform_type, 6309 GLenum transform_type,
6281 const GLfloat* transform_values) { 6310 const GLfloat* transform_values) {
6282 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6311 GPU_CLIENT_SINGLE_THREAD_CHECK();
6283 GPU_CLIENT_LOG("[" << GetLogPrefix() 6312 GPU_CLIENT_LOG("[" << GetLogPrefix()
6284 << "] glStencilFillPathInstancedCHROMIUM(" << num_paths 6313 << "] glStencilFillPathInstancedCHROMIUM(" << num_paths
6285 << ", " << path_name_type << ", " << paths << ", " 6314 << ", " << path_name_type << ", " << paths << ", "
6286 << path_base << ", " << fill_mode << ", " << mask << ", " 6315 << path_base << ", " << fill_mode << ", " << mask << ", "
6287 << transform_type << ", " << transform_values << ")"); 6316 << transform_type << ", " << transform_values << ")");
6288 6317
6289 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_); 6318 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_);
6290 uint32 paths_shm_id = 0; 6319 uint32_t paths_shm_id = 0;
6291 size_t paths_offset = 0; 6320 size_t paths_offset = 0;
6292 uint32 transforms_shm_id = 0; 6321 uint32_t transforms_shm_id = 0;
6293 size_t transforms_offset = 0; 6322 size_t transforms_offset = 0;
6294 if (!PrepareInstancedPathCommand( 6323 if (!PrepareInstancedPathCommand(
6295 "glStencilFillPathInstancedCHROMIUM", num_paths, path_name_type, 6324 "glStencilFillPathInstancedCHROMIUM", num_paths, path_name_type,
6296 paths, transform_type, transform_values, &buffer, &paths_shm_id, 6325 paths, transform_type, transform_values, &buffer, &paths_shm_id,
6297 &paths_offset, &transforms_shm_id, &transforms_offset)) { 6326 &paths_offset, &transforms_shm_id, &transforms_offset)) {
6298 return; 6327 return;
6299 } 6328 }
6300 6329
6301 helper_->StencilFillPathInstancedCHROMIUM( 6330 helper_->StencilFillPathInstancedCHROMIUM(
6302 num_paths, path_name_type, paths_shm_id, paths_offset, path_base, 6331 num_paths, path_name_type, paths_shm_id, paths_offset, path_base,
(...skipping 12 matching lines...) Expand all
6315 GLenum transform_type, 6344 GLenum transform_type,
6316 const GLfloat* transform_values) { 6345 const GLfloat* transform_values) {
6317 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6346 GPU_CLIENT_SINGLE_THREAD_CHECK();
6318 GPU_CLIENT_LOG("[" << GetLogPrefix() 6347 GPU_CLIENT_LOG("[" << GetLogPrefix()
6319 << "] glStencilStrokePathInstancedCHROMIUM(" << num_paths 6348 << "] glStencilStrokePathInstancedCHROMIUM(" << num_paths
6320 << ", " << path_name_type << ", " << paths << ", " 6349 << ", " << path_name_type << ", " << paths << ", "
6321 << path_base << ", " << ref << ", " << mask << ", " 6350 << path_base << ", " << ref << ", " << mask << ", "
6322 << transform_type << ", " << transform_values << ")"); 6351 << transform_type << ", " << transform_values << ")");
6323 6352
6324 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_); 6353 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_);
6325 uint32 paths_shm_id = 0; 6354 uint32_t paths_shm_id = 0;
6326 size_t paths_offset = 0; 6355 size_t paths_offset = 0;
6327 uint32 transforms_shm_id = 0; 6356 uint32_t transforms_shm_id = 0;
6328 size_t transforms_offset = 0; 6357 size_t transforms_offset = 0;
6329 if (!PrepareInstancedPathCommand( 6358 if (!PrepareInstancedPathCommand(
6330 "glStencilStrokePathInstancedCHROMIUM", num_paths, path_name_type, 6359 "glStencilStrokePathInstancedCHROMIUM", num_paths, path_name_type,
6331 paths, transform_type, transform_values, &buffer, &paths_shm_id, 6360 paths, transform_type, transform_values, &buffer, &paths_shm_id,
6332 &paths_offset, &transforms_shm_id, &transforms_offset)) { 6361 &paths_offset, &transforms_shm_id, &transforms_offset)) {
6333 return; 6362 return;
6334 } 6363 }
6335 6364
6336 helper_->StencilStrokePathInstancedCHROMIUM( 6365 helper_->StencilStrokePathInstancedCHROMIUM(
6337 num_paths, path_name_type, paths_shm_id, paths_offset, path_base, ref, 6366 num_paths, path_name_type, paths_shm_id, paths_offset, path_base, ref,
(...skipping 10 matching lines...) Expand all
6348 GLenum cover_mode, 6377 GLenum cover_mode,
6349 GLenum transform_type, 6378 GLenum transform_type,
6350 const GLfloat* transform_values) { 6379 const GLfloat* transform_values) {
6351 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6380 GPU_CLIENT_SINGLE_THREAD_CHECK();
6352 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCoverFillPathInstancedCHROMIUM(" 6381 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCoverFillPathInstancedCHROMIUM("
6353 << num_paths << ", " << path_name_type << ", " << paths 6382 << num_paths << ", " << path_name_type << ", " << paths
6354 << ", " << path_base << ", " << cover_mode << ", " 6383 << ", " << path_base << ", " << cover_mode << ", "
6355 << transform_type << ", " << transform_values << ")"); 6384 << transform_type << ", " << transform_values << ")");
6356 6385
6357 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_); 6386 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_);
6358 uint32 paths_shm_id = 0; 6387 uint32_t paths_shm_id = 0;
6359 size_t paths_offset = 0; 6388 size_t paths_offset = 0;
6360 uint32 transforms_shm_id = 0; 6389 uint32_t transforms_shm_id = 0;
6361 size_t transforms_offset = 0; 6390 size_t transforms_offset = 0;
6362 if (!PrepareInstancedPathCommand( 6391 if (!PrepareInstancedPathCommand(
6363 "glCoverFillPathInstancedCHROMIUM", num_paths, path_name_type, paths, 6392 "glCoverFillPathInstancedCHROMIUM", num_paths, path_name_type, paths,
6364 transform_type, transform_values, &buffer, &paths_shm_id, 6393 transform_type, transform_values, &buffer, &paths_shm_id,
6365 &paths_offset, &transforms_shm_id, &transforms_offset)) { 6394 &paths_offset, &transforms_shm_id, &transforms_offset)) {
6366 return; 6395 return;
6367 } 6396 }
6368 6397
6369 helper_->CoverFillPathInstancedCHROMIUM( 6398 helper_->CoverFillPathInstancedCHROMIUM(
6370 num_paths, path_name_type, paths_shm_id, paths_offset, path_base, 6399 num_paths, path_name_type, paths_shm_id, paths_offset, path_base,
(...skipping 11 matching lines...) Expand all
6382 GLenum transform_type, 6411 GLenum transform_type,
6383 const GLfloat* transform_values) { 6412 const GLfloat* transform_values) {
6384 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6413 GPU_CLIENT_SINGLE_THREAD_CHECK();
6385 GPU_CLIENT_LOG("[" << GetLogPrefix() 6414 GPU_CLIENT_LOG("[" << GetLogPrefix()
6386 << "] glCoverStrokePathInstancedCHROMIUM(" << num_paths 6415 << "] glCoverStrokePathInstancedCHROMIUM(" << num_paths
6387 << ", " << path_name_type << ", " << paths << ", " 6416 << ", " << path_name_type << ", " << paths << ", "
6388 << path_base << ", " << cover_mode << ", " 6417 << path_base << ", " << cover_mode << ", "
6389 << transform_type << ", " << transform_values << ")"); 6418 << transform_type << ", " << transform_values << ")");
6390 6419
6391 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_); 6420 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_);
6392 uint32 paths_shm_id = 0; 6421 uint32_t paths_shm_id = 0;
6393 size_t paths_offset = 0; 6422 size_t paths_offset = 0;
6394 uint32 transforms_shm_id = 0; 6423 uint32_t transforms_shm_id = 0;
6395 size_t transforms_offset = 0; 6424 size_t transforms_offset = 0;
6396 if (!PrepareInstancedPathCommand( 6425 if (!PrepareInstancedPathCommand(
6397 "glCoverStrokePathInstancedCHROMIUM", num_paths, path_name_type, 6426 "glCoverStrokePathInstancedCHROMIUM", num_paths, path_name_type,
6398 paths, transform_type, transform_values, &buffer, &paths_shm_id, 6427 paths, transform_type, transform_values, &buffer, &paths_shm_id,
6399 &paths_offset, &transforms_shm_id, &transforms_offset)) { 6428 &paths_offset, &transforms_shm_id, &transforms_offset)) {
6400 return; 6429 return;
6401 } 6430 }
6402 6431
6403 helper_->CoverStrokePathInstancedCHROMIUM( 6432 helper_->CoverStrokePathInstancedCHROMIUM(
6404 num_paths, path_name_type, paths_shm_id, paths_offset, path_base, 6433 num_paths, path_name_type, paths_shm_id, paths_offset, path_base,
(...skipping 13 matching lines...) Expand all
6418 GLenum transform_type, 6447 GLenum transform_type,
6419 const GLfloat* transform_values) { 6448 const GLfloat* transform_values) {
6420 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6449 GPU_CLIENT_SINGLE_THREAD_CHECK();
6421 GPU_CLIENT_LOG( 6450 GPU_CLIENT_LOG(
6422 "[" << GetLogPrefix() << "] glStencilThenCoverFillPathInstancedCHROMIUM(" 6451 "[" << GetLogPrefix() << "] glStencilThenCoverFillPathInstancedCHROMIUM("
6423 << num_paths << ", " << path_name_type << ", " << paths << ", " 6452 << num_paths << ", " << path_name_type << ", " << paths << ", "
6424 << path_base << ", " << cover_mode << ", " << fill_mode << ", " 6453 << path_base << ", " << cover_mode << ", " << fill_mode << ", "
6425 << mask << ", " << transform_type << ", " << transform_values << ")"); 6454 << mask << ", " << transform_type << ", " << transform_values << ")");
6426 6455
6427 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_); 6456 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_);
6428 uint32 paths_shm_id = 0; 6457 uint32_t paths_shm_id = 0;
6429 size_t paths_offset = 0; 6458 size_t paths_offset = 0;
6430 uint32 transforms_shm_id = 0; 6459 uint32_t transforms_shm_id = 0;
6431 size_t transforms_offset = 0; 6460 size_t transforms_offset = 0;
6432 if (!PrepareInstancedPathCommand( 6461 if (!PrepareInstancedPathCommand(
6433 "glStencilThenCoverFillPathInstancedCHROMIUM", num_paths, 6462 "glStencilThenCoverFillPathInstancedCHROMIUM", num_paths,
6434 path_name_type, paths, transform_type, transform_values, &buffer, 6463 path_name_type, paths, transform_type, transform_values, &buffer,
6435 &paths_shm_id, &paths_offset, &transforms_shm_id, 6464 &paths_shm_id, &paths_offset, &transforms_shm_id,
6436 &transforms_offset)) { 6465 &transforms_offset)) {
6437 return; 6466 return;
6438 } 6467 }
6439 6468
6440 helper_->StencilThenCoverFillPathInstancedCHROMIUM( 6469 helper_->StencilThenCoverFillPathInstancedCHROMIUM(
(...skipping 16 matching lines...) Expand all
6457 const GLfloat* transform_values) { 6486 const GLfloat* transform_values) {
6458 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6487 GPU_CLIENT_SINGLE_THREAD_CHECK();
6459 GPU_CLIENT_LOG("[" << GetLogPrefix() 6488 GPU_CLIENT_LOG("[" << GetLogPrefix()
6460 << "] glStencilThenCoverStrokePathInstancedCHROMIUM(" 6489 << "] glStencilThenCoverStrokePathInstancedCHROMIUM("
6461 << num_paths << ", " << path_name_type << ", " << paths 6490 << num_paths << ", " << path_name_type << ", " << paths
6462 << ", " << path_base << ", " << cover_mode << ", " << ref 6491 << ", " << path_base << ", " << cover_mode << ", " << ref
6463 << ", " << mask << ", " << transform_type << ", " 6492 << ", " << mask << ", " << transform_type << ", "
6464 << transform_values << ")"); 6493 << transform_values << ")");
6465 6494
6466 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_); 6495 ScopedTransferBufferPtr buffer(helper_, transfer_buffer_);
6467 uint32 paths_shm_id = 0; 6496 uint32_t paths_shm_id = 0;
6468 size_t paths_offset = 0; 6497 size_t paths_offset = 0;
6469 uint32 transforms_shm_id = 0; 6498 uint32_t transforms_shm_id = 0;
6470 size_t transforms_offset = 0; 6499 size_t transforms_offset = 0;
6471 if (!PrepareInstancedPathCommand( 6500 if (!PrepareInstancedPathCommand(
6472 "glStencilThenCoverStrokePathInstancedCHROMIUM", num_paths, 6501 "glStencilThenCoverStrokePathInstancedCHROMIUM", num_paths,
6473 path_name_type, paths, transform_type, transform_values, &buffer, 6502 path_name_type, paths, transform_type, transform_values, &buffer,
6474 &paths_shm_id, &paths_offset, &transforms_shm_id, 6503 &paths_shm_id, &paths_offset, &transforms_shm_id,
6475 &transforms_offset)) { 6504 &transforms_offset)) {
6476 return; 6505 return;
6477 } 6506 }
6478 6507
6479 helper_->StencilThenCoverStrokePathInstancedCHROMIUM( 6508 helper_->StencilThenCoverStrokePathInstancedCHROMIUM(
(...skipping 22 matching lines...) Expand all
6502 GLint location, 6531 GLint location,
6503 GLenum gen_mode, 6532 GLenum gen_mode,
6504 GLint components, 6533 GLint components,
6505 const GLfloat* coeffs) { 6534 const GLfloat* coeffs) {
6506 GPU_CLIENT_SINGLE_THREAD_CHECK(); 6535 GPU_CLIENT_SINGLE_THREAD_CHECK();
6507 GPU_CLIENT_LOG("[" << GetLogPrefix() 6536 GPU_CLIENT_LOG("[" << GetLogPrefix()
6508 << "] glProgramPathFragmentInputGenCHROMIUM(" << program 6537 << "] glProgramPathFragmentInputGenCHROMIUM(" << program
6509 << ", " << gen_mode << ", " << components << ", " << coeffs 6538 << ", " << gen_mode << ", " << components << ", " << coeffs
6510 << ")"); 6539 << ")");
6511 6540
6512 uint32 coeffs_per_component = 6541 uint32_t coeffs_per_component =
6513 GLES2Util::GetCoefficientCountForGLPathFragmentInputGenMode(gen_mode); 6542 GLES2Util::GetCoefficientCountForGLPathFragmentInputGenMode(gen_mode);
6514 6543
6515 if (components <= 0 || components > 4 || gen_mode == GL_NONE || 6544 if (components <= 0 || components > 4 || gen_mode == GL_NONE ||
6516 coeffs_per_component == 0 || location == -1) { 6545 coeffs_per_component == 0 || location == -1) {
6517 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode, 6546 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode,
6518 components, 0, 0); 6547 components, 0, 0);
6519 } else { 6548 } else {
6520 // The multiplication below will not overflow. 6549 // The multiplication below will not overflow.
6521 DCHECK(coeffs_per_component > 0 && coeffs_per_component <= 4); 6550 DCHECK(coeffs_per_component > 0 && coeffs_per_component <= 4);
6522 DCHECK(components > 0 && components <= 4); 6551 DCHECK(components > 0 && components <= 4);
6523 uint32 coeffs_size = sizeof(GLfloat) * coeffs_per_component * components; 6552 uint32_t coeffs_size = sizeof(GLfloat) * coeffs_per_component * components;
6524 6553
6525 ScopedTransferBufferPtr buffer(coeffs_size, helper_, transfer_buffer_); 6554 ScopedTransferBufferPtr buffer(coeffs_size, helper_, transfer_buffer_);
6526 if (!buffer.valid() || buffer.size() < coeffs_size) { 6555 if (!buffer.valid() || buffer.size() < coeffs_size) {
6527 SetGLError(GL_OUT_OF_MEMORY, "glProgramPathFragmentInputGenCHROMIUM", 6556 SetGLError(GL_OUT_OF_MEMORY, "glProgramPathFragmentInputGenCHROMIUM",
6528 "no room in transfer buffer"); 6557 "no room in transfer buffer");
6529 return; 6558 return;
6530 } 6559 }
6531 6560
6532 DCHECK(coeffs_size > 0); 6561 DCHECK(coeffs_size > 0);
6533 unsigned char* addr = static_cast<unsigned char*>(buffer.address()); 6562 unsigned char* addr = static_cast<unsigned char*>(buffer.address());
6534 memcpy(addr, coeffs, coeffs_size); 6563 memcpy(addr, coeffs, coeffs_size);
6535 6564
6536 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode, 6565 helper_->ProgramPathFragmentInputGenCHROMIUM(program, location, gen_mode,
6537 components, buffer.shm_id(), 6566 components, buffer.shm_id(),
6538 buffer.offset()); 6567 buffer.offset());
6539 } 6568 }
6540 CheckGLError(); 6569 CheckGLError();
6541 } 6570 }
6542 6571
6543 // Include the auto-generated part of this file. We split this because it means 6572 // Include the auto-generated part of this file. We split this because it means
6544 // we can easily edit the non-auto generated parts right here in this file 6573 // we can easily edit the non-auto generated parts right here in this file
6545 // instead of having to edit some template or the code generator. 6574 // instead of having to edit some template or the code generator.
6546 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 6575 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6547 6576
6548 } // namespace gles2 6577 } // namespace gles2
6549 } // namespace gpu 6578 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698