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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // static | 46 // static |
47 scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { | 47 scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { |
48 return make_scoped_ptr(new TestWebGraphicsContext3D()); | 48 return make_scoped_ptr(new TestWebGraphicsContext3D()); |
49 } | 49 } |
50 | 50 |
51 TestWebGraphicsContext3D::TestWebGraphicsContext3D() | 51 TestWebGraphicsContext3D::TestWebGraphicsContext3D() |
52 : context_id_(s_context_id++), | 52 : context_id_(s_context_id++), |
53 times_bind_texture_succeeds_(-1), | 53 times_bind_texture_succeeds_(-1), |
54 times_end_query_succeeds_(-1), | 54 times_end_query_succeeds_(-1), |
55 context_lost_(false), | 55 context_lost_(false), |
56 times_map_image_chromium_succeeds_(-1), | |
57 times_map_buffer_chromium_succeeds_(-1), | 56 times_map_buffer_chromium_succeeds_(-1), |
58 current_used_transfer_buffer_usage_bytes_(0), | 57 current_used_transfer_buffer_usage_bytes_(0), |
59 max_used_transfer_buffer_usage_bytes_(0), | 58 max_used_transfer_buffer_usage_bytes_(0), |
60 next_program_id_(1000), | 59 next_program_id_(1000), |
61 next_shader_id_(2000), | 60 next_shader_id_(2000), |
62 max_texture_size_(2048), | 61 max_texture_size_(2048), |
63 reshape_called_(false), | 62 reshape_called_(false), |
64 width_(0), | 63 width_(0), |
65 height_(0), | 64 height_(0), |
66 scale_factor_(-1.f), | 65 scale_factor_(-1.f), |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( | 537 GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( |
539 GLenum target) { | 538 GLenum target) { |
540 base::AutoLock lock(namespace_->lock); | 539 base::AutoLock lock(namespace_->lock); |
541 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 540 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
542 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 541 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
543 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 542 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
544 buffers.get(bound_buffer_)->pixels = nullptr; | 543 buffers.get(bound_buffer_)->pixels = nullptr; |
545 return true; | 544 return true; |
546 } | 545 } |
547 | 546 |
548 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(GLsizei width, | 547 GLuint TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer, |
| 548 GLsizei width, |
549 GLsizei height, | 549 GLsizei height, |
550 GLenum internalformat, | 550 GLenum internalformat) { |
551 GLenum usage) { | 551 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat)); |
552 DCHECK_EQ(GL_RGBA8_OES, static_cast<int>(internalformat)); | |
553 GLuint image_id = NextImageId(); | 552 GLuint image_id = NextImageId(); |
554 base::AutoLock lock(namespace_->lock); | 553 base::AutoLock lock(namespace_->lock); |
555 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; | 554 base::hash_set<unsigned>& images = namespace_->images; |
556 images.set(image_id, make_scoped_ptr(new Image).Pass()); | 555 images.insert(image_id); |
557 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); | |
558 return image_id; | 556 return image_id; |
559 } | 557 } |
560 | 558 |
561 void TestWebGraphicsContext3D::destroyImageCHROMIUM( | 559 void TestWebGraphicsContext3D::destroyImageCHROMIUM( |
562 GLuint id) { | 560 GLuint id) { |
563 RetireImageId(id); | 561 RetireImageId(id); |
564 } | |
565 | |
566 void TestWebGraphicsContext3D::getImageParameterivCHROMIUM( | |
567 GLuint image_id, | |
568 GLenum pname, | |
569 GLint* params) { | |
570 base::AutoLock lock(namespace_->lock); | 562 base::AutoLock lock(namespace_->lock); |
571 DCHECK_GT(namespace_->images.count(image_id), 0u); | 563 base::hash_set<unsigned>& images = namespace_->images; |
572 DCHECK_EQ(GL_IMAGE_ROWBYTES_CHROMIUM, static_cast<int>(pname)); | 564 if (!images.count(id)) |
573 *params = 0; | 565 ADD_FAILURE() << "destroyImageCHROMIUM called on unknown image " << id; |
574 } | 566 images.erase(id); |
575 | |
576 void* TestWebGraphicsContext3D::mapImageCHROMIUM(GLuint image_id) { | |
577 base::AutoLock lock(namespace_->lock); | |
578 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; | |
579 DCHECK_GT(images.count(image_id), 0u); | |
580 if (times_map_image_chromium_succeeds_ >= 0) { | |
581 if (!times_map_image_chromium_succeeds_) { | |
582 return NULL; | |
583 } | |
584 --times_map_image_chromium_succeeds_; | |
585 } | |
586 return images.get(image_id)->pixels.get(); | |
587 } | |
588 | |
589 void TestWebGraphicsContext3D::unmapImageCHROMIUM( | |
590 GLuint image_id) { | |
591 base::AutoLock lock(namespace_->lock); | |
592 DCHECK_GT(namespace_->images.count(image_id), 0u); | |
593 } | 567 } |
594 | 568 |
595 GLuint TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM( | 569 GLuint TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM( |
596 GLsizei width, | 570 GLsizei width, |
597 GLsizei height, | 571 GLsizei height, |
598 GLenum internalformat, | 572 GLenum internalformat, |
599 GLenum usage) { | 573 GLenum usage) { |
600 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat)); | 574 DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat)); |
601 GLuint image_id = NextImageId(); | 575 GLuint image_id = NextImageId(); |
602 base::AutoLock lock(namespace_->lock); | 576 base::AutoLock lock(namespace_->lock); |
603 base::ScopedPtrHashMap<unsigned, Image>& images = namespace_->images; | 577 base::hash_set<unsigned>& images = namespace_->images; |
604 images.set(image_id, make_scoped_ptr(new Image).Pass()); | 578 images.insert(image_id); |
605 images.get(image_id)->pixels.reset(new uint8[width * height * 4]); | |
606 return image_id; | 579 return image_id; |
607 } | 580 } |
608 | 581 |
609 unsigned TestWebGraphicsContext3D::insertSyncPoint() { | 582 unsigned TestWebGraphicsContext3D::insertSyncPoint() { |
610 return next_insert_sync_point_++; | 583 return next_insert_sync_point_++; |
611 } | 584 } |
612 | 585 |
613 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point) { | 586 void TestWebGraphicsContext3D::waitSyncPoint(unsigned sync_point) { |
614 if (sync_point) | 587 if (sync_point) |
615 last_waited_sync_point_ = sync_point; | 588 last_waited_sync_point_ = sync_point; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 713 |
741 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} | 714 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} |
742 | 715 |
743 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 716 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
744 | 717 |
745 TestWebGraphicsContext3D::Image::Image() {} | 718 TestWebGraphicsContext3D::Image::Image() {} |
746 | 719 |
747 TestWebGraphicsContext3D::Image::~Image() {} | 720 TestWebGraphicsContext3D::Image::~Image() {} |
748 | 721 |
749 } // namespace cc | 722 } // namespace cc |
OLD | NEW |