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
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
7 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
11 AsyncPixelTransferCompletionObserver::AsyncPixelTransferCompletionObserver() {}
13 AsyncPixelTransferCompletionObserver::~AsyncPixelTransferCompletionObserver() {}
15 AsyncPixelTransferManager::AsyncPixelTransferManager() {}
17 AsyncPixelTransferManager::~AsyncPixelTransferManager() {
19 manager_->RemoveObserver(this);
22 void AsyncPixelTransferManager::Initialize(gles2::TextureManager* manager) {
24 manager_->AddObserver(this);
27 AsyncPixelTransferDelegate*
28 AsyncPixelTransferManager::CreatePixelTransferDelegate(
29 gles2::TextureRef* ref,
30 const AsyncTexImage2DParams& define_params) {
31 DCHECK(!GetPixelTransferDelegate(ref));
32 AsyncPixelTransferDelegate* delegate =
33 CreatePixelTransferDelegateImpl(ref, define_params);
34 delegate_map_[ref] = make_linked_ptr(delegate);
38 AsyncPixelTransferDelegate*
39 AsyncPixelTransferManager::GetPixelTransferDelegate(
40 gles2::TextureRef* ref) {
41 TextureToDelegateMap::iterator it = delegate_map_.find(ref);
42 if (it == delegate_map_.end()) {
45 return it->second.get();
49 void AsyncPixelTransferManager::ClearPixelTransferDelegateForTest(
50 gles2::TextureRef* ref) {
51 TextureToDelegateMap::iterator it = delegate_map_.find(ref);
52 if (it != delegate_map_.end())
53 delegate_map_.erase(it);
56 bool AsyncPixelTransferManager::AsyncTransferIsInProgress(
57 gles2::TextureRef* ref) {
58 AsyncPixelTransferDelegate* delegate = GetPixelTransferDelegate(ref);
59 return delegate && delegate->TransferIsInProgress();
62 void AsyncPixelTransferManager::OnTextureManagerDestroying(
63 gles2::TextureManager* manager) {
64 // TextureManager should outlive AsyncPixelTransferManager.
69 void AsyncPixelTransferManager::OnTextureRefDestroying(
70 gles2::TextureRef* texture) {
71 TextureToDelegateMap::iterator it = delegate_map_.find(texture);
72 if (it != delegate_map_.end())
73 delegate_map_.erase(it);