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"
12 FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl(
14 SharedBitmapManager
* manager
)
15 : FakeLayerTreeHostImpl(proxy
, manager
, nullptr) {
18 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {}
20 void FakeUIResourceLayerTreeHostImpl::CreateUIResource(
22 const UIResourceBitmap
& bitmap
) {
23 if (ResourceIdForUIResource(uid
))
24 DeleteUIResource(uid
);
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 ResourceId id
= ResourceIdForUIResource(uid
);
39 fake_ui_resource_map_
.erase(uid
);
42 ResourceId
FakeUIResourceLayerTreeHostImpl::ResourceIdForUIResource(
43 UIResourceId uid
) const {
44 UIResourceMap::const_iterator iter
= fake_ui_resource_map_
.find(uid
);
45 if (iter
!= fake_ui_resource_map_
.end())
46 return iter
->second
.resource_id
;
50 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid
)
52 UIResourceMap::const_iterator iter
= fake_ui_resource_map_
.find(uid
);
53 DCHECK(iter
!= fake_ui_resource_map_
.end());
54 return iter
->second
.opaque
;