| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual ~MockTransferBuffer() { } | 117 virtual ~MockTransferBuffer() { } |
| 118 | 118 |
| 119 virtual bool Initialize( | 119 virtual bool Initialize( |
| 120 unsigned int starting_buffer_size, | 120 unsigned int starting_buffer_size, |
| 121 unsigned int result_size, | 121 unsigned int result_size, |
| 122 unsigned int /* min_buffer_size */, | 122 unsigned int /* min_buffer_size */, |
| 123 unsigned int /* max_buffer_size */, | 123 unsigned int /* max_buffer_size */, |
| 124 unsigned int alignment, | 124 unsigned int alignment, |
| 125 unsigned int size_to_flush) OVERRIDE; | 125 unsigned int size_to_flush) override; |
| 126 virtual int GetShmId() OVERRIDE; | 126 virtual int GetShmId() override; |
| 127 virtual void* GetResultBuffer() OVERRIDE; | 127 virtual void* GetResultBuffer() override; |
| 128 virtual int GetResultOffset() OVERRIDE; | 128 virtual int GetResultOffset() override; |
| 129 virtual void Free() OVERRIDE; | 129 virtual void Free() override; |
| 130 virtual bool HaveBuffer() const OVERRIDE; | 130 virtual bool HaveBuffer() const override; |
| 131 virtual void* AllocUpTo( | 131 virtual void* AllocUpTo( |
| 132 unsigned int size, unsigned int* size_allocated) OVERRIDE; | 132 unsigned int size, unsigned int* size_allocated) override; |
| 133 virtual void* Alloc(unsigned int size) OVERRIDE; | 133 virtual void* Alloc(unsigned int size) override; |
| 134 virtual RingBuffer::Offset GetOffset(void* pointer) const OVERRIDE; | 134 virtual RingBuffer::Offset GetOffset(void* pointer) const override; |
| 135 virtual void FreePendingToken(void* p, unsigned int /* token */) OVERRIDE; | 135 virtual void FreePendingToken(void* p, unsigned int /* token */) override; |
| 136 | 136 |
| 137 size_t MaxTransferBufferSize() { | 137 size_t MaxTransferBufferSize() { |
| 138 return size_ - result_size_; | 138 return size_ - result_size_; |
| 139 } | 139 } |
| 140 | 140 |
| 141 unsigned int RoundToAlignment(unsigned int size) { | 141 unsigned int RoundToAlignment(unsigned int size) { |
| 142 return (size + alignment_ - 1) & ~(alignment_ - 1); | 142 return (size + alignment_ - 1) & ~(alignment_ - 1); |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool InSync() { | 145 bool InSync() { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 scoped_ptr<MockClientGpuControl> gpu_control_; | 499 scoped_ptr<MockClientGpuControl> gpu_control_; |
| 500 scoped_ptr<GLES2CmdHelper> helper_; | 500 scoped_ptr<GLES2CmdHelper> helper_; |
| 501 scoped_ptr<MockTransferBuffer> transfer_buffer_; | 501 scoped_ptr<MockTransferBuffer> transfer_buffer_; |
| 502 scoped_ptr<GLES2Implementation> gl_; | 502 scoped_ptr<GLES2Implementation> gl_; |
| 503 CommandBufferEntry* commands_; | 503 CommandBufferEntry* commands_; |
| 504 int token_; | 504 int token_; |
| 505 }; | 505 }; |
| 506 | 506 |
| 507 GLES2ImplementationTest() : commands_(NULL) {} | 507 GLES2ImplementationTest() : commands_(NULL) {} |
| 508 | 508 |
| 509 virtual void SetUp() OVERRIDE; | 509 virtual void SetUp() override; |
| 510 virtual void TearDown() OVERRIDE; | 510 virtual void TearDown() override; |
| 511 | 511 |
| 512 bool NoCommandsWritten() { | 512 bool NoCommandsWritten() { |
| 513 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); | 513 scoped_refptr<Buffer> ring_buffer = helper_->get_ring_buffer(); |
| 514 const uint8* cmds = reinterpret_cast<const uint8*>(ring_buffer->memory()); | 514 const uint8* cmds = reinterpret_cast<const uint8*>(ring_buffer->memory()); |
| 515 const uint8* end = cmds + ring_buffer->size(); | 515 const uint8* end = cmds + ring_buffer->size(); |
| 516 for (; cmds < end; ++cmds) { | 516 for (; cmds < end; ++cmds) { |
| 517 if (*cmds != kInitialValue) { | 517 if (*cmds != kInitialValue) { |
| 518 return false; | 518 return false; |
| 519 } | 519 } |
| 520 } | 520 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 ASSERT_TRUE(Initialize(init_options)); | 623 ASSERT_TRUE(Initialize(init_options)); |
| 624 } | 624 } |
| 625 | 625 |
| 626 void GLES2ImplementationTest::TearDown() { | 626 void GLES2ImplementationTest::TearDown() { |
| 627 for (int i = 0; i < kNumTestContexts; i++) | 627 for (int i = 0; i < kNumTestContexts; i++) |
| 628 test_contexts_[i].TearDown(); | 628 test_contexts_[i].TearDown(); |
| 629 } | 629 } |
| 630 | 630 |
| 631 class GLES2ImplementationManualInitTest : public GLES2ImplementationTest { | 631 class GLES2ImplementationManualInitTest : public GLES2ImplementationTest { |
| 632 protected: | 632 protected: |
| 633 virtual void SetUp() OVERRIDE {} | 633 virtual void SetUp() override {} |
| 634 }; | 634 }; |
| 635 | 635 |
| 636 class GLES2ImplementationStrictSharedTest : public GLES2ImplementationTest { | 636 class GLES2ImplementationStrictSharedTest : public GLES2ImplementationTest { |
| 637 protected: | 637 protected: |
| 638 virtual void SetUp() OVERRIDE; | 638 virtual void SetUp() override; |
| 639 | 639 |
| 640 template <class ResApi> | 640 template <class ResApi> |
| 641 void FlushGenerationTest() { | 641 void FlushGenerationTest() { |
| 642 GLuint id1, id2, id3; | 642 GLuint id1, id2, id3; |
| 643 | 643 |
| 644 // Generate valid id. | 644 // Generate valid id. |
| 645 ResApi::Gen(gl_, 1, &id1); | 645 ResApi::Gen(gl_, 1, &id1); |
| 646 EXPECT_NE(id1, 0u); | 646 EXPECT_NE(id1, 0u); |
| 647 | 647 |
| 648 // Delete id1 and generate id2. id1 should not be reused. | 648 // Delete id1 and generate id2. id1 should not be reused. |
| (...skipping 2756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3405 ContextInitOptions init_options; | 3405 ContextInitOptions init_options; |
| 3406 init_options.bind_generates_resource_client = true; | 3406 init_options.bind_generates_resource_client = true; |
| 3407 init_options.bind_generates_resource_service = false; | 3407 init_options.bind_generates_resource_service = false; |
| 3408 EXPECT_FALSE(Initialize(init_options)); | 3408 EXPECT_FALSE(Initialize(init_options)); |
| 3409 } | 3409 } |
| 3410 | 3410 |
| 3411 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3411 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 3412 | 3412 |
| 3413 } // namespace gles2 | 3413 } // namespace gles2 |
| 3414 } // namespace gpu | 3414 } // namespace gpu |
| OLD | NEW |