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

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 <functional>
9 #include <map>
10
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/ref_counted.h"
13 #include "crypto/hmac.h"
14 #include "gpu/command_buffer/common/constants.h"
15 #include "gpu/gpu_export.h"
16
17 // From gl2/gl2ext.h.
18 #ifndef GL_MAILBOX_SIZE_CHROMIUM
19 #define GL_MAILBOX_SIZE_CHROMIUM 64
20 #endif
21
22 typedef signed char GLbyte;
23
24 namespace gpu {
25 namespace gles2 {
26
27 class TextureDefinition;
28 class TextureManager;
29
30 // Identifies a mailbox where a texture definition can be stored for
31 // transferring textures between contexts that are not in the same context
32 // group. It is a random key signed with a hash of a private key.
33 struct MailboxName {
34 GLbyte key[GL_MAILBOX_SIZE_CHROMIUM / 2];
35 GLbyte signature[GL_MAILBOX_SIZE_CHROMIUM / 2];
36 };
37
38 // Manages resources scoped beyond the context or context group level.
39 class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
40 public:
41 MailboxManager();
42
43 // Generate a unique mailbox name signed with the manager's private key.
44 void GenerateMailboxName(MailboxName* name);
45
46 // Remove the texture definition from the named mailbox and empty the mailbox.
47 TextureDefinition* ConsumeTexture(unsigned target, const MailboxName& name);
48
49 // Put the texture definition in the named mailbox.
50 bool ProduceTexture(unsigned target,
51 const MailboxName& name,
52 TextureDefinition* definition,
53 TextureManager* owner);
54
55 // Destroy any texture definitions and mailboxes owned by the given texture
56 // manager.
57 void DestroyOwnedTextures(TextureManager* owner, bool have_context);
58
59 private:
60 friend class base::RefCounted<MailboxManager>;
61
62 ~MailboxManager();
63
64 void SignMailboxName(MailboxName* name);
65 bool IsMailboxNameValid(const MailboxName& name);
66
67 struct TargetName {
68 TargetName(unsigned target, const MailboxName& name);
69 unsigned target;
70 MailboxName name;
71 };
72
73 static bool TargetNameLess(TargetName lhs, TargetName rhs);
74
75 struct OwnedTextureDefinition {
76 OwnedTextureDefinition(TextureDefinition* definition,
77 TextureManager* owner);
78 ~OwnedTextureDefinition();
79 linked_ptr<TextureDefinition> definition;
80 TextureManager* owner;
81 };
82
83 typedef std::map<
84 TargetName,
85 OwnedTextureDefinition,
86 std::pointer_to_binary_function<TargetName, TargetName, bool> >
87 TextureDefinitionMap;
88
89 crypto::HMAC hmac_;
90 TextureDefinitionMap textures_;
91
92 DISALLOW_COPY_AND_ASSIGN(MailboxManager);
93 };
94 } // namespage gles2
95 } // namespace gpu
96
97 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
98
99
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | gpu/command_buffer/service/mailbox_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698