Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / content / browser / android / ui_resource_provider_impl.cc
blobcd45d7cc634d160e56ce9ddc67cde910ab834f0f
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.
5 #include "content/browser/android/ui_resource_provider_impl.h"
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"
11 namespace content {
13 UIResourceProviderImpl::UIResourceProviderImpl()
14 : system_ui_resource_manager_(this), host_(NULL),
15 supports_etc1_npot_(false) {
19 UIResourceProviderImpl::~UIResourceProviderImpl() {
20 SetLayerTreeHost(NULL);
23 void UIResourceProviderImpl::SetLayerTreeHost(cc::LayerTreeHost* host) {
24 if (host_ == host)
25 return;
26 host_ = host;
27 UIResourcesAreInvalid();
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();
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());
47 ui_resource_client_map_[id] = client;
48 return id;
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());
56 ui_resource_client_map_.erase(iter);
58 if (!host_)
59 return;
60 host_->DeleteUIResource(ui_resource_id);
63 ui::SystemUIResourceManager&
64 UIResourceProviderImpl::GetSystemUIResourceManager() {
65 return system_ui_resource_manager_;
68 bool UIResourceProviderImpl::SupportsETC1NonPowerOfTwo() const {
69 return supports_etc1_npot_;
72 } // namespace content