| 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "gpu/command_buffer/common/constants.h" | 14 #include "gpu/command_buffer/common/constants.h" |
| 15 #include "gpu/command_buffer/common/mailbox.h" | 15 #include "gpu/command_buffer/common/mailbox.h" |
| 16 #include "gpu/command_buffer/service/mailbox_manager.h" | 16 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 17 #include "gpu/command_buffer/service/texture_definition.h" | 17 #include "gpu/command_buffer/service/texture_definition.h" |
| 18 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
| 19 | 19 |
| 20 namespace gpu { | 20 namespace gpu { |
| 21 namespace gles2 { | 21 namespace gles2 { |
| 22 | 22 |
| 23 class Texture; | 23 class TextureBase; |
| 24 class TextureManager; | 24 class TextureManager; |
| 25 | 25 |
| 26 // Manages resources scoped beyond the context or context group level | 26 // Manages resources scoped beyond the context or context group level |
| 27 // and across threads and driver level share groups by synchronizing | 27 // and across threads and driver level share groups by synchronizing |
| 28 // texture state. | 28 // texture state. |
| 29 class GPU_EXPORT MailboxManagerSync : public MailboxManager { | 29 class GPU_EXPORT MailboxManagerSync : public MailboxManager { |
| 30 public: | 30 public: |
| 31 MailboxManagerSync(); | 31 MailboxManagerSync(); |
| 32 | 32 |
| 33 // MailboxManager implementation: | 33 // MailboxManager implementation: |
| 34 Texture* ConsumeTexture(const Mailbox& mailbox) override; | 34 TextureBase* ConsumeTexture(const Mailbox& mailbox) override; |
| 35 void ProduceTexture(const Mailbox& mailbox, Texture* texture) override; | 35 void ProduceTexture(const Mailbox& mailbox, TextureBase* texture) override; |
| 36 bool UsesSync() override; | 36 bool UsesSync() override; |
| 37 void PushTextureUpdates(const SyncToken& token) override; | 37 void PushTextureUpdates(const SyncToken& token) override; |
| 38 void PullTextureUpdates(const SyncToken& token) override; | 38 void PullTextureUpdates(const SyncToken& token) override; |
| 39 void TextureDeleted(Texture* texture) override; | 39 void TextureDeleted(TextureBase* texture) override; |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 friend class base::RefCounted<MailboxManager>; | 42 friend class base::RefCounted<MailboxManager>; |
| 43 | 43 |
| 44 static bool SkipTextureWorkarounds(const Texture* texture); | 44 static bool SkipTextureWorkarounds(const Texture* texture); |
| 45 | 45 |
| 46 ~MailboxManagerSync() override; | 46 ~MailboxManagerSync() override; |
| 47 | 47 |
| 48 class TextureGroup : public base::RefCounted<TextureGroup> { | 48 class TextureGroup : public base::RefCounted<TextureGroup> { |
| 49 public: | 49 public: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 77 static base::LazyInstance<MailboxToGroupMap> mailbox_to_group_; | 77 static base::LazyInstance<MailboxToGroupMap> mailbox_to_group_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 struct TextureGroupRef { | 80 struct TextureGroupRef { |
| 81 TextureGroupRef(unsigned version, TextureGroup* group); | 81 TextureGroupRef(unsigned version, TextureGroup* group); |
| 82 TextureGroupRef(const TextureGroupRef& other); | 82 TextureGroupRef(const TextureGroupRef& other); |
| 83 ~TextureGroupRef(); | 83 ~TextureGroupRef(); |
| 84 unsigned version; | 84 unsigned version; |
| 85 scoped_refptr<TextureGroup> group; | 85 scoped_refptr<TextureGroup> group; |
| 86 }; | 86 }; |
| 87 static void UpdateDefinitionLocked(Texture* texture, | 87 static void UpdateDefinitionLocked(TextureBase* texture, |
| 88 TextureGroupRef* group_ref); | 88 TextureGroupRef* group_ref); |
| 89 | 89 |
| 90 typedef std::map<Texture*, TextureGroupRef> TextureToGroupMap; | 90 typedef std::map<Texture*, TextureGroupRef> TextureToGroupMap; |
| 91 TextureToGroupMap texture_to_group_; | 91 TextureToGroupMap texture_to_group_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(MailboxManagerSync); | 93 DISALLOW_COPY_AND_ASSIGN(MailboxManagerSync); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespage gles2 | 96 } // namespage gles2 |
| 97 } // namespace gpu | 97 } // namespace gpu |
| 98 | 98 |
| 99 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_ | 99 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_SYNC_H_ |
| 100 | 100 |
| OLD | NEW |