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

Side by Side Diff: cc/test/test_web_graphics_context_3d.cc

Issue 1587283002: Switch cc to std::unordered_*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unordered-map
Patch Set: Fix MSVC build issue Created 4 years, 10 months 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
« no previous file with comments | « cc/test/test_web_graphics_context_3d.h ('k') | cc/tiles/image_decode_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/test_web_graphics_context_3d.h" 5 #include "cc/test/test_web_graphics_context_3d.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 bound_buffer_ = buffer; 519 bound_buffer_ = buffer;
520 if (!bound_buffer_) 520 if (!bound_buffer_)
521 return; 521 return;
522 unsigned context_id = buffer >> 16; 522 unsigned context_id = buffer >> 16;
523 unsigned buffer_id = buffer & 0xffff; 523 unsigned buffer_id = buffer & 0xffff;
524 base::AutoLock lock(namespace_->lock); 524 base::AutoLock lock(namespace_->lock);
525 DCHECK(buffer_id); 525 DCHECK(buffer_id);
526 DCHECK_LT(buffer_id, namespace_->next_buffer_id); 526 DCHECK_LT(buffer_id, namespace_->next_buffer_id);
527 DCHECK_EQ(context_id, context_id_); 527 DCHECK_EQ(context_id, context_id_);
528 528
529 base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = 529 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers =
530 namespace_->buffers; 530 namespace_->buffers;
531 if (buffers.count(bound_buffer_) == 0) 531 if (buffers.count(bound_buffer_) == 0)
532 buffers.set(bound_buffer_, make_scoped_ptr(new Buffer)); 532 buffers[bound_buffer_] = make_scoped_ptr(new Buffer);
533 533
534 buffers.get(bound_buffer_)->target = target; 534 buffers[bound_buffer_]->target = target;
535 } 535 }
536 536
537 void TestWebGraphicsContext3D::bufferData(GLenum target, 537 void TestWebGraphicsContext3D::bufferData(GLenum target,
538 GLsizeiptr size, 538 GLsizeiptr size,
539 const void* data, 539 const void* data,
540 GLenum usage) { 540 GLenum usage) {
541 base::AutoLock lock(namespace_->lock); 541 base::AutoLock lock(namespace_->lock);
542 base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = 542 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers =
543 namespace_->buffers; 543 namespace_->buffers;
544 DCHECK_GT(buffers.count(bound_buffer_), 0u); 544 DCHECK_GT(buffers.count(bound_buffer_), 0u);
545 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); 545 DCHECK_EQ(target, buffers[bound_buffer_]->target);
546 Buffer* buffer = buffers.get(bound_buffer_); 546 Buffer* buffer = buffers[bound_buffer_].get();
547 if (context_lost_) { 547 if (context_lost_) {
548 buffer->pixels = nullptr; 548 buffer->pixels = nullptr;
549 return; 549 return;
550 } 550 }
551 551
552 size_t old_size = buffer->size; 552 size_t old_size = buffer->size;
553 553
554 buffer->pixels.reset(new uint8_t[size]); 554 buffer->pixels.reset(new uint8_t[size]);
555 buffer->size = size; 555 buffer->size = size;
556 if (data != NULL) 556 if (data != NULL)
(...skipping 25 matching lines...) Expand all
582 } 582 }
583 break; 583 break;
584 default: 584 default:
585 break; 585 break;
586 } 586 }
587 } 587 }
588 588
589 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, 589 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target,
590 GLenum access) { 590 GLenum access) {
591 base::AutoLock lock(namespace_->lock); 591 base::AutoLock lock(namespace_->lock);
592 base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = 592 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers =
593 namespace_->buffers; 593 namespace_->buffers;
594 DCHECK_GT(buffers.count(bound_buffer_), 0u); 594 DCHECK_GT(buffers.count(bound_buffer_), 0u);
595 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); 595 DCHECK_EQ(target, buffers[bound_buffer_]->target);
596 if (times_map_buffer_chromium_succeeds_ >= 0) { 596 if (times_map_buffer_chromium_succeeds_ >= 0) {
597 if (!times_map_buffer_chromium_succeeds_) { 597 if (!times_map_buffer_chromium_succeeds_) {
598 return NULL; 598 return NULL;
599 } 599 }
600 --times_map_buffer_chromium_succeeds_; 600 --times_map_buffer_chromium_succeeds_;
601 } 601 }
602 602
603 return buffers.get(bound_buffer_)->pixels.get(); 603 return buffers[bound_buffer_]->pixels.get();
604 } 604 }
605 605
606 GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( 606 GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM(
607 GLenum target) { 607 GLenum target) {
608 base::AutoLock lock(namespace_->lock); 608 base::AutoLock lock(namespace_->lock);
609 base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = 609 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers =
610 namespace_->buffers; 610 namespace_->buffers;
611 DCHECK_GT(buffers.count(bound_buffer_), 0u); 611 DCHECK_GT(buffers.count(bound_buffer_), 0u);
612 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); 612 DCHECK_EQ(target, buffers[bound_buffer_]->target);
613 buffers.get(bound_buffer_)->pixels = nullptr; 613 buffers[bound_buffer_]->pixels = nullptr;
614 return true; 614 return true;
615 } 615 }
616 616
617 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer, 617 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer,
618 GLsizei width, 618 GLsizei width,
619 GLsizei height, 619 GLsizei height,
620 GLenum internalformat) { 620 GLenum internalformat) {
621 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat)); 621 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat));
622 GLuint image_id = NextImageId(); 622 GLuint image_id = NextImageId();
623 base::AutoLock lock(namespace_->lock); 623 base::AutoLock lock(namespace_->lock);
624 base::hash_set<unsigned>& images = namespace_->images; 624 std::unordered_set<unsigned>& images = namespace_->images;
625 images.insert(image_id); 625 images.insert(image_id);
626 return image_id; 626 return image_id;
627 } 627 }
628 628
629 void TestWebGraphicsContext3D::destroyImageCHROMIUM( 629 void TestWebGraphicsContext3D::destroyImageCHROMIUM(
630 GLuint id) { 630 GLuint id) {
631 RetireImageId(id); 631 RetireImageId(id);
632 base::AutoLock lock(namespace_->lock); 632 base::AutoLock lock(namespace_->lock);
633 base::hash_set<unsigned>& images = namespace_->images; 633 std::unordered_set<unsigned>& images = namespace_->images;
634 if (!images.count(id)) 634 if (!images.count(id))
635 ADD_FAILURE() << "destroyImageCHROMIUM called on unknown image " << id; 635 ADD_FAILURE() << "destroyImageCHROMIUM called on unknown image " << id;
636 images.erase(id); 636 images.erase(id);
637 } 637 }
638 638
639 GLuint TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM( 639 GLuint TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM(
640 GLsizei width, 640 GLsizei width,
641 GLsizei height, 641 GLsizei height,
642 GLenum internalformat, 642 GLenum internalformat,
643 GLenum usage) { 643 GLenum usage) {
644 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat)); 644 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat));
645 GLuint image_id = NextImageId(); 645 GLuint image_id = NextImageId();
646 base::AutoLock lock(namespace_->lock); 646 base::AutoLock lock(namespace_->lock);
647 base::hash_set<unsigned>& images = namespace_->images; 647 std::unordered_set<unsigned>& images = namespace_->images;
648 images.insert(image_id); 648 images.insert(image_id);
649 return image_id; 649 return image_id;
650 } 650 }
651 651
652 GLuint64 TestWebGraphicsContext3D::insertFenceSync() { 652 GLuint64 TestWebGraphicsContext3D::insertFenceSync() {
653 return next_insert_fence_sync_++; 653 return next_insert_fence_sync_++;
654 } 654 }
655 655
656 void TestWebGraphicsContext3D::genSyncToken(GLuint64 fence_sync, 656 void TestWebGraphicsContext3D::genSyncToken(GLuint64 fence_sync,
657 GLbyte* sync_token) { 657 GLbyte* sync_token) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 840
841 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} 841 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {}
842 842
843 TestWebGraphicsContext3D::Buffer::~Buffer() {} 843 TestWebGraphicsContext3D::Buffer::~Buffer() {}
844 844
845 TestWebGraphicsContext3D::Image::Image() {} 845 TestWebGraphicsContext3D::Image::Image() {}
846 846
847 TestWebGraphicsContext3D::Image::~Image() {} 847 TestWebGraphicsContext3D::Image::~Image() {}
848 848
849 } // namespace cc 849 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_web_graphics_context_3d.h ('k') | cc/tiles/image_decode_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698