| Index: gpu/command_buffer/service/mailbox_manager.cc
|
| diff --git a/gpu/command_buffer/service/mailbox_manager.cc b/gpu/command_buffer/service/mailbox_manager.cc
|
| index 90193934f3a4dd40ba797266978847b653241e69..d4afe2cdf26f25554deae808bcd78292d60f00f2 100644
|
| --- a/gpu/command_buffer/service/mailbox_manager.cc
|
| +++ b/gpu/command_buffer/service/mailbox_manager.cc
|
| @@ -6,9 +6,9 @@
|
|
|
| #include <algorithm>
|
|
|
| +#include "base/bind.h"
|
| #include "base/rand_util.h"
|
| #include "crypto/hmac.h"
|
| -#include "gpu/command_buffer/service/gl_utils.h"
|
| #include "gpu/command_buffer/service/texture_definition.h"
|
|
|
| namespace gpu {
|
| @@ -48,16 +48,17 @@ TextureDefinition* MailboxManager::ConsumeTexture(unsigned target,
|
| if (it == textures_.end())
|
| return NULL;
|
|
|
| - TextureDefinition* definition = it->second.definition.release();
|
| + TextureDefinition* definition = it->second;
|
| textures_.erase(it);
|
|
|
| + TextureDefinition::DestroyCallback cb;
|
| + definition->SetDestroyCallback(cb);
|
| return definition;
|
| }
|
|
|
| bool MailboxManager::ProduceTexture(unsigned target,
|
| const MailboxName& name,
|
| - TextureDefinition* definition,
|
| - TextureManager* owner) {
|
| + TextureDefinition* definition) {
|
| if (!IsMailboxNameValid(name))
|
| return false;
|
|
|
| @@ -65,30 +66,23 @@ bool MailboxManager::ProduceTexture(unsigned target,
|
| textures_.find(TargetName(target, name));
|
| if (it != textures_.end()) {
|
| NOTREACHED();
|
| - GLuint service_id = it->second.definition->ReleaseServiceId();
|
| - glDeleteTextures(1, &service_id);
|
| - it->second = OwnedTextureDefinition(definition, owner);
|
| + it->second = definition;
|
| } else {
|
| - textures_.insert(std::make_pair(
|
| - TargetName(target, name),
|
| - OwnedTextureDefinition(definition, owner)));
|
| + textures_.insert(std::make_pair(TargetName(target, name), definition));
|
| }
|
|
|
| + definition->SetDestroyCallback(base::Bind(
|
| + &MailboxManager::OnDestroyTexture, this));
|
| return true;
|
| }
|
|
|
| -void MailboxManager::DestroyOwnedTextures(TextureManager* owner,
|
| - bool have_context) {
|
| +void MailboxManager::OnDestroyTexture(TextureDefinition* definition) {
|
| TextureDefinitionMap::iterator it = textures_.begin();
|
| while (it != textures_.end()) {
|
| TextureDefinitionMap::iterator current_it = it;
|
| ++it;
|
| - if (current_it->second.owner == owner) {
|
| - GLuint service_id = current_it->second.definition->ReleaseServiceId();
|
| - if (have_context)
|
| - glDeleteTextures(1, &service_id);
|
| + if (current_it->second == definition)
|
| textures_.erase(current_it);
|
| - }
|
| }
|
| }
|
|
|
| @@ -118,15 +112,5 @@ bool MailboxManager::TargetNameLess(const MailboxManager::TargetName& lhs,
|
| return memcmp(&lhs, &rhs, sizeof(lhs)) < 0;
|
| }
|
|
|
| -MailboxManager::OwnedTextureDefinition::OwnedTextureDefinition(
|
| - TextureDefinition* definition,
|
| - TextureManager* owner)
|
| - : definition(definition),
|
| - owner(owner) {
|
| -}
|
| -
|
| -MailboxManager::OwnedTextureDefinition::~OwnedTextureDefinition() {
|
| -}
|
| -
|
| } // namespace gles2
|
| } // namespace gpu
|
|
|