Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / cc / test / fake_ui_resource_layer_tree_host_impl.cc
blobd61ad7c5b1a6efa4a0a1aa6f22d652823d6400aa
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 TaskGraphRunner* task_graph_runner)
16 : FakeLayerTreeHostImpl(proxy, manager, task_graph_runner) {
19 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {}
21 void FakeUIResourceLayerTreeHostImpl::CreateUIResource(
22 UIResourceId uid,
23 const UIResourceBitmap& bitmap) {
24 if (ResourceIdForUIResource(uid))
25 DeleteUIResource(uid);
27 UIResourceData data;
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);
39 if (id)
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;
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