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