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 TaskGraphRunner
* task_graph_runner
)
16 : FakeLayerTreeHostImpl(proxy
, manager
, task_graph_runner
) {
19 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {}
21 void FakeUIResourceLayerTreeHostImpl::CreateUIResource(
23 const UIResourceBitmap
& bitmap
) {
24 if (ResourceIdForUIResource(uid
))
25 DeleteUIResource(uid
);
28 data
.resource_id
= resource_provider()->CreateResource(
29 bitmap
.GetSize(), GL_CLAMP_TO_EDGE
,
30 ResourceProvider::TEXTURE_HINT_IMMUTABLE
, RGBA_8888
);
32 data
.size
= bitmap
.GetSize();
33 data
.opaque
= bitmap
.GetOpaque();
34 fake_ui_resource_map_
[uid
] = data
;
37 void FakeUIResourceLayerTreeHostImpl::DeleteUIResource(UIResourceId uid
) {
38 ResourceId id
= ResourceIdForUIResource(uid
);
40 fake_ui_resource_map_
.erase(uid
);
43 ResourceId
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
;
51 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid
)
53 UIResourceMap::const_iterator iter
= fake_ui_resource_map_
.find(uid
);
54 DCHECK(iter
!= fake_ui_resource_map_
.end());
55 return iter
->second
.opaque
;