Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: gpu/command_buffer/service/mailbox_manager.h

Issue 10106015: Allow textures to be moved from one GL context group to another. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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_MAILBOX_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
7
8 #include "base/hash_tables.h"
9 #include "base/memory/linked_ptr.h"
10 #include "base/memory/ref_counted.h"
11 #include "gpu/command_buffer/common/constants.h"
12 #include "gpu/gpu_export.h"
13
14 namespace gpu {
15 namespace gles2 {
16
17 class TextureDefinition;
18 class TextureManager;
19
20 // Identifies a mailbox where a texture definition can be stored for sharing
21 // transferring between contexts that are not in the same context group. It is
Ken Russell (switch to Gerrit) 2012/04/26 22:34:14 "sharing transferring" -> "transferring textures"?
apatrick_chromium 2012/04/27 22:31:58 Done.
22 // generally a large random number.
23 struct MailboxName {
24 GLbyte key[GL_MAILBOX_SIZE_CHROMIUM / 2];
25 GLbyte signature[GL_MAILBOX_SIZE_CHROMIUM / 2];
26 };
27
28 // Manages resources scoped beyond the context or context group level.
29 class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
30 public:
31 MailboxManager();
32
33 // Generate a unique signed mailbox name.
34 void GenerateMailboxName(MailboxName* name);
35
36 // Remove the texture definition from the named mailbox and empty the mailbox.
37 TextureDefinition* ConsumeTexture(unsigned target, const MailboxName& name);
38
39 // Put the texture definition in the named mailbox.
40 bool ProduceTexture(unsigned target,
41 const MailboxName& name,
42 TextureDefinition* definition,
43 TextureManager* owner);
44
45 // Destroy any texture definitions and mailboxes owned by the given texture
46 // manager.
47 void DestroyOwnedTextures(TextureManager* owner, bool have_context);
48
49 private:
50 friend class base::RefCounted<MailboxManager>;
51
52 ~MailboxManager();
53
54 void SignMailboxName(MailboxName* name);
55 bool IsMailboxNameValid(const MailboxName& name);
56
57 struct TargetName {
58 TargetName(unsigned target, const MailboxName& name);
59 unsigned target;
60 MailboxName name;
61 };
62
63 struct TargetNameCompare {
64 enum {
65 bucket_size = 4,
66 min_buckets = 8
67 };
68 size_t operator() (const TargetName& key) const;
69 int operator() (const TargetName& lhs, const TargetName& rhs) const;
70 };
71
72 struct OwnedTextureDefinition {
73 OwnedTextureDefinition(TextureDefinition* definition,
74 TextureManager* owner);
75 ~OwnedTextureDefinition();
76 linked_ptr<TextureDefinition> definition;
77 TextureManager* owner;
78 };
79
80 typedef base::hash_map<TargetName, OwnedTextureDefinition, TargetNameCompare>
81 TextureDefinitionMap;
82
83 GLbyte private_key_[GL_MAILBOX_SIZE_CHROMIUM / 2];
84 TextureDefinitionMap textures_;
85
86 DISALLOW_COPY_AND_ASSIGN(MailboxManager);
87 };
88 } // namespage gles2
89 } // namespace gpu
90
91 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
92
93
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698