Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / cc / test / fake_ui_resource_layer_tree_host_impl.cc
blob3dbea527e4ceb830724a6fef9b3cf881c21a32f4
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 "cc/test/fake_ui_resource_layer_tree_host_impl.h"
7 #include "cc/resources/ui_resource_bitmap.h"
8 #include "cc/test/fake_layer_tree_host_impl.h"
10 namespace cc {
12 FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl(
13 Proxy* proxy,
14 SharedBitmapManager* manager)
15 : FakeLayerTreeHostImpl(proxy, manager, nullptr) {
18 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {}
20 void FakeUIResourceLayerTreeHostImpl::CreateUIResource(
21 UIResourceId uid,
22 const UIResourceBitmap& bitmap) {
23 if (ResourceIdForUIResource(uid))
24 DeleteUIResource(uid);
26 UIResourceData data;
27 data.resource_id = resource_provider()->CreateResource(
28 bitmap.GetSize(), GL_CLAMP_TO_EDGE,
29 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888);
31 data.size = bitmap.GetSize();
32 data.opaque = bitmap.GetOpaque();
33 fake_ui_resource_map_[uid] = data;
36 void FakeUIResourceLayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
37 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
38 if (id)
39 fake_ui_resource_map_.erase(uid);
42 ResourceProvider::ResourceId
43 FakeUIResourceLayerTreeHostImpl::ResourceIdForUIResource(
44 UIResourceId uid) const {
45 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid);
46 if (iter != fake_ui_resource_map_.end())
47 return iter->second.resource_id;
48 return 0;
51 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid)
52 const {
53 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid);
54 DCHECK(iter != fake_ui_resource_map_.end());
55 return iter->second.opaque;
58 } // namespace cc