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