| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_impl.h" | 5 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 void MailboxManagerImpl::ProduceTexture(const Mailbox& mailbox, | 37 void MailboxManagerImpl::ProduceTexture(const Mailbox& mailbox, |
| 38 Texture* texture) { | 38 Texture* texture) { |
| 39 MailboxToTextureMap::iterator it = mailbox_to_textures_.find(mailbox); | 39 MailboxToTextureMap::iterator it = mailbox_to_textures_.find(mailbox); |
| 40 if (it != mailbox_to_textures_.end()) { | 40 if (it != mailbox_to_textures_.end()) { |
| 41 if (it->second->first == texture) | 41 if (it->second->first == texture) |
| 42 return; | 42 return; |
| 43 TextureToMailboxMap::iterator texture_it = it->second; | 43 TextureToMailboxMap::iterator texture_it = it->second; |
| 44 mailbox_to_textures_.erase(it); | 44 mailbox_to_textures_.erase(it); |
| 45 textures_to_mailboxes_.erase(texture_it); | 45 textures_to_mailboxes_.erase(texture_it); |
| 46 } | 46 } |
| 47 InsertTexture(mailbox, texture); | 47 if (texture) |
| 48 InsertTexture(mailbox, texture); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void MailboxManagerImpl::InsertTexture(const Mailbox& mailbox, | 51 void MailboxManagerImpl::InsertTexture(const Mailbox& mailbox, |
| 51 Texture* texture) { | 52 Texture* texture) { |
| 52 texture->SetMailboxManager(this); | 53 texture->SetMailboxManager(this); |
| 53 TextureToMailboxMap::iterator texture_it = | 54 TextureToMailboxMap::iterator texture_it = |
| 54 textures_to_mailboxes_.insert(std::make_pair(texture, mailbox)); | 55 textures_to_mailboxes_.insert(std::make_pair(texture, mailbox)); |
| 55 mailbox_to_textures_.insert(std::make_pair(mailbox, texture_it)); | 56 mailbox_to_textures_.insert(std::make_pair(mailbox, texture_it)); |
| 56 DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size()); | 57 DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size()); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void MailboxManagerImpl::TextureDeleted(Texture* texture) { | 60 void MailboxManagerImpl::TextureDeleted(Texture* texture) { |
| 60 std::pair<TextureToMailboxMap::iterator, | 61 std::pair<TextureToMailboxMap::iterator, |
| 61 TextureToMailboxMap::iterator> range = | 62 TextureToMailboxMap::iterator> range = |
| 62 textures_to_mailboxes_.equal_range(texture); | 63 textures_to_mailboxes_.equal_range(texture); |
| 63 for (TextureToMailboxMap::iterator it = range.first; | 64 for (TextureToMailboxMap::iterator it = range.first; |
| 64 it != range.second; ++it) { | 65 it != range.second; ++it) { |
| 65 size_t count = mailbox_to_textures_.erase(it->second); | 66 size_t count = mailbox_to_textures_.erase(it->second); |
| 66 DCHECK(count == 1); | 67 DCHECK(count == 1); |
| 67 } | 68 } |
| 68 textures_to_mailboxes_.erase(range.first, range.second); | 69 textures_to_mailboxes_.erase(range.first, range.second); |
| 69 DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size()); | 70 DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size()); |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace gles2 | 73 } // namespace gles2 |
| 73 } // namespace gpu | 74 } // namespace gpu |
| OLD | NEW |