| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/mailbox_manager.h" | 5 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 6 | 6 |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "crypto/hmac.h" | 8 #include "crypto/hmac.h" |
| 9 #include "gpu/command_buffer/service/gl_utils.h" | 9 #include "gpu/command_buffer/service/gl_utils.h" |
| 10 #include "gpu/command_buffer/service/texture_definition.h" | 10 #include "gpu/command_buffer/service/texture_definition.h" |
| 11 | 11 |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 namespace gles2 { | 13 namespace gles2 { |
| 14 | 14 |
| 15 MailboxManager::MailboxManager() | 15 MailboxManager::MailboxManager() |
| 16 : hmac_(crypto::HMAC::SHA256), | 16 : hmac_(crypto::HMAC::SHA256), |
| 17 textures_(std::ptr_fun(&MailboxManager::TargetNameLess)) { | 17 textures_(std::ptr_fun(&MailboxManager::TargetNameLess)) { |
| 18 base::RandBytes(private_key_, sizeof(private_key_)); | 18 base::RandBytes(private_key_, sizeof(private_key_)); |
| 19 bool success = hmac_.Init( | 19 bool success = hmac_.Init( |
| 20 base::StringPiece(private_key_, sizeof(private_key_))); | 20 base::StringPiece(private_key_, sizeof(private_key_))); |
| 21 DCHECK(success); | 21 DCHECK(success); |
| 22 } | 22 } |
| 23 | 23 |
| 24 MailboxManager::~MailboxManager() { | 24 MailboxManager::~MailboxManager() { |
| 25 DCHECK(!textures_.size()); |
| 25 } | 26 } |
| 26 | 27 |
| 27 void MailboxManager::GenerateMailboxName(MailboxName* name) { | 28 void MailboxManager::GenerateMailboxName(MailboxName* name) { |
| 28 base::RandBytes(name->key, sizeof(name->key)); | 29 base::RandBytes(name->key, sizeof(name->key)); |
| 29 SignMailboxName(name); | 30 SignMailboxName(name); |
| 30 } | 31 } |
| 31 | 32 |
| 32 TextureDefinition* MailboxManager::ConsumeTexture(unsigned target, | 33 TextureDefinition* MailboxManager::ConsumeTexture(unsigned target, |
| 33 const MailboxName& name) { | 34 const MailboxName& name) { |
| 34 if (!IsMailboxNameValid(name)) | 35 if (!IsMailboxNameValid(name)) |
| 35 return NULL; | 36 return NULL; |
| 36 | 37 |
| 37 TextureDefinitionMap::iterator it = | 38 TextureDefinitionMap::iterator it = |
| 38 textures_.find(TargetName(target, name)); | 39 textures_.find(TargetName(target, name)); |
| 39 if (it == textures_.end()) { | 40 if (it == textures_.end()) |
| 40 NOTREACHED(); | |
| 41 return NULL; | 41 return NULL; |
| 42 } | |
| 43 | 42 |
| 44 TextureDefinition* definition = it->second.definition.release(); | 43 TextureDefinition* definition = it->second.definition.release(); |
| 45 textures_.erase(it); | 44 textures_.erase(it); |
| 46 | 45 |
| 47 return definition; | 46 return definition; |
| 48 } | 47 } |
| 49 | 48 |
| 50 bool MailboxManager::ProduceTexture(unsigned target, | 49 bool MailboxManager::ProduceTexture(unsigned target, |
| 51 const MailboxName& name, | 50 const MailboxName& name, |
| 52 TextureDefinition* definition, | 51 TextureDefinition* definition, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 TextureManager* owner) | 115 TextureManager* owner) |
| 117 : definition(definition), | 116 : definition(definition), |
| 118 owner(owner) { | 117 owner(owner) { |
| 119 } | 118 } |
| 120 | 119 |
| 121 MailboxManager::OwnedTextureDefinition::~OwnedTextureDefinition() { | 120 MailboxManager::OwnedTextureDefinition::~OwnedTextureDefinition() { |
| 122 } | 121 } |
| 123 | 122 |
| 124 } // namespace gles2 | 123 } // namespace gles2 |
| 125 } // namespace gpu | 124 } // namespace gpu |
| OLD | NEW |