OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 scoped_refptr<UIResourceBitmap> bitmap) { | 2493 scoped_refptr<UIResourceBitmap> bitmap) { |
2494 DCHECK_GT(uid, 0); | 2494 DCHECK_GT(uid, 0); |
2495 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); | 2495 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); |
2496 | 2496 |
2497 // Allow for multiple creation requests with the same UIResourceId. The | 2497 // Allow for multiple creation requests with the same UIResourceId. The |
2498 // previous resource is simply deleted. | 2498 // previous resource is simply deleted. |
2499 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2499 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
2500 if (id) | 2500 if (id) |
2501 DeleteUIResource(uid); | 2501 DeleteUIResource(uid); |
2502 id = resource_provider_->CreateResource( | 2502 id = resource_provider_->CreateResource( |
2503 bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny); | 2503 bitmap->GetSize(), |
| 2504 resource_provider_->best_texture_format(), |
| 2505 ResourceProvider::TextureUsageAny); |
2504 | 2506 |
2505 ui_resource_map_[uid] = id; | 2507 ui_resource_map_[uid] = id; |
2506 resource_provider_->SetPixels(id, | 2508 resource_provider_->SetPixels(id, |
2507 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), | 2509 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), |
2508 gfx::Rect(bitmap->GetSize()), | 2510 gfx::Rect(bitmap->GetSize()), |
2509 gfx::Rect(bitmap->GetSize()), | 2511 gfx::Rect(bitmap->GetSize()), |
2510 gfx::Vector2d(0, 0)); | 2512 gfx::Vector2d(0, 0)); |
2511 } | 2513 } |
2512 | 2514 |
2513 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2515 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
2514 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2516 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
2515 if (id) { | 2517 if (id) { |
2516 resource_provider_->DeleteResource(id); | 2518 resource_provider_->DeleteResource(id); |
2517 ui_resource_map_.erase(uid); | 2519 ui_resource_map_.erase(uid); |
2518 } | 2520 } |
2519 } | 2521 } |
2520 | 2522 |
2521 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2523 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2522 UIResourceId uid) const { | 2524 UIResourceId uid) const { |
2523 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2525 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2524 if (iter != ui_resource_map_.end()) | 2526 if (iter != ui_resource_map_.end()) |
2525 return iter->second; | 2527 return iter->second; |
2526 return 0; | 2528 return 0; |
2527 } | 2529 } |
2528 | 2530 |
2529 } // namespace cc | 2531 } // namespace cc |
OLD | NEW |