OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "cc/debug/test_web_graphics_context_3d.h" | 5 #include "cc/debug/test_web_graphics_context_3d.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 WebKit::WebGLId buffer) { | 475 WebKit::WebGLId buffer) { |
476 bound_buffer_ = buffer; | 476 bound_buffer_ = buffer; |
477 if (!bound_buffer_) | 477 if (!bound_buffer_) |
478 return; | 478 return; |
479 unsigned context_id = buffer >> 17; | 479 unsigned context_id = buffer >> 17; |
480 unsigned buffer_id = buffer & 0x1ffff; | 480 unsigned buffer_id = buffer & 0x1ffff; |
481 base::AutoLock lock(namespace_->lock); | 481 base::AutoLock lock(namespace_->lock); |
482 DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id); | 482 DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id); |
483 DCHECK_EQ(context_id, context_id_); | 483 DCHECK_EQ(context_id, context_id_); |
484 | 484 |
485 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 485 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
486 if (buffers.count(bound_buffer_) == 0) | 486 if (buffers.count(bound_buffer_) == 0) |
487 buffers.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); | 487 buffers.set(bound_buffer_, make_scoped_ptr(new Buffer).Pass()); |
488 | 488 |
489 buffers.get(bound_buffer_)->target = target; | 489 buffers.get(bound_buffer_)->target = target; |
490 } | 490 } |
491 | 491 |
492 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, | 492 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, |
493 WebKit::WGC3Dsizeiptr size, | 493 WebKit::WGC3Dsizeiptr size, |
494 const void* data, | 494 const void* data, |
495 WebKit::WGC3Denum usage) { | 495 WebKit::WGC3Denum usage) { |
496 base::AutoLock lock(namespace_->lock); | 496 base::AutoLock lock(namespace_->lock); |
497 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 497 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
498 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 498 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
499 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 499 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
500 if (context_lost_) { | 500 if (context_lost_) { |
501 buffers.get(bound_buffer_)->pixels.reset(); | 501 buffers.get(bound_buffer_)->pixels.reset(); |
502 return; | 502 return; |
503 } | 503 } |
504 buffers.get(bound_buffer_)->pixels.reset(new uint8[size]); | 504 buffers.get(bound_buffer_)->pixels.reset(new uint8[size]); |
505 if (data != NULL) | 505 if (data != NULL) |
506 memcpy(buffers.get(bound_buffer_)->pixels.get(), data, size); | 506 memcpy(buffers.get(bound_buffer_)->pixels.get(), data, size); |
507 } | 507 } |
508 | 508 |
509 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, | 509 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, |
510 WebKit::WGC3Denum access) { | 510 WebKit::WGC3Denum access) { |
511 base::AutoLock lock(namespace_->lock); | 511 base::AutoLock lock(namespace_->lock); |
512 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 512 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
513 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 513 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
514 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 514 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
515 if (times_map_buffer_chromium_succeeds_ >= 0) { | 515 if (times_map_buffer_chromium_succeeds_ >= 0) { |
516 if (!times_map_buffer_chromium_succeeds_) { | 516 if (!times_map_buffer_chromium_succeeds_) { |
517 return NULL; | 517 return NULL; |
518 } | 518 } |
519 --times_map_buffer_chromium_succeeds_; | 519 --times_map_buffer_chromium_succeeds_; |
520 } | 520 } |
521 return buffers.get(bound_buffer_)->pixels.get(); | 521 return buffers.get(bound_buffer_)->pixels.get(); |
522 } | 522 } |
523 | 523 |
524 WebKit::WGC3Dboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( | 524 WebKit::WGC3Dboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( |
525 WebKit::WGC3Denum target) { | 525 WebKit::WGC3Denum target) { |
526 base::AutoLock lock(namespace_->lock); | 526 base::AutoLock lock(namespace_->lock); |
527 ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 527 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
528 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 528 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
529 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 529 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
530 buffers.get(bound_buffer_)->pixels.reset(); | 530 buffers.get(bound_buffer_)->pixels.reset(); |
531 return true; | 531 return true; |
532 } | 532 } |
533 | 533 |
534 WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM( | 534 WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM( |
535 WebKit::WGC3Dsizei width, WebKit::WGC3Dsizei height, | 535 WebKit::WGC3Dsizei width, WebKit::WGC3Dsizei height, |
536 WebKit::WGC3Denum internalformat) { | 536 WebKit::WGC3Denum internalformat) { |
537 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); | 537 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); |
538 WebKit::WGC3Duint image_id = NextImageId(); | 538 WebKit::WGC3Duint image_id = NextImageId(); |
539 base::AutoLock lock(namespace_->lock); | 539 base::AutoLock lock(namespace_->lock); |
540 ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; | 540 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; |
541 images.set(image_id, make_scoped_ptr(new Image).Pass()); | 541 images.set(image_id, make_scoped_ptr(new Image).Pass()); |
542 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); | 542 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); |
543 return image_id; | 543 return image_id; |
544 } | 544 } |
545 | 545 |
546 void TestWebGraphicsContext3D::destroyImageCHROMIUM( | 546 void TestWebGraphicsContext3D::destroyImageCHROMIUM( |
547 WebKit::WGC3Duint id) { | 547 WebKit::WGC3Duint id) { |
548 base::AutoLock lock(namespace_->lock); | 548 base::AutoLock lock(namespace_->lock); |
549 unsigned context_id = id >> 17; | 549 unsigned context_id = id >> 17; |
550 unsigned image_id = id & 0x1ffff; | 550 unsigned image_id = id & 0x1ffff; |
551 DCHECK(image_id && image_id < namespace_->next_image_id); | 551 DCHECK(image_id && image_id < namespace_->next_image_id); |
552 DCHECK_EQ(context_id, context_id_); | 552 DCHECK_EQ(context_id, context_id_); |
553 } | 553 } |
554 | 554 |
555 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( | 555 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( |
556 WebKit::WGC3Duint image_id, | 556 WebKit::WGC3Duint image_id, |
557 WebKit::WGC3Denum pname, | 557 WebKit::WGC3Denum pname, |
558 WebKit::WGC3Dint* params) { | 558 WebKit::WGC3Dint* params) { |
559 base::AutoLock lock(namespace_->lock); | 559 base::AutoLock lock(namespace_->lock); |
560 DCHECK_GT(namespace_->images.count(image_id), 0u); | 560 DCHECK_GT(namespace_->images.count(image_id), 0u); |
561 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); | 561 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); |
562 *params = 0; | 562 *params = 0; |
563 } | 563 } |
564 | 564 |
565 void* TestWebGraphicsContext3D::mapImageCHROMIUM(WebKit::WGC3Duint image_id, | 565 void* TestWebGraphicsContext3D::mapImageCHROMIUM(WebKit::WGC3Duint image_id, |
566 WebKit::WGC3Denum access) { | 566 WebKit::WGC3Denum access) { |
567 base::AutoLock lock(namespace_->lock); | 567 base::AutoLock lock(namespace_->lock); |
568 ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; | 568 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; |
569 DCHECK_GT(images.count(image_id), 0u); | 569 DCHECK_GT(images.count(image_id), 0u); |
570 if (times_map_image_chromium_succeeds_ >= 0) { | 570 if (times_map_image_chromium_succeeds_ >= 0) { |
571 if (!times_map_image_chromium_succeeds_) { | 571 if (!times_map_image_chromium_succeeds_) { |
572 return NULL; | 572 return NULL; |
573 } | 573 } |
574 --times_map_image_chromium_succeeds_; | 574 --times_map_image_chromium_succeeds_; |
575 } | 575 } |
576 return images.get(image_id)->pixels.get(); | 576 return images.get(image_id)->pixels.get(); |
577 } | 577 } |
578 | 578 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 618 |
619 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} | 619 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} |
620 | 620 |
621 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 621 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
622 | 622 |
623 TestWebGraphicsContext3D::Image::Image() {} | 623 TestWebGraphicsContext3D::Image::Image() {} |
624 | 624 |
625 TestWebGraphicsContext3D::Image::~Image() {} | 625 TestWebGraphicsContext3D::Image::~Image() {} |
626 | 626 |
627 } // namespace cc | 627 } // namespace cc |
OLD | NEW |