| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/async_pixel_transfer_manager.h" | 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" | 7 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" |
| 8 | 8 |
| 9 namespace gpu { | 9 namespace gpu { |
| 10 | 10 |
| 11 AsyncPixelTransferCompletionObserver::AsyncPixelTransferCompletionObserver() {} | 11 AsyncPixelTransferCompletionObserver::AsyncPixelTransferCompletionObserver() {} |
| 12 | 12 |
| 13 AsyncPixelTransferCompletionObserver::~AsyncPixelTransferCompletionObserver() {} | 13 AsyncPixelTransferCompletionObserver::~AsyncPixelTransferCompletionObserver() {} |
| 14 | 14 |
| 15 AsyncPixelTransferManager::AsyncPixelTransferManager() {} | 15 AsyncPixelTransferManager::AsyncPixelTransferManager() : manager_(NULL) { |
| 16 } |
| 16 | 17 |
| 17 AsyncPixelTransferManager::~AsyncPixelTransferManager() { | 18 AsyncPixelTransferManager::~AsyncPixelTransferManager() { |
| 18 if (manager_) | 19 if (manager_) |
| 19 manager_->RemoveObserver(this); | 20 manager_->RemoveObserver(this); |
| 20 | 21 |
| 21 for (TextureToDelegateMap::iterator ref = delegate_map_.begin(); | 22 for (TextureToDelegateMap::iterator ref = delegate_map_.begin(); |
| 22 ref != delegate_map_.end(); | 23 ref != delegate_map_.end(); |
| 23 ref++) { | 24 ref++) { |
| 24 ref->first->RemoveObserver(); | 25 ref->first->RemoveObserver(); |
| 25 } | 26 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 const AsyncTexImage2DParams& define_params) { | 37 const AsyncTexImage2DParams& define_params) { |
| 37 DCHECK(!GetPixelTransferDelegate(ref)); | 38 DCHECK(!GetPixelTransferDelegate(ref)); |
| 38 AsyncPixelTransferDelegate* delegate = | 39 AsyncPixelTransferDelegate* delegate = |
| 39 CreatePixelTransferDelegateImpl(ref, define_params); | 40 CreatePixelTransferDelegateImpl(ref, define_params); |
| 40 delegate_map_[ref] = make_linked_ptr(delegate); | 41 delegate_map_[ref] = make_linked_ptr(delegate); |
| 41 ref->AddObserver(); | 42 ref->AddObserver(); |
| 42 return delegate; | 43 return delegate; |
| 43 } | 44 } |
| 44 | 45 |
| 45 AsyncPixelTransferDelegate* | 46 AsyncPixelTransferDelegate* |
| 46 AsyncPixelTransferManager::GetPixelTransferDelegate( | 47 AsyncPixelTransferManager::CreatePixelTransferDelegate( |
| 48 gles2::TextureRef* ref, |
| 49 const AsyncCompressedTexImage2DParams& define_params) { |
| 50 DCHECK(!GetPixelTransferDelegate(ref)); |
| 51 AsyncPixelTransferDelegate* delegate = |
| 52 CreatePixelTransferDelegateImpl(ref, define_params); |
| 53 delegate_map_[ref] = make_linked_ptr(delegate); |
| 54 ref->AddObserver(); |
| 55 return delegate; |
| 56 } |
| 57 |
| 58 AsyncPixelTransferDelegate* AsyncPixelTransferManager::GetPixelTransferDelegate( |
| 47 gles2::TextureRef* ref) { | 59 gles2::TextureRef* ref) { |
| 48 TextureToDelegateMap::iterator it = delegate_map_.find(ref); | 60 TextureToDelegateMap::iterator it = delegate_map_.find(ref); |
| 49 if (it == delegate_map_.end()) { | 61 if (it == delegate_map_.end()) { |
| 50 return NULL; | 62 return NULL; |
| 51 } else { | 63 } else { |
| 52 return it->second.get(); | 64 return it->second.get(); |
| 53 } | 65 } |
| 54 } | 66 } |
| 55 | 67 |
| 56 void AsyncPixelTransferManager::ClearPixelTransferDelegateForTest( | 68 void AsyncPixelTransferManager::ClearPixelTransferDelegateForTest( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 78 void AsyncPixelTransferManager::OnTextureRefDestroying( | 90 void AsyncPixelTransferManager::OnTextureRefDestroying( |
| 79 gles2::TextureRef* texture) { | 91 gles2::TextureRef* texture) { |
| 80 TextureToDelegateMap::iterator it = delegate_map_.find(texture); | 92 TextureToDelegateMap::iterator it = delegate_map_.find(texture); |
| 81 if (it != delegate_map_.end()) { | 93 if (it != delegate_map_.end()) { |
| 82 delegate_map_.erase(it); | 94 delegate_map_.erase(it); |
| 83 texture->RemoveObserver(); | 95 texture->RemoveObserver(); |
| 84 } | 96 } |
| 85 } | 97 } |
| 86 | 98 |
| 87 } // namespace gpu | 99 } // namespace gpu |
| OLD | NEW |