Index: gpu/command_buffer/service/mailbox_synchronizer.h |
diff --git a/gpu/command_buffer/service/mailbox_synchronizer.h b/gpu/command_buffer/service/mailbox_synchronizer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cc462e47e883c9afb52897b8e57999a74adc793d |
--- /dev/null |
+++ b/gpu/command_buffer/service/mailbox_synchronizer.h |
@@ -0,0 +1,83 @@ |
+// Copyright (c) 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. |
+ |
+#ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ |
+#define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ |
+ |
+#include "gpu/command_buffer/common/mailbox.h" |
+ |
+#include <map> |
+#include <set> |
+ |
+#include "base/memory/linked_ptr.h" |
+#include "base/synchronization/lock.h" |
+#include "gpu/command_buffer/service/texture_definition.h" |
+#include "gpu/gpu_export.h" |
+ |
+namespace gpu { |
+namespace gles2 { |
+ |
+class MailboxManager; |
+class Texture; |
+ |
+// A thread-safe proxy that can be used to emulate texture sharing across |
+// share-groups. |
+class MailboxSynchronizer { |
+ public: |
+ ~MailboxSynchronizer(); |
+ |
+ GPU_EXPORT static bool Initialize(); |
+ GPU_EXPORT static void Terminate(); |
+ static MailboxSynchronizer* GetInstance(); |
+ |
+ // Create a texture from a globally visible mailbox. |
+ Texture* CreateTextureFromMailbox(MailboxManager* manager, |
+ unsigned target, |
+ const Mailbox& mailbox); |
+ |
+ void PushTextureUpdates(MailboxManager* manager); |
+ void PullTextureUpdates(MailboxManager* manager); |
+ |
+ void TextureDeleted(MailboxManager* manager, |
+ unsigned target, |
+ const Mailbox& mailbox); |
+ |
+ private: |
+ MailboxSynchronizer(); |
+ |
+ struct TargetName { |
+ TargetName(unsigned target, const Mailbox& mailbox); |
+ bool operator<(const TargetName& rhs) const { |
+ return memcmp(this, &rhs, sizeof(rhs)) < 0; |
+ } |
+ bool operator!=(const TargetName& rhs) const { |
+ return memcmp(this, &rhs, sizeof(rhs)) != 0; |
+ } |
+ unsigned target; |
+ Mailbox mailbox; |
+ }; |
+ |
+ base::Lock lock_; |
+ |
+ struct GlobalMailbox { |
+ GlobalMailbox(const TextureDefinition& definition) |
piman
2014/03/08 01:03:11
nit: explicit
no sievers
2014/03/12 18:45:36
Done.
|
+ : definition(definition) {} |
+ TextureDefinition definition; |
+ std::set<MailboxManager*> refs; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(GlobalMailbox); |
+ }; |
+ typedef std::map<TargetName, linked_ptr<GlobalMailbox> > MailboxMap; |
+ |
+ MailboxMap mailboxes_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MailboxSynchronizer); |
+}; |
+ |
+} // namespage gles2 |
+} // namespace gpu |
+ |
+#endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ |
+ |