| 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;
|
|
|
|
|