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

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

Issue 180723023: gpu: Mailbox emulation with EGLImage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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.cc
diff --git a/gpu/command_buffer/service/mailbox_manager.cc b/gpu/command_buffer/service/mailbox_manager.cc
index c337b483929bb7dea5f70ec13ba98c382afcbe37..74cb6968f7752d9c73fc6905cdb8403bb17fae45 100644
--- a/gpu/command_buffer/service/mailbox_manager.cc
+++ b/gpu/command_buffer/service/mailbox_manager.cc
@@ -7,13 +7,15 @@
#include <algorithm>
#include "crypto/random.h"
+#include "gpu/command_buffer/service/mailbox_synchronizer.h"
#include "gpu/command_buffer/service/texture_manager.h"
namespace gpu {
namespace gles2 {
MailboxManager::MailboxManager()
- : mailbox_to_textures_(std::ptr_fun(&MailboxManager::TargetNameLess)) {
+ : mailbox_to_textures_(std::ptr_fun(&MailboxManager::TargetNameLess)),
+ sync_(MailboxSynchronizer::GetInstance()) {
piman 2014/03/08 01:03:11 nit: it'd be nice to pass explicitly to avoid one
no sievers 2014/03/12 18:45:36 I still need to do this.
}
MailboxManager::~MailboxManager() {
@@ -23,25 +25,43 @@ MailboxManager::~MailboxManager() {
Texture* MailboxManager::ConsumeTexture(unsigned target,
const Mailbox& mailbox) {
+ TargetName target_name(target, mailbox);
MailboxToTextureMap::iterator it =
- mailbox_to_textures_.find(TargetName(target, mailbox));
- if (it == mailbox_to_textures_.end())
- return NULL;
+ mailbox_to_textures_.find(target_name);
+ if (it != mailbox_to_textures_.end())
+ return it->second->first;
+
+ if (sync_) {
+ // See if it's visible in another mailbox manager, and if so make it visible
+ // here too.
+ Texture* texture = sync_->CreateTextureFromMailbox(this, target, mailbox);
+ if (texture) {
+ InsertTexture(target_name, texture);
+ DCHECK_EQ(0U, texture->refs_.size()); // TODO
+ }
+ return texture;
+ }
- return it->second->first;
+ return NULL;
}
void MailboxManager::ProduceTexture(unsigned target,
const Mailbox& mailbox,
Texture* texture) {
- texture->SetMailboxManager(this);
TargetName target_name(target, mailbox);
MailboxToTextureMap::iterator it = mailbox_to_textures_.find(target_name);
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(target_name, texture);
+}
+
+void MailboxManager::InsertTexture(TargetName target_name, Texture* texture) {
+ texture->SetMailboxManager(this);
TextureToMailboxMap::iterator texture_it =
textures_to_mailboxes_.insert(std::make_pair(texture, target_name));
mailbox_to_textures_.insert(std::make_pair(target_name, texture_it));
@@ -54,6 +74,9 @@ void MailboxManager::TextureDeleted(Texture* texture) {
textures_to_mailboxes_.equal_range(texture);
for (TextureToMailboxMap::iterator it = range.first;
it != range.second; ++it) {
+ if (sync_) {
+ sync_->TextureDeleted(this, it->second.target, it->second.mailbox);
+ }
size_t count = mailbox_to_textures_.erase(it->second);
DCHECK(count == 1);
}
@@ -61,6 +84,16 @@ void MailboxManager::TextureDeleted(Texture* texture) {
DCHECK_EQ(mailbox_to_textures_.size(), textures_to_mailboxes_.size());
}
+void MailboxManager::PushTextureUpdates() {
+ if (sync_)
+ sync_->PushTextureUpdates(this);
+}
+
+void MailboxManager::PullTextureUpdates() {
+ if (sync_)
+ sync_->PullTextureUpdates(this);
+}
+
MailboxManager::TargetName::TargetName(unsigned target, const Mailbox& mailbox)
: target(target),
mailbox(mailbox) {

Powered by Google App Engine
This is Rietveld 408576698