Setup a experiment to enable background tracing.
[chromium-blink-merge.git] / cc / test / fake_ui_resource_layer_tree_host_impl.cc
blobe48ef38072896a7befd02e47d65108c23b4f72a9
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 ResourceId id = ResourceIdForUIResource(uid);
38 if (id)
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;
47 return 0;
50 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid)
51 const {
52 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid);
53 DCHECK(iter != fake_ui_resource_map_.end());
54 return iter->second.opaque;
57 } // namespace cc