| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 next_shader_id_(2000), | 62 next_shader_id_(2000), |
| 63 next_framebuffer_id_(1), | 63 next_framebuffer_id_(1), |
| 64 current_framebuffer_(0), | 64 current_framebuffer_(0), |
| 65 max_texture_size_(2048), | 65 max_texture_size_(2048), |
| 66 reshape_called_(false), | 66 reshape_called_(false), |
| 67 width_(0), | 67 width_(0), |
| 68 height_(0), | 68 height_(0), |
| 69 scale_factor_(-1.f), | 69 scale_factor_(-1.f), |
| 70 test_support_(NULL), | 70 test_support_(NULL), |
| 71 last_update_type_(NO_UPDATE), | 71 last_update_type_(NO_UPDATE), |
| 72 next_insert_sync_point_(1), | 72 next_insert_fence_sync_(1), |
| 73 unpack_alignment_(4), | 73 unpack_alignment_(4), |
| 74 bound_buffer_(0), | 74 bound_buffer_(0), |
| 75 weak_ptr_factory_(this) { | 75 weak_ptr_factory_(this) { |
| 76 CreateNamespace(); | 76 CreateNamespace(); |
| 77 set_support_image(true); | 77 set_support_image(true); |
| 78 } | 78 } |
| 79 | 79 |
| 80 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { | 80 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { |
| 81 base::AutoLock lock(g_shared_namespace_lock.Get()); | 81 base::AutoLock lock(g_shared_namespace_lock.Get()); |
| 82 namespace_ = NULL; | 82 namespace_ = NULL; |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 base::hash_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 unsigned TestWebGraphicsContext3D::insertSyncPoint() { | 652 GLuint TestWebGraphicsContext3D::insertSyncPoint() { |
| 653 return next_insert_sync_point_++; | 653 return static_cast<GLuint>(next_insert_fence_sync_++); |
| 654 } |
| 655 |
| 656 GLuint64 TestWebGraphicsContext3D::insertFenceSync() { |
| 657 return next_insert_fence_sync_++; |
| 658 } |
| 659 |
| 660 void TestWebGraphicsContext3D::genSyncToken(GLuint64 fence_sync, |
| 661 GLbyte* sync_token) { |
| 662 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, 0, |
| 663 fence_sync); |
| 664 sync_token_data.SetVerifyFlush(); |
| 665 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); |
| 654 } | 666 } |
| 655 | 667 |
| 656 void TestWebGraphicsContext3D::waitSyncToken(const GLbyte* sync_token) { | 668 void TestWebGraphicsContext3D::waitSyncToken(const GLbyte* sync_token) { |
| 657 if (sync_token) { | 669 if (sync_token) { |
| 658 gpu::SyncToken sync_token_data; | 670 gpu::SyncToken sync_token_data; |
| 659 memcpy(sync_token_data.GetData(), sync_token, sizeof(sync_token_data)); | 671 memcpy(sync_token_data.GetData(), sync_token, sizeof(sync_token_data)); |
| 660 if (sync_token_data.HasData()) | 672 if (sync_token_data.HasData()) |
| 661 last_waited_sync_token_ = sync_token_data; | 673 last_waited_sync_token_ = sync_token_data; |
| 662 } | 674 } |
| 663 } | 675 } |
| 664 | 676 |
| 677 void TestWebGraphicsContext3D::verifySyncTokens(GLbyte** sync_tokens, |
| 678 GLsizei count) { |
| 679 for (GLsizei i = 0; i < count; ++i) { |
| 680 gpu::SyncToken sync_token_data; |
| 681 memcpy(sync_token_data.GetData(), sync_tokens[i], sizeof(sync_token_data)); |
| 682 sync_token_data.SetVerifyFlush(); |
| 683 memcpy(sync_tokens[i], &sync_token_data, sizeof(sync_token_data)); |
| 684 } |
| 685 } |
| 686 |
| 665 size_t TestWebGraphicsContext3D::NumTextures() const { | 687 size_t TestWebGraphicsContext3D::NumTextures() const { |
| 666 base::AutoLock lock(namespace_->lock); | 688 base::AutoLock lock(namespace_->lock); |
| 667 return namespace_->textures.Size(); | 689 return namespace_->textures.Size(); |
| 668 } | 690 } |
| 669 | 691 |
| 670 GLuint TestWebGraphicsContext3D::TextureAt(int i) const { | 692 GLuint TestWebGraphicsContext3D::TextureAt(int i) const { |
| 671 base::AutoLock lock(namespace_->lock); | 693 base::AutoLock lock(namespace_->lock); |
| 672 return namespace_->textures.IdAt(i); | 694 return namespace_->textures.IdAt(i); |
| 673 } | 695 } |
| 674 | 696 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 | 844 |
| 823 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} | 845 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} |
| 824 | 846 |
| 825 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 847 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
| 826 | 848 |
| 827 TestWebGraphicsContext3D::Image::Image() {} | 849 TestWebGraphicsContext3D::Image::Image() {} |
| 828 | 850 |
| 829 TestWebGraphicsContext3D::Image::~Image() {} | 851 TestWebGraphicsContext3D::Image::~Image() {} |
| 830 | 852 |
| 831 } // namespace cc | 853 } // namespace cc |
| OLD | NEW |