Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Unified Diff: gpu/command_buffer/service/mailbox_manager_impl.cc

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/mailbox_manager_impl.cc
diff --git a/gpu/command_buffer/service/mailbox_manager_impl.cc b/gpu/command_buffer/service/mailbox_manager_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db7b4c20fafbda98c06f1c7b8ea97cac1e385449
--- /dev/null
+++ b/gpu/command_buffer/service/mailbox_manager_impl.cc
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/service/mailbox_manager_impl.h"
+
+#include <algorithm>
+
+#include "gpu/command_buffer/service/texture_manager.h"
+
+namespace gpu {
+namespace gles2 {
+
+MailboxManagerImpl::MailboxManagerImpl() {
+}
+
+MailboxManagerImpl::~MailboxManagerImpl() {
+ DCHECK(mailbox_to_textures_.empty());
+ DCHECK(textures_to_mailboxes_.empty());
+}
+
+bool MailboxManagerImpl::UsesSync() {
+ return false;
+}
+
+Texture* MailboxManagerImpl::ConsumeTexture(const Mailbox& mailbox) {
+ MailboxToTextureMap::iterator it =
+ mailbox_to_textures_.find(mailbox);
+ if (it != mailbox_to_textures_.end())
+ return it->second->first;
+
+ return NULL;
+}
+
+void MailboxManagerImpl::ProduceTexture(const Mailbox& mailbox,
+ Texture* texture) {
+ MailboxToTextureMap::iterator it = mailbox_to_textures_.find(mailbox);
+ if (it != mailbox_to_textures_.end()) {
+ if (it->second->first == texture)
+ return;
+ TextureToMailboxMap::iterator texture_it = it->second;
+ mailbox_to_textures_.erase(it);
+ textures_to_mailboxes_.erase(texture_it);
+ }
+ InsertTexture(mailbox, texture);
+}
+
+void MailboxManagerImpl::InsertTexture(const Mailbox& mailbox,
+ Texture* texture) {
+ texture->SetMailboxManager(this);
+ TextureToMailboxMap::iterator texture_it =
+ textures_to_mailboxes_.insert(std::make_pair(texture, mailbox));
+ mailbox_to_textures_.insert(std::make_pair(mailbox, texture_it));
+ DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size());
+}
+
+void MailboxManagerImpl::TextureDeleted(Texture* texture) {
+ std::pair<TextureToMailboxMap::iterator,
+ TextureToMailboxMap::iterator> range =
+ textures_to_mailboxes_.equal_range(texture);
+ for (TextureToMailboxMap::iterator it = range.first;
+ it != range.second; ++it) {
+ size_t count = mailbox_to_textures_.erase(it->second);
+ DCHECK(count == 1);
+ }
+ textures_to_mailboxes_.erase(range.first, range.second);
+ DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size());
+}
+
+} // namespace gles2
+} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_impl.h ('k') | gpu/command_buffer/service/mailbox_manager_sync.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698