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/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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 std::unique_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { | 50 std::unique_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { |
51 return base::WrapUnique(new TestWebGraphicsContext3D()); | 51 return base::WrapUnique(new TestWebGraphicsContext3D()); |
52 } | 52 } |
53 | 53 |
54 TestWebGraphicsContext3D::TestWebGraphicsContext3D() | 54 TestWebGraphicsContext3D::TestWebGraphicsContext3D() |
55 : context_id_(s_context_id++), | 55 : context_id_(s_context_id++), |
56 times_bind_texture_succeeds_(-1), | 56 times_bind_texture_succeeds_(-1), |
57 times_end_query_succeeds_(-1), | 57 times_end_query_succeeds_(-1), |
58 context_lost_(false), | 58 context_lost_(false), |
59 times_map_buffer_chromium_succeeds_(-1), | 59 times_map_buffer_chromium_succeeds_(-1), |
60 current_used_transfer_buffer_usage_bytes_(0), | |
61 max_used_transfer_buffer_usage_bytes_(0), | |
62 next_program_id_(1000), | 60 next_program_id_(1000), |
63 next_shader_id_(2000), | 61 next_shader_id_(2000), |
64 next_framebuffer_id_(1), | 62 next_framebuffer_id_(1), |
65 current_framebuffer_(0), | 63 current_framebuffer_(0), |
66 max_texture_size_(2048), | 64 max_texture_size_(2048), |
67 reshape_called_(false), | 65 reshape_called_(false), |
68 width_(0), | 66 width_(0), |
69 height_(0), | 67 height_(0), |
70 scale_factor_(-1.f), | 68 scale_factor_(-1.f), |
71 test_support_(NULL), | 69 test_support_(NULL), |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 std::unordered_map<unsigned, std::unique_ptr<Buffer>>& buffers = | 541 std::unordered_map<unsigned, std::unique_ptr<Buffer>>& buffers = |
544 namespace_->buffers; | 542 namespace_->buffers; |
545 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 543 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
546 DCHECK_EQ(target, buffers[bound_buffer_]->target); | 544 DCHECK_EQ(target, buffers[bound_buffer_]->target); |
547 Buffer* buffer = buffers[bound_buffer_].get(); | 545 Buffer* buffer = buffers[bound_buffer_].get(); |
548 if (context_lost_) { | 546 if (context_lost_) { |
549 buffer->pixels = nullptr; | 547 buffer->pixels = nullptr; |
550 return; | 548 return; |
551 } | 549 } |
552 | 550 |
553 size_t old_size = buffer->size; | |
554 | |
555 buffer->pixels.reset(new uint8_t[size]); | 551 buffer->pixels.reset(new uint8_t[size]); |
556 buffer->size = size; | 552 buffer->size = size; |
557 if (data != NULL) | 553 if (data != nullptr) |
558 memcpy(buffer->pixels.get(), data, size); | 554 memcpy(buffer->pixels.get(), data, size); |
559 if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) | |
560 current_used_transfer_buffer_usage_bytes_ += | |
561 base::checked_cast<int>(buffer->size) - | |
562 base::checked_cast<int>(old_size); | |
563 max_used_transfer_buffer_usage_bytes_ = | |
564 std::max(max_used_transfer_buffer_usage_bytes_, | |
565 current_used_transfer_buffer_usage_bytes_); | |
566 } | 555 } |
567 | 556 |
568 void TestWebGraphicsContext3D::pixelStorei(GLenum pname, GLint param) { | 557 void TestWebGraphicsContext3D::pixelStorei(GLenum pname, GLint param) { |
569 switch (pname) { | 558 switch (pname) { |
570 case GL_UNPACK_ALIGNMENT: | 559 case GL_UNPACK_ALIGNMENT: |
571 // Param should be a power of two <= 8. | 560 // Param should be a power of two <= 8. |
572 EXPECT_EQ(0, param & (param - 1)); | 561 EXPECT_EQ(0, param & (param - 1)); |
573 EXPECT_GE(8, param); | 562 EXPECT_GE(8, param); |
574 switch (param) { | 563 switch (param) { |
575 case 1: | 564 case 1: |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 return id; | 755 return id; |
767 } | 756 } |
768 | 757 |
769 void TestWebGraphicsContext3D::RetireRenderbufferId(GLuint id) { | 758 void TestWebGraphicsContext3D::RetireRenderbufferId(GLuint id) { |
770 base::AutoLock lock_for_renderbuffer_access(namespace_->lock); | 759 base::AutoLock lock_for_renderbuffer_access(namespace_->lock); |
771 DCHECK(namespace_->renderbuffer_set.find(id) != | 760 DCHECK(namespace_->renderbuffer_set.find(id) != |
772 namespace_->renderbuffer_set.end()); | 761 namespace_->renderbuffer_set.end()); |
773 namespace_->renderbuffer_set.erase(id); | 762 namespace_->renderbuffer_set.erase(id); |
774 } | 763 } |
775 | 764 |
776 void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes( | |
777 size_t max_transfer_buffer_usage_bytes) { | |
778 test_capabilities_.max_transfer_buffer_usage_bytes = | |
779 max_transfer_buffer_usage_bytes; | |
780 } | |
781 | |
782 void TestWebGraphicsContext3D::SetMaxSamples(int max_samples) { | 765 void TestWebGraphicsContext3D::SetMaxSamples(int max_samples) { |
783 test_capabilities_.gpu.max_samples = max_samples; | 766 test_capabilities_.max_samples = max_samples; |
784 } | 767 } |
785 | 768 |
786 TestWebGraphicsContext3D::TextureTargets::TextureTargets() { | 769 TestWebGraphicsContext3D::TextureTargets::TextureTargets() { |
787 // Initialize default bindings. | 770 // Initialize default bindings. |
788 bound_textures_[GL_TEXTURE_2D] = 0; | 771 bound_textures_[GL_TEXTURE_2D] = 0; |
789 bound_textures_[GL_TEXTURE_EXTERNAL_OES] = 0; | 772 bound_textures_[GL_TEXTURE_EXTERNAL_OES] = 0; |
790 bound_textures_[GL_TEXTURE_RECTANGLE_ARB] = 0; | 773 bound_textures_[GL_TEXTURE_RECTANGLE_ARB] = 0; |
791 } | 774 } |
792 | 775 |
793 TestWebGraphicsContext3D::TextureTargets::~TextureTargets() {} | 776 TestWebGraphicsContext3D::TextureTargets::~TextureTargets() {} |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 | 824 |
842 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} | 825 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} |
843 | 826 |
844 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 827 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
845 | 828 |
846 TestWebGraphicsContext3D::Image::Image() {} | 829 TestWebGraphicsContext3D::Image::Image() {} |
847 | 830 |
848 TestWebGraphicsContext3D::Image::~Image() {} | 831 TestWebGraphicsContext3D::Image::~Image() {} |
849 | 832 |
850 } // namespace cc | 833 } // namespace cc |
OLD | NEW |