| 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 the Command Buffer Helper. | 5 // Tests for the Command Buffer Helper. |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // Override CommandBufferService::Flush() to lock flushing and simulate | 39 // Override CommandBufferService::Flush() to lock flushing and simulate |
| 40 // the buffer becoming full in asynchronous mode. | 40 // the buffer becoming full in asynchronous mode. |
| 41 class CommandBufferServiceLocked : public CommandBufferService { | 41 class CommandBufferServiceLocked : public CommandBufferService { |
| 42 public: | 42 public: |
| 43 explicit CommandBufferServiceLocked( | 43 explicit CommandBufferServiceLocked( |
| 44 TransferBufferManagerInterface* transfer_buffer_manager) | 44 TransferBufferManagerInterface* transfer_buffer_manager) |
| 45 : CommandBufferService(transfer_buffer_manager), | 45 : CommandBufferService(transfer_buffer_manager), |
| 46 flush_locked_(false), | 46 flush_locked_(false), |
| 47 last_flush_(-1), | 47 last_flush_(-1), |
| 48 flush_count_(0) {} | 48 flush_count_(0) {} |
| 49 virtual ~CommandBufferServiceLocked() {} | 49 ~CommandBufferServiceLocked() override {} |
| 50 | 50 |
| 51 virtual void Flush(int32 put_offset) override { | 51 void Flush(int32 put_offset) override { |
| 52 flush_count_++; | 52 flush_count_++; |
| 53 if (!flush_locked_) { | 53 if (!flush_locked_) { |
| 54 last_flush_ = -1; | 54 last_flush_ = -1; |
| 55 CommandBufferService::Flush(put_offset); | 55 CommandBufferService::Flush(put_offset); |
| 56 } else { | 56 } else { |
| 57 last_flush_ = put_offset; | 57 last_flush_ = put_offset; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 void LockFlush() { flush_locked_ = true; } | 61 void LockFlush() { flush_locked_ = true; } |
| 62 | 62 |
| 63 void UnlockFlush() { flush_locked_ = false; } | 63 void UnlockFlush() { flush_locked_ = false; } |
| 64 | 64 |
| 65 int FlushCount() { return flush_count_; } | 65 int FlushCount() { return flush_count_; } |
| 66 | 66 |
| 67 virtual void WaitForGetOffsetInRange(int32 start, int32 end) override { | 67 void WaitForGetOffsetInRange(int32 start, int32 end) override { |
| 68 if (last_flush_ != -1) { | 68 if (last_flush_ != -1) { |
| 69 CommandBufferService::Flush(last_flush_); | 69 CommandBufferService::Flush(last_flush_); |
| 70 last_flush_ = -1; | 70 last_flush_ = -1; |
| 71 } | 71 } |
| 72 CommandBufferService::WaitForGetOffsetInRange(start, end); | 72 CommandBufferService::WaitForGetOffsetInRange(start, end); |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 bool flush_locked_; | 76 bool flush_locked_; |
| 77 int last_flush_; | 77 int last_flush_; |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 helper_->Finish(); | 703 helper_->Finish(); |
| 704 | 704 |
| 705 // Check that the commands did happen. | 705 // Check that the commands did happen. |
| 706 Mock::VerifyAndClearExpectations(api_mock_.get()); | 706 Mock::VerifyAndClearExpectations(api_mock_.get()); |
| 707 | 707 |
| 708 // Check the error status. | 708 // Check the error status. |
| 709 EXPECT_EQ(error::kNoError, GetError()); | 709 EXPECT_EQ(error::kNoError, GetError()); |
| 710 } | 710 } |
| 711 | 711 |
| 712 } // namespace gpu | 712 } // namespace gpu |
| OLD | NEW |