| OLD | NEW |
| (Empty) |
| 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/resources/ui_resource_bitmap.h" | |
| 8 #include "cc/test/fake_layer_tree_host_impl.h" | |
| 9 | |
| 10 namespace cc { | |
| 11 | |
| 12 FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl( | |
| 13 Proxy* proxy, | |
| 14 SharedBitmapManager* manager) | |
| 15 : FakeLayerTreeHostImpl(proxy, manager, nullptr), | |
| 16 fake_next_resource_id_(1) { | |
| 17 } | |
| 18 | |
| 19 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {} | |
| 20 | |
| 21 void FakeUIResourceLayerTreeHostImpl::CreateUIResource( | |
| 22 UIResourceId uid, | |
| 23 const UIResourceBitmap& bitmap) { | |
| 24 if (ResourceIdForUIResource(uid)) | |
| 25 DeleteUIResource(uid); | |
| 26 | |
| 27 UIResourceData data; | |
| 28 data.resource_id = fake_next_resource_id_++; | |
| 29 data.size = bitmap.GetSize(); | |
| 30 data.opaque = bitmap.GetOpaque(); | |
| 31 fake_ui_resource_map_[uid] = data; | |
| 32 } | |
| 33 | |
| 34 void FakeUIResourceLayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | |
| 35 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | |
| 36 if (id) | |
| 37 fake_ui_resource_map_.erase(uid); | |
| 38 } | |
| 39 | |
| 40 ResourceProvider::ResourceId | |
| 41 FakeUIResourceLayerTreeHostImpl::ResourceIdForUIResource( | |
| 42 UIResourceId uid) const { | |
| 43 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid); | |
| 44 if (iter != fake_ui_resource_map_.end()) | |
| 45 return iter->second.resource_id; | |
| 46 return 0; | |
| 47 } | |
| 48 | |
| 49 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid) | |
| 50 const { | |
| 51 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid); | |
| 52 DCHECK(iter != fake_ui_resource_map_.end()); | |
| 53 return iter->second.opaque; | |
| 54 } | |
| 55 | |
| 56 } // namespace cc | |
| OLD | NEW |