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