| 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/debug/test_web_graphics_context_3d.h" | 5 #include "cc/debug/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 g_shared_namespace_lock.Get().AssertAcquired(); | 51 g_shared_namespace_lock.Get().AssertAcquired(); |
| 52 if (shared_namespace_ == this) | 52 if (shared_namespace_ == this) |
| 53 shared_namespace_ = NULL; | 53 shared_namespace_ = NULL; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { | 57 scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { |
| 58 return make_scoped_ptr(new TestWebGraphicsContext3D()); | 58 return make_scoped_ptr(new TestWebGraphicsContext3D()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // static | |
| 62 base::Callback<scoped_ptr<TestWebGraphicsContext3D>()> | |
| 63 TestWebGraphicsContext3D::CreateFactory() { | |
| 64 return base::Bind(&TestWebGraphicsContext3D::Create); | |
| 65 } | |
| 66 | |
| 67 TestWebGraphicsContext3D::TestWebGraphicsContext3D() | 61 TestWebGraphicsContext3D::TestWebGraphicsContext3D() |
| 68 : FakeWebGraphicsContext3D(), | 62 : FakeWebGraphicsContext3D(), |
| 69 context_id_(s_context_id++), | 63 context_id_(s_context_id++), |
| 70 support_swapbuffers_complete_callback_(true), | 64 support_swapbuffers_complete_callback_(true), |
| 71 have_extension_io_surface_(false), | 65 have_extension_io_surface_(false), |
| 72 have_extension_egl_image_(false), | 66 have_extension_egl_image_(false), |
| 73 times_make_current_succeeds_(-1), | 67 times_make_current_succeeds_(-1), |
| 74 times_bind_texture_succeeds_(-1), | 68 times_bind_texture_succeeds_(-1), |
| 75 times_end_query_succeeds_(-1), | 69 times_end_query_succeeds_(-1), |
| 76 times_gen_mailbox_succeeds_(-1), | 70 times_gen_mailbox_succeeds_(-1), |
| 77 context_lost_(false), | 71 context_lost_(false), |
| 78 times_map_image_chromium_succeeds_(-1), | 72 times_map_image_chromium_succeeds_(-1), |
| 79 times_map_buffer_chromium_succeeds_(-1), | 73 times_map_buffer_chromium_succeeds_(-1), |
| 80 context_lost_callback_(NULL), | 74 context_lost_callback_(NULL), |
| 81 swap_buffers_callback_(NULL), | 75 swap_buffers_callback_(NULL), |
| 82 memory_allocation_changed_callback_(NULL), | |
| 83 max_texture_size_(1024), | 76 max_texture_size_(1024), |
| 84 width_(0), | 77 width_(0), |
| 85 height_(0), | 78 height_(0), |
| 86 bound_buffer_(0), | 79 bound_buffer_(0), |
| 87 weak_ptr_factory_(this) { | 80 weak_ptr_factory_(this) { |
| 88 CreateNamespace(); | 81 CreateNamespace(); |
| 89 } | 82 } |
| 90 | 83 |
| 91 TestWebGraphicsContext3D::TestWebGraphicsContext3D( | 84 TestWebGraphicsContext3D::TestWebGraphicsContext3D( |
| 92 const WebGraphicsContext3D::Attributes& attributes) | 85 const WebGraphicsContext3D::Attributes& attributes) |
| 93 : FakeWebGraphicsContext3D(), | 86 : FakeWebGraphicsContext3D(), |
| 94 context_id_(s_context_id++), | 87 context_id_(s_context_id++), |
| 95 attributes_(attributes), | 88 attributes_(attributes), |
| 96 support_swapbuffers_complete_callback_(true), | 89 support_swapbuffers_complete_callback_(true), |
| 97 have_extension_io_surface_(false), | 90 have_extension_io_surface_(false), |
| 98 have_extension_egl_image_(false), | 91 have_extension_egl_image_(false), |
| 99 times_make_current_succeeds_(-1), | 92 times_make_current_succeeds_(-1), |
| 100 times_bind_texture_succeeds_(-1), | 93 times_bind_texture_succeeds_(-1), |
| 101 times_end_query_succeeds_(-1), | 94 times_end_query_succeeds_(-1), |
| 102 times_gen_mailbox_succeeds_(-1), | 95 times_gen_mailbox_succeeds_(-1), |
| 103 context_lost_(false), | 96 context_lost_(false), |
| 104 times_map_image_chromium_succeeds_(-1), | 97 times_map_image_chromium_succeeds_(-1), |
| 105 times_map_buffer_chromium_succeeds_(-1), | 98 times_map_buffer_chromium_succeeds_(-1), |
| 106 context_lost_callback_(NULL), | 99 context_lost_callback_(NULL), |
| 107 swap_buffers_callback_(NULL), | 100 swap_buffers_callback_(NULL), |
| 108 memory_allocation_changed_callback_(NULL), | |
| 109 max_texture_size_(1024), | 101 max_texture_size_(1024), |
| 110 width_(0), | 102 width_(0), |
| 111 height_(0), | 103 height_(0), |
| 112 bound_buffer_(0), | 104 bound_buffer_(0), |
| 113 weak_ptr_factory_(this) { | 105 weak_ptr_factory_(this) { |
| 114 CreateNamespace(); | 106 CreateNamespace(); |
| 115 } | 107 } |
| 116 | 108 |
| 117 void TestWebGraphicsContext3D::CreateNamespace() { | 109 void TestWebGraphicsContext3D::CreateNamespace() { |
| 118 if (attributes_.shareResources) { | 110 if (attributes_.shareResources) { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 WebGraphicsSyncPointCallback* callback) { | 424 WebGraphicsSyncPointCallback* callback) { |
| 433 sync_point_callbacks_.push_back(callback); | 425 sync_point_callbacks_.push_back(callback); |
| 434 } | 426 } |
| 435 | 427 |
| 436 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( | 428 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( |
| 437 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { | 429 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { |
| 438 if (support_swapbuffers_complete_callback_) | 430 if (support_swapbuffers_complete_callback_) |
| 439 swap_buffers_callback_ = callback; | 431 swap_buffers_callback_ = callback; |
| 440 } | 432 } |
| 441 | 433 |
| 442 void TestWebGraphicsContext3D::setMemoryAllocationChangedCallbackCHROMIUM( | |
| 443 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { | |
| 444 memory_allocation_changed_callback_ = callback; | |
| 445 } | |
| 446 | |
| 447 void TestWebGraphicsContext3D::prepareTexture() { | 434 void TestWebGraphicsContext3D::prepareTexture() { |
| 448 if (swap_buffers_callback_) { | 435 if (swap_buffers_callback_) { |
| 449 base::MessageLoop::current()->PostTask( | 436 base::MessageLoop::current()->PostTask( |
| 450 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete, | 437 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete, |
| 451 weak_ptr_factory_.GetWeakPtr())); | 438 weak_ptr_factory_.GetWeakPtr())); |
| 452 } | 439 } |
| 453 CallAllSyncPointCallbacks(); | 440 CallAllSyncPointCallbacks(); |
| 454 } | 441 } |
| 455 | 442 |
| 456 void TestWebGraphicsContext3D::finish() { | 443 void TestWebGraphicsContext3D::finish() { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 } | 616 } |
| 630 | 617 |
| 631 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { | 618 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { |
| 632 base::AutoLock lock(namespace_->lock); | 619 base::AutoLock lock(namespace_->lock); |
| 633 WGC3Duint image_id = namespace_->next_image_id++; | 620 WGC3Duint image_id = namespace_->next_image_id++; |
| 634 DCHECK(image_id < (1 << 17)); | 621 DCHECK(image_id < (1 << 17)); |
| 635 image_id |= context_id_ << 17; | 622 image_id |= context_id_ << 17; |
| 636 return image_id; | 623 return image_id; |
| 637 } | 624 } |
| 638 | 625 |
| 639 void TestWebGraphicsContext3D::SetMemoryAllocation( | |
| 640 WebKit::WebGraphicsMemoryAllocation allocation) { | |
| 641 if (!memory_allocation_changed_callback_) | |
| 642 return; | |
| 643 memory_allocation_changed_callback_->onMemoryAllocationChanged(allocation); | |
| 644 } | |
| 645 | |
| 646 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} | 626 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} |
| 647 | 627 |
| 648 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 628 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
| 649 | 629 |
| 650 TestWebGraphicsContext3D::Image::Image() {} | 630 TestWebGraphicsContext3D::Image::Image() {} |
| 651 | 631 |
| 652 TestWebGraphicsContext3D::Image::~Image() {} | 632 TestWebGraphicsContext3D::Image::~Image() {} |
| 653 | 633 |
| 654 } // namespace cc | 634 } // namespace cc |
| OLD | NEW |