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. 4 5 #include "cc/test/fake_ui_resource_layer_tree_host_impl.h" 6 7 #include "cc/test/fake_layer_tree_host_impl.h" 8 9 namespace cc { 10 11 FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl( 12 Proxy* proxy, 13 SharedBitmapManager* manager) 14 : FakeLayerTreeHostImpl(proxy, manager), fake_next_resource_id_(1) {} 15 16 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {} 17 18 void FakeUIResourceLayerTreeHostImpl::CreateUIResource( 19 UIResourceId uid, 20 const UIResourceBitmap& bitmap) { 21 if (ResourceIdForUIResource(uid)) 22 DeleteUIResource(uid); 23 24 UIResourceData data; 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; 29 } 30 31 void FakeUIResourceLayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { 32 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 33 if (id) 34 fake_ui_resource_map_.erase(uid); 35 } 36 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; 43 return 0; 44 } 45 46 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid) 47 const { 48 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid); 49 DCHECK(iter != fake_ui_resource_map_.end()); 50 return iter->second.opaque; 51 } 52 53 } // namespace cc 54