| 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 #include "gpu/command_buffer/service/mailbox_manager.h" | 5 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "crypto/random.h" | 9 #include "crypto/random.h" |
| 10 #include "gpu/command_buffer/service/texture_manager.h" | 10 #include "gpu/command_buffer/service/texture_manager.h" |
| 11 | 11 |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 namespace gles2 { | 13 namespace gles2 { |
| 14 | 14 |
| 15 MailboxManager::MailboxManager() | 15 MailboxManager::MailboxManager() |
| 16 : mailbox_to_textures_(std::ptr_fun(&MailboxManager::TargetNameLess)) { | 16 : mailbox_to_textures_(std::ptr_fun(&MailboxManager::TargetNameLess)) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 MailboxManager::~MailboxManager() { | 19 MailboxManager::~MailboxManager() { |
| 20 DCHECK(mailbox_to_textures_.empty()); | 20 DCHECK(mailbox_to_textures_.empty()); |
| 21 DCHECK(textures_to_mailboxes_.empty()); | 21 DCHECK(textures_to_mailboxes_.empty()); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void MailboxManager::GenerateMailbox(Mailbox* mailbox) { | |
| 25 crypto::RandBytes(mailbox->name, sizeof(mailbox->name)); | |
| 26 } | |
| 27 | |
| 28 Texture* MailboxManager::ConsumeTexture(unsigned target, | 24 Texture* MailboxManager::ConsumeTexture(unsigned target, |
| 29 const Mailbox& mailbox) { | 25 const Mailbox& mailbox) { |
| 30 MailboxToTextureMap::iterator it = | 26 MailboxToTextureMap::iterator it = |
| 31 mailbox_to_textures_.find(TargetName(target, mailbox)); | 27 mailbox_to_textures_.find(TargetName(target, mailbox)); |
| 32 if (it == mailbox_to_textures_.end()) | 28 if (it == mailbox_to_textures_.end()) |
| 33 return NULL; | 29 return NULL; |
| 34 | 30 |
| 35 return it->second->first; | 31 return it->second->first; |
| 36 } | 32 } |
| 37 | 33 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 mailbox(mailbox) { | 66 mailbox(mailbox) { |
| 71 } | 67 } |
| 72 | 68 |
| 73 bool MailboxManager::TargetNameLess(const MailboxManager::TargetName& lhs, | 69 bool MailboxManager::TargetNameLess(const MailboxManager::TargetName& lhs, |
| 74 const MailboxManager::TargetName& rhs) { | 70 const MailboxManager::TargetName& rhs) { |
| 75 return memcmp(&lhs, &rhs, sizeof(lhs)) < 0; | 71 return memcmp(&lhs, &rhs, sizeof(lhs)) < 0; |
| 76 } | 72 } |
| 77 | 73 |
| 78 } // namespace gles2 | 74 } // namespace gles2 |
| 79 } // namespace gpu | 75 } // namespace gpu |
| OLD | NEW |