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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ptr_util.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/numerics/safe_conversions.h" 18 #include "base/numerics/safe_conversions.h"
18 #include "cc/test/test_context_support.h" 19 #include "cc/test/test_context_support.h"
19 #include "gpu/GLES2/gl2extchromium.h" 20 #include "gpu/GLES2/gl2extchromium.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/khronos/GLES2/gl2ext.h" 22 #include "third_party/khronos/GLES2/gl2ext.h"
22 23
23 namespace cc { 24 namespace cc {
24 25
25 static unsigned s_context_id = 1; 26 static unsigned s_context_id = 1;
(...skipping 13 matching lines...) Expand all
39 next_renderbuffer_id(1) { 40 next_renderbuffer_id(1) {
40 } 41 }
41 42
42 TestWebGraphicsContext3D::Namespace::~Namespace() { 43 TestWebGraphicsContext3D::Namespace::~Namespace() {
43 g_shared_namespace_lock.Get().AssertAcquired(); 44 g_shared_namespace_lock.Get().AssertAcquired();
44 if (shared_namespace_ == this) 45 if (shared_namespace_ == this)
45 shared_namespace_ = NULL; 46 shared_namespace_ = NULL;
46 } 47 }
47 48
48 // static 49 // static
49 scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { 50 std::unique_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() {
50 return make_scoped_ptr(new TestWebGraphicsContext3D()); 51 return base::WrapUnique(new TestWebGraphicsContext3D());
51 } 52 }
52 53
53 TestWebGraphicsContext3D::TestWebGraphicsContext3D() 54 TestWebGraphicsContext3D::TestWebGraphicsContext3D()
54 : context_id_(s_context_id++), 55 : context_id_(s_context_id++),
55 times_bind_texture_succeeds_(-1), 56 times_bind_texture_succeeds_(-1),
56 times_end_query_succeeds_(-1), 57 times_end_query_succeeds_(-1),
57 context_lost_(false), 58 context_lost_(false),
58 times_map_buffer_chromium_succeeds_(-1), 59 times_map_buffer_chromium_succeeds_(-1),
59 current_used_transfer_buffer_usage_bytes_(0), 60 current_used_transfer_buffer_usage_bytes_(0),
60 max_used_transfer_buffer_usage_bytes_(0), 61 max_used_transfer_buffer_usage_bytes_(0),
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 bound_buffer_ = buffer; 520 bound_buffer_ = buffer;
520 if (!bound_buffer_) 521 if (!bound_buffer_)
521 return; 522 return;
522 unsigned context_id = buffer >> 16; 523 unsigned context_id = buffer >> 16;
523 unsigned buffer_id = buffer & 0xffff; 524 unsigned buffer_id = buffer & 0xffff;
524 base::AutoLock lock(namespace_->lock); 525 base::AutoLock lock(namespace_->lock);
525 DCHECK(buffer_id); 526 DCHECK(buffer_id);
526 DCHECK_LT(buffer_id, namespace_->next_buffer_id); 527 DCHECK_LT(buffer_id, namespace_->next_buffer_id);
527 DCHECK_EQ(context_id, context_id_); 528 DCHECK_EQ(context_id, context_id_);
528 529
529 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = 530 std::unordered_map<unsigned, std::unique_ptr<Buffer>>& buffers =
530 namespace_->buffers; 531 namespace_->buffers;
531 if (buffers.count(bound_buffer_) == 0) 532 if (buffers.count(bound_buffer_) == 0)
532 buffers[bound_buffer_] = make_scoped_ptr(new Buffer); 533 buffers[bound_buffer_] = base::WrapUnique(new Buffer);
533 534
534 buffers[bound_buffer_]->target = target; 535 buffers[bound_buffer_]->target = target;
535 } 536 }
536 537
537 void TestWebGraphicsContext3D::bufferData(GLenum target, 538 void TestWebGraphicsContext3D::bufferData(GLenum target,
538 GLsizeiptr size, 539 GLsizeiptr size,
539 const void* data, 540 const void* data,
540 GLenum usage) { 541 GLenum usage) {
541 base::AutoLock lock(namespace_->lock); 542 base::AutoLock lock(namespace_->lock);
542 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = 543 std::unordered_map<unsigned, std::unique_ptr<Buffer>>& buffers =
543 namespace_->buffers; 544 namespace_->buffers;
544 DCHECK_GT(buffers.count(bound_buffer_), 0u); 545 DCHECK_GT(buffers.count(bound_buffer_), 0u);
545 DCHECK_EQ(target, buffers[bound_buffer_]->target); 546 DCHECK_EQ(target, buffers[bound_buffer_]->target);
546 Buffer* buffer = buffers[bound_buffer_].get(); 547 Buffer* buffer = buffers[bound_buffer_].get();
547 if (context_lost_) { 548 if (context_lost_) {
548 buffer->pixels = nullptr; 549 buffer->pixels = nullptr;
549 return; 550 return;
550 } 551 }
551 552
552 size_t old_size = buffer->size; 553 size_t old_size = buffer->size;
(...skipping 29 matching lines...) Expand all
582 } 583 }
583 break; 584 break;
584 default: 585 default:
585 break; 586 break;
586 } 587 }
587 } 588 }
588 589
589 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, 590 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target,
590 GLenum access) { 591 GLenum access) {
591 base::AutoLock lock(namespace_->lock); 592 base::AutoLock lock(namespace_->lock);
592 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = 593 std::unordered_map<unsigned, std::unique_ptr<Buffer>>& buffers =
593 namespace_->buffers; 594 namespace_->buffers;
594 DCHECK_GT(buffers.count(bound_buffer_), 0u); 595 DCHECK_GT(buffers.count(bound_buffer_), 0u);
595 DCHECK_EQ(target, buffers[bound_buffer_]->target); 596 DCHECK_EQ(target, buffers[bound_buffer_]->target);
596 if (times_map_buffer_chromium_succeeds_ >= 0) { 597 if (times_map_buffer_chromium_succeeds_ >= 0) {
597 if (!times_map_buffer_chromium_succeeds_) { 598 if (!times_map_buffer_chromium_succeeds_) {
598 return NULL; 599 return NULL;
599 } 600 }
600 --times_map_buffer_chromium_succeeds_; 601 --times_map_buffer_chromium_succeeds_;
601 } 602 }
602 603
603 return buffers[bound_buffer_]->pixels.get(); 604 return buffers[bound_buffer_]->pixels.get();
604 } 605 }
605 606
606 GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( 607 GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM(
607 GLenum target) { 608 GLenum target) {
608 base::AutoLock lock(namespace_->lock); 609 base::AutoLock lock(namespace_->lock);
609 std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = 610 std::unordered_map<unsigned, std::unique_ptr<Buffer>>& buffers =
610 namespace_->buffers; 611 namespace_->buffers;
611 DCHECK_GT(buffers.count(bound_buffer_), 0u); 612 DCHECK_GT(buffers.count(bound_buffer_), 0u);
612 DCHECK_EQ(target, buffers[bound_buffer_]->target); 613 DCHECK_EQ(target, buffers[bound_buffer_]->target);
613 buffers[bound_buffer_]->pixels = nullptr; 614 buffers[bound_buffer_]->pixels = nullptr;
614 return true; 615 return true;
615 } 616 }
616 617
617 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer, 618 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer,
618 GLsizei width, 619 GLsizei width,
619 GLsizei height, 620 GLsizei height,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 841
841 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} 842 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {}
842 843
843 TestWebGraphicsContext3D::Buffer::~Buffer() {} 844 TestWebGraphicsContext3D::Buffer::~Buffer() {}
844 845
845 TestWebGraphicsContext3D::Image::Image() {} 846 TestWebGraphicsContext3D::Image::Image() {}
846 847
847 TestWebGraphicsContext3D::Image::~Image() {} 848 TestWebGraphicsContext3D::Image::~Image() {}
848 849
849 } // namespace cc 850 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_web_graphics_context_3d.h ('k') | cc/test/test_web_graphics_context_3d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698