| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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. | |
| 4 | |
| 5 #include "content/browser/android/ui_resource_provider_impl.h" | |
| 6 | |
| 7 #include "cc/resources/ui_resource_client.h" | |
| 8 #include "cc/trees/layer_tree_host.h" | |
| 9 #include "content/public/browser/android/ui_resource_client_android.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 UIResourceProviderImpl::UIResourceProviderImpl() | |
| 14 : system_ui_resource_manager_(this), host_(NULL), | |
| 15 supports_etc1_npot_(false) { | |
| 16 | |
| 17 } | |
| 18 | |
| 19 UIResourceProviderImpl::~UIResourceProviderImpl() { | |
| 20 SetLayerTreeHost(NULL); | |
| 21 } | |
| 22 | |
| 23 void UIResourceProviderImpl::SetLayerTreeHost(cc::LayerTreeHost* host) { | |
| 24 if (host_ == host) | |
| 25 return; | |
| 26 host_ = host; | |
| 27 UIResourcesAreInvalid(); | |
| 28 } | |
| 29 | |
| 30 void UIResourceProviderImpl::UIResourcesAreInvalid() { | |
| 31 UIResourceClientMap client_map = ui_resource_client_map_; | |
| 32 ui_resource_client_map_.clear(); | |
| 33 for (UIResourceClientMap::iterator iter = client_map.begin(); | |
| 34 iter != client_map.end(); | |
| 35 iter++) { | |
| 36 iter->second->UIResourceIsInvalid(); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 cc::UIResourceId UIResourceProviderImpl::CreateUIResource( | |
| 41 UIResourceClientAndroid* client) { | |
| 42 if (!host_) | |
| 43 return 0; | |
| 44 cc::UIResourceId id = host_->CreateUIResource(client); | |
| 45 DCHECK(ui_resource_client_map_.find(id) == ui_resource_client_map_.end()); | |
| 46 | |
| 47 ui_resource_client_map_[id] = client; | |
| 48 return id; | |
| 49 } | |
| 50 | |
| 51 void UIResourceProviderImpl::DeleteUIResource(cc::UIResourceId ui_resource_id) { | |
| 52 UIResourceClientMap::iterator iter = | |
| 53 ui_resource_client_map_.find(ui_resource_id); | |
| 54 DCHECK(iter != ui_resource_client_map_.end()); | |
| 55 | |
| 56 ui_resource_client_map_.erase(iter); | |
| 57 | |
| 58 if (!host_) | |
| 59 return; | |
| 60 host_->DeleteUIResource(ui_resource_id); | |
| 61 } | |
| 62 | |
| 63 ui::SystemUIResourceManager& | |
| 64 UIResourceProviderImpl::GetSystemUIResourceManager() { | |
| 65 return system_ui_resource_manager_; | |
| 66 } | |
| 67 | |
| 68 bool UIResourceProviderImpl::SupportsETC1NonPowerOfTwo() const { | |
| 69 return supports_etc1_npot_; | |
| 70 } | |
| 71 | |
| 72 } // namespace content | |
| OLD | NEW |