Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ | |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ | |
| 7 | |
| 8 #include "gpu/command_buffer/common/mailbox.h" | |
| 9 | |
| 10 #include <map> | |
| 11 #include <set> | |
| 12 | |
| 13 #include "base/memory/linked_ptr.h" | |
| 14 #include "base/synchronization/lock.h" | |
| 15 #include "gpu/command_buffer/service/texture_definition.h" | |
| 16 #include "gpu/gpu_export.h" | |
| 17 | |
| 18 namespace gpu { | |
| 19 namespace gles2 { | |
| 20 | |
| 21 class MailboxManager; | |
| 22 class Texture; | |
| 23 | |
| 24 // A thread-safe proxy that can be used to emulate texture sharing across | |
| 25 // share-groups. | |
| 26 class MailboxSynchronizer { | |
| 27 public: | |
| 28 ~MailboxSynchronizer(); | |
| 29 | |
| 30 GPU_EXPORT static bool Initialize(); | |
| 31 GPU_EXPORT static void Terminate(); | |
| 32 static MailboxSynchronizer* GetInstance(); | |
| 33 | |
| 34 // Create a texture from a globally visible mailbox. | |
| 35 Texture* CreateTextureFromMailbox(MailboxManager* manager, | |
| 36 unsigned target, | |
| 37 const Mailbox& mailbox); | |
| 38 | |
| 39 void PushTextureUpdates(MailboxManager* manager); | |
| 40 void PullTextureUpdates(MailboxManager* manager); | |
| 41 | |
| 42 void TextureDeleted(MailboxManager* manager, | |
| 43 unsigned target, | |
| 44 const Mailbox& mailbox); | |
| 45 | |
| 46 private: | |
| 47 MailboxSynchronizer(); | |
| 48 | |
| 49 struct TargetName { | |
| 50 TargetName(unsigned target, const Mailbox& mailbox); | |
| 51 bool operator<(const TargetName& rhs) const { | |
| 52 return memcmp(this, &rhs, sizeof(rhs)) < 0; | |
| 53 } | |
| 54 bool operator!=(const TargetName& rhs) const { | |
| 55 return memcmp(this, &rhs, sizeof(rhs)) != 0; | |
| 56 } | |
| 57 unsigned target; | |
| 58 Mailbox mailbox; | |
| 59 }; | |
| 60 | |
| 61 base::Lock lock_; | |
| 62 | |
| 63 struct GlobalMailbox { | |
| 64 GlobalMailbox(const TextureDefinition& definition) | |
|
piman
2014/03/08 01:03:11
nit: explicit
no sievers
2014/03/12 18:45:36
Done.
| |
| 65 : definition(definition) {} | |
| 66 TextureDefinition definition; | |
| 67 std::set<MailboxManager*> refs; | |
| 68 | |
| 69 private: | |
| 70 DISALLOW_COPY_AND_ASSIGN(GlobalMailbox); | |
| 71 }; | |
| 72 typedef std::map<TargetName, linked_ptr<GlobalMailbox> > MailboxMap; | |
| 73 | |
| 74 MailboxMap mailboxes_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(MailboxSynchronizer); | |
| 77 }; | |
| 78 | |
| 79 } // namespage gles2 | |
| 80 } // namespace gpu | |
| 81 | |
| 82 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_SYNCHRONIZER_H_ | |
| 83 | |
| OLD | NEW |