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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 474 } |
475 | 475 |
476 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, | 476 void TestWebGraphicsContext3D::bufferData(WebKit::WGC3Denum target, |
477 WebKit::WGC3Dsizeiptr size, | 477 WebKit::WGC3Dsizeiptr size, |
478 const void* data, | 478 const void* data, |
479 WebKit::WGC3Denum usage) { | 479 WebKit::WGC3Denum usage) { |
480 base::AutoLock lock(namespace_->lock); | 480 base::AutoLock lock(namespace_->lock); |
481 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 481 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
482 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 482 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
483 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 483 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
| 484 Buffer* buffer = buffers.get(bound_buffer_); |
484 if (context_lost_) { | 485 if (context_lost_) { |
485 buffers.get(bound_buffer_)->pixels.reset(); | 486 buffer->pixels.reset(); |
486 return; | 487 return; |
487 } | 488 } |
488 buffers.get(bound_buffer_)->pixels.reset(new uint8[size]); | 489 |
| 490 buffer->pixels.reset(new uint8[size]); |
| 491 buffer->size = size; |
489 if (data != NULL) | 492 if (data != NULL) |
490 memcpy(buffers.get(bound_buffer_)->pixels.get(), data, size); | 493 memcpy(buffer->pixels.get(), data, size); |
491 } | 494 } |
492 | 495 |
493 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, | 496 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(WebKit::WGC3Denum target, |
494 WebKit::WGC3Denum access) { | 497 WebKit::WGC3Denum access) { |
495 base::AutoLock lock(namespace_->lock); | 498 base::AutoLock lock(namespace_->lock); |
496 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 499 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
497 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 500 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
498 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 501 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
499 if (times_map_buffer_chromium_succeeds_ >= 0) { | 502 if (times_map_buffer_chromium_succeeds_ >= 0) { |
500 if (!times_map_buffer_chromium_succeeds_) { | 503 if (!times_map_buffer_chromium_succeeds_) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 } | 596 } |
594 | 597 |
595 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { | 598 WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() { |
596 base::AutoLock lock(namespace_->lock); | 599 base::AutoLock lock(namespace_->lock); |
597 WGC3Duint image_id = namespace_->next_image_id++; | 600 WGC3Duint image_id = namespace_->next_image_id++; |
598 DCHECK(image_id < (1 << 17)); | 601 DCHECK(image_id < (1 << 17)); |
599 image_id |= context_id_ << 17; | 602 image_id |= context_id_ << 17; |
600 return image_id; | 603 return image_id; |
601 } | 604 } |
602 | 605 |
603 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} | 606 size_t TestWebGraphicsContext3D::GetTransferBufferMemoryUsedBytes() const { |
| 607 size_t total_bytes = 0; |
| 608 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
| 609 base::ScopedPtrHashMap<unsigned, Buffer>::iterator it = buffers.begin(); |
| 610 for (; it != buffers.end(); ++it) { |
| 611 Buffer* buffer = it->second; |
| 612 if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) |
| 613 total_bytes += buffer->size; |
| 614 } |
| 615 return total_bytes; |
| 616 } |
| 617 |
| 618 void TestWebGraphicsContext3D::SetMaxTransferBufferUsageBytes( |
| 619 size_t max_transfer_buffer_usage_bytes) { |
| 620 test_capabilities_.max_transfer_buffer_usage_bytes = |
| 621 max_transfer_buffer_usage_bytes; |
| 622 } |
| 623 |
| 624 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} |
604 | 625 |
605 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 626 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
606 | 627 |
607 TestWebGraphicsContext3D::Image::Image() {} | 628 TestWebGraphicsContext3D::Image::Image() {} |
608 | 629 |
609 TestWebGraphicsContext3D::Image::~Image() {} | 630 TestWebGraphicsContext3D::Image::~Image() {} |
610 | 631 |
611 } // namespace cc | 632 } // namespace cc |
OLD | NEW |