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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 next_shader_id_(2000), | 60 next_shader_id_(2000), |
61 max_texture_size_(2048), | 61 max_texture_size_(2048), |
62 reshape_called_(false), | 62 reshape_called_(false), |
63 width_(0), | 63 width_(0), |
64 height_(0), | 64 height_(0), |
65 scale_factor_(-1.f), | 65 scale_factor_(-1.f), |
66 test_support_(NULL), | 66 test_support_(NULL), |
67 last_update_type_(NoUpdate), | 67 last_update_type_(NoUpdate), |
68 next_insert_sync_point_(1), | 68 next_insert_sync_point_(1), |
69 last_waited_sync_point_(0), | 69 last_waited_sync_point_(0), |
| 70 unpack_alignment_(4), |
70 bound_buffer_(0), | 71 bound_buffer_(0), |
71 weak_ptr_factory_(this) { | 72 weak_ptr_factory_(this) { |
72 CreateNamespace(); | 73 CreateNamespace(); |
73 } | 74 } |
74 | 75 |
75 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { | 76 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { |
76 base::AutoLock lock(g_shared_namespace_lock.Get()); | 77 base::AutoLock lock(g_shared_namespace_lock.Get()); |
77 namespace_ = NULL; | 78 namespace_ = NULL; |
78 } | 79 } |
79 | 80 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 *params = 1; | 361 *params = 1; |
361 } | 362 } |
362 | 363 |
363 void TestWebGraphicsContext3D::getIntegerv( | 364 void TestWebGraphicsContext3D::getIntegerv( |
364 GLenum pname, | 365 GLenum pname, |
365 GLint* value) { | 366 GLint* value) { |
366 if (pname == GL_MAX_TEXTURE_SIZE) | 367 if (pname == GL_MAX_TEXTURE_SIZE) |
367 *value = max_texture_size_; | 368 *value = max_texture_size_; |
368 else if (pname == GL_ACTIVE_TEXTURE) | 369 else if (pname == GL_ACTIVE_TEXTURE) |
369 *value = GL_TEXTURE0; | 370 *value = GL_TEXTURE0; |
| 371 else if (pname == GL_UNPACK_ALIGNMENT) |
| 372 *value = unpack_alignment_; |
370 } | 373 } |
371 | 374 |
372 void TestWebGraphicsContext3D::getProgramiv(GLuint program, | 375 void TestWebGraphicsContext3D::getProgramiv(GLuint program, |
373 GLenum pname, | 376 GLenum pname, |
374 GLint* value) { | 377 GLint* value) { |
375 if (pname == GL_LINK_STATUS) | 378 if (pname == GL_LINK_STATUS) |
376 *value = 1; | 379 *value = 1; |
377 } | 380 } |
378 | 381 |
379 void TestWebGraphicsContext3D::getShaderiv(GLuint shader, | 382 void TestWebGraphicsContext3D::getShaderiv(GLuint shader, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 buffer->size = size; | 514 buffer->size = size; |
512 if (data != NULL) | 515 if (data != NULL) |
513 memcpy(buffer->pixels.get(), data, size); | 516 memcpy(buffer->pixels.get(), data, size); |
514 if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) | 517 if (buffer->target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) |
515 current_used_transfer_buffer_usage_bytes_ += buffer->size - old_size; | 518 current_used_transfer_buffer_usage_bytes_ += buffer->size - old_size; |
516 max_used_transfer_buffer_usage_bytes_ = | 519 max_used_transfer_buffer_usage_bytes_ = |
517 std::max(max_used_transfer_buffer_usage_bytes_, | 520 std::max(max_used_transfer_buffer_usage_bytes_, |
518 current_used_transfer_buffer_usage_bytes_); | 521 current_used_transfer_buffer_usage_bytes_); |
519 } | 522 } |
520 | 523 |
| 524 void TestWebGraphicsContext3D::pixelStorei(GLenum pname, GLint param) { |
| 525 switch (pname) { |
| 526 case GL_UNPACK_ALIGNMENT: |
| 527 // Param should be a power of two <= 8. |
| 528 EXPECT_EQ(0, param & (param - 1)); |
| 529 EXPECT_GE(8, param); |
| 530 switch (param) { |
| 531 case 1: |
| 532 case 2: |
| 533 case 4: |
| 534 case 8: |
| 535 unpack_alignment_ = param; |
| 536 break; |
| 537 default: |
| 538 break; |
| 539 } |
| 540 break; |
| 541 default: |
| 542 break; |
| 543 } |
| 544 } |
| 545 |
521 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, | 546 void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, |
522 GLenum access) { | 547 GLenum access) { |
523 base::AutoLock lock(namespace_->lock); | 548 base::AutoLock lock(namespace_->lock); |
524 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; | 549 base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers; |
525 DCHECK_GT(buffers.count(bound_buffer_), 0u); | 550 DCHECK_GT(buffers.count(bound_buffer_), 0u); |
526 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); | 551 DCHECK_EQ(target, buffers.get(bound_buffer_)->target); |
527 if (times_map_buffer_chromium_succeeds_ >= 0) { | 552 if (times_map_buffer_chromium_succeeds_ >= 0) { |
528 if (!times_map_buffer_chromium_succeeds_) { | 553 if (!times_map_buffer_chromium_succeeds_) { |
529 return NULL; | 554 return NULL; |
530 } | 555 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 738 |
714 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} | 739 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} |
715 | 740 |
716 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 741 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
717 | 742 |
718 TestWebGraphicsContext3D::Image::Image() {} | 743 TestWebGraphicsContext3D::Image::Image() {} |
719 | 744 |
720 TestWebGraphicsContext3D::Image::~Image() {} | 745 TestWebGraphicsContext3D::Image::~Image() {} |
721 | 746 |
722 } // namespace cc | 747 } // namespace cc |
OLD | NEW |