OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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_DISPLAY_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_DISPLAY_H_ |
| 7 |
| 8 #include <queue> |
| 9 |
| 10 #include "base/hash_tables.h" |
| 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "gpu/command_buffer/common/constants.h" |
| 14 #include "gpu/gpu_export.h" |
| 15 |
| 16 namespace gpu { |
| 17 namespace gles2 { |
| 18 |
| 19 class TextureDefinition; |
| 20 class TextureManager; |
| 21 |
| 22 // Identified a mailbox where a texture definition can be stored for sharing |
| 23 // transferring between contexts that are not in the same context group. It is |
| 24 // generally a large random number. |
| 25 struct MailboxName { |
| 26 char components[kMailboxSize]; |
| 27 }; |
| 28 |
| 29 // Manages resources scoped beyond the context or context group level. |
| 30 class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> { |
| 31 public: |
| 32 MailboxManager(); |
| 33 |
| 34 // Remove the texture definition from the named mailbox and empty the mailbox. |
| 35 TextureDefinition* ConsumeTexture(unsigned target, const MailboxName& name); |
| 36 |
| 37 // Put the texture definition in the named mailbox. |
| 38 void ProduceTexture(unsigned target, |
| 39 const MailboxName& name, |
| 40 TextureDefinition* definition, |
| 41 TextureManager* owner); |
| 42 |
| 43 // Destroy any texture definitions and mailboxes owned by the given texture |
| 44 // manager. |
| 45 void DestroyOwnedTextures(TextureManager* owner, bool have_context); |
| 46 |
| 47 private: |
| 48 friend class base::RefCounted<MailboxManager>; |
| 49 |
| 50 struct TargetName { |
| 51 TargetName(unsigned target, const MailboxName& name); |
| 52 unsigned target; |
| 53 MailboxName name; |
| 54 }; |
| 55 |
| 56 struct TargetNameCompare { |
| 57 enum { |
| 58 bucket_size = 4, |
| 59 min_buckets = 8 |
| 60 }; |
| 61 size_t operator() (const TargetName& key) const; |
| 62 int operator() (const TargetName& lhs, const TargetName& rhs) const; |
| 63 }; |
| 64 |
| 65 struct OwnedTextureDefinition { |
| 66 OwnedTextureDefinition(TextureDefinition* definition, |
| 67 TextureManager* owner); |
| 68 linked_ptr<TextureDefinition> definition; |
| 69 TextureManager* owner; |
| 70 }; |
| 71 |
| 72 typedef base::hash_map<TargetName, OwnedTextureDefinition, TargetNameCompare> |
| 73 TextureDefinitionMap; |
| 74 |
| 75 ~MailboxManager(); |
| 76 |
| 77 TextureDefinitionMap textures_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(MailboxManager); |
| 80 }; |
| 81 } // namespage gles2 |
| 82 } // namespace gpu |
| 83 |
| 84 #endif // GPU_COMMAND_BUFFER_SERVICE_DISPLAY_H_ |
| 85 |
| 86 |
OLD | NEW |