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

Unified Diff: gpu/command_buffer/service/mailbox_manager.h

Issue 12717013: Add reference-counting for mailbox textures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add optional 'pool' reference while textures are in mailbox Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/mailbox_manager.h
diff --git a/gpu/command_buffer/service/mailbox_manager.h b/gpu/command_buffer/service/mailbox_manager.h
index 8f97dd4af6d867b4ee96b906c8af998b186649da..8cd4087a463ad70c4b6162ed7a10f2eff885cc8c 100644
--- a/gpu/command_buffer/service/mailbox_manager.h
+++ b/gpu/command_buffer/service/mailbox_manager.h
@@ -5,6 +5,7 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
#define GPU_COMMAND_BUFFER_SERVICE_MAILBOX_MANAGER_H_
+#include <algorithm>
#include <functional>
#include <map>
@@ -12,6 +13,7 @@
#include "base/memory/ref_counted.h"
#include "crypto/hmac.h"
#include "gpu/command_buffer/common/constants.h"
+#include "gpu/command_buffer/service/texture_definition.h"
#include "gpu/gpu_export.h"
// From gl2/gl2ext.h.
@@ -24,9 +26,6 @@ typedef signed char GLbyte;
namespace gpu {
namespace gles2 {
-class TextureDefinition;
-class TextureManager;
-
// Identifies a mailbox where a texture definition can be stored for
// transferring textures between contexts that are not in the same context
// group. It is a random key signed with a hash of a private key.
@@ -37,7 +36,9 @@ struct GPU_EXPORT MailboxName {
};
// Manages resources scoped beyond the context or context group level.
-class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
+class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager>,
+ public TextureDefinition::Observer,
+ private TextureDefinition::Client {
public:
MailboxManager();
@@ -47,20 +48,30 @@ class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
// Remove the texture definition from the named mailbox and empty the mailbox.
TextureDefinition* ConsumeTexture(unsigned target, const MailboxName& name);
+ enum TexturePoolType {
+ TEXTURE_POOL_NONE,
+ TEXTURE_POOL_FOR_SURFACE,
+ };
+
+ typedef std::pair<TexturePoolType, int> TexturePoolId;
+ static const TexturePoolId TexturePoolNone;
+
// Put the texture definition in the named mailbox.
bool ProduceTexture(unsigned target,
const MailboxName& name,
TextureDefinition* definition,
- TextureManager* owner);
-
- // Destroy any texture definitions and mailboxes owned by the given texture
- // manager.
- void DestroyOwnedTextures(TextureManager* owner, bool have_context);
+ TexturePoolId pool);
std::string private_key() {
return std::string(private_key_, sizeof(private_key_));
}
+ // TextureDefinition::Observer implementation
+ virtual void OnDestroySharedTexture(const TextureDefinition* definition)
+ OVERRIDE;
+
+ void RemoveTexturesFromPool(TexturePoolId pool_id, bool have_context);
+
private:
friend class base::RefCounted<MailboxManager>;
@@ -77,17 +88,16 @@ class GPU_EXPORT MailboxManager : public base::RefCounted<MailboxManager> {
static bool TargetNameLess(const TargetName& lhs, const TargetName& rhs);
- struct OwnedTextureDefinition {
- OwnedTextureDefinition(TextureDefinition* definition,
- TextureManager* owner);
- ~OwnedTextureDefinition();
- linked_ptr<TextureDefinition> definition;
- TextureManager* owner;
+ struct MailboxTexture {
+ MailboxTexture(TextureDefinition* definition, TexturePoolId pool_id)
+ : definition(definition), pool_id(pool_id) {}
+ TextureDefinition* definition;
+ TexturePoolId pool_id;
};
typedef std::map<
TargetName,
- OwnedTextureDefinition,
+ MailboxTexture,
std::pointer_to_binary_function<
const TargetName&, const TargetName&, bool> > TextureDefinitionMap;
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc ('k') | gpu/command_buffer/service/mailbox_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698