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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_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/command_buffer/common/mailbox.h"
15 #include "gpu/gpu_export.h"
17 typedef signed char GLbyte;
25 // Manages resources scoped beyond the context or context group level.
26 class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
30 // Look up the texture definition from the named mailbox.
31 Texture* ConsumeTexture(unsigned target, const Mailbox& mailbox);
33 // Put the texture into the named mailbox.
34 void ProduceTexture(unsigned target,
35 const Mailbox& mailbox,
38 // Destroy any mailbox that reference the given texture.
39 void TextureDeleted(Texture* texture);
42 friend class base::RefCounted<MailboxManager>;
47 TargetName(unsigned target, const Mailbox& mailbox);
52 static bool TargetNameLess(const TargetName& lhs, const TargetName& rhs);
54 // This is a bidirectional map between mailbox and textures. We can have
55 // multiple mailboxes per texture, but one texture per mailbox. We keep an
56 // iterator in the MailboxToTextureMap to be able to manage changes to
57 // the TextureToMailboxMap efficiently.
58 typedef std::multimap<Texture*, TargetName> TextureToMailboxMap;
59 typedef std::map<TargetName,
60 TextureToMailboxMap::iterator,
61 std::pointer_to_binary_function<const TargetName&,
63 bool> > MailboxToTextureMap;
65 MailboxToTextureMap mailbox_to_textures_;
66 TextureToMailboxMap textures_to_mailboxes_;
68 DISALLOW_COPY_AND_ASSIGN(MailboxManager);
73 #endif // GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_