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/test/fake_layer_tree_host_impl.h"
11 FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl(
13 SharedBitmapManager
* manager
)
14 : FakeLayerTreeHostImpl(proxy
, manager
), fake_next_resource_id_(1) {}
16 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {}
18 void FakeUIResourceLayerTreeHostImpl::CreateUIResource(
20 const UIResourceBitmap
& bitmap
) {
21 if (ResourceIdForUIResource(uid
))
22 DeleteUIResource(uid
);
25 data
.resource_id
= fake_next_resource_id_
++;
26 data
.size
= bitmap
.GetSize();
27 data
.opaque
= bitmap
.GetOpaque();
28 fake_ui_resource_map_
[uid
] = data
;
31 void FakeUIResourceLayerTreeHostImpl::DeleteUIResource(UIResourceId uid
) {
32 ResourceProvider::ResourceId id
= ResourceIdForUIResource(uid
);
34 fake_ui_resource_map_
.erase(uid
);
37 ResourceProvider::ResourceId
38 FakeUIResourceLayerTreeHostImpl::ResourceIdForUIResource(
39 UIResourceId uid
) const {
40 UIResourceMap::const_iterator iter
= fake_ui_resource_map_
.find(uid
);
41 if (iter
!= fake_ui_resource_map_
.end())
42 return iter
->second
.resource_id
;
46 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid
)
48 UIResourceMap::const_iterator iter
= fake_ui_resource_map_
.find(uid
);
49 DCHECK(iter
!= fake_ui_resource_map_
.end());
50 return iter
->second
.opaque
;