| 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 2525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2536 const LayerTreeDebugState& new_debug_state) { | 2536 const LayerTreeDebugState& new_debug_state) { |
| 2537 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 2537 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
| 2538 return; | 2538 return; |
| 2539 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) | 2539 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) |
| 2540 paint_time_counter_->ClearHistory(); | 2540 paint_time_counter_->ClearHistory(); |
| 2541 | 2541 |
| 2542 debug_state_ = new_debug_state; | 2542 debug_state_ = new_debug_state; |
| 2543 SetFullRootLayerDamage(); | 2543 SetFullRootLayerDamage(); |
| 2544 } | 2544 } |
| 2545 | 2545 |
| 2546 void LayerTreeHostImpl::CreateUIResource( | 2546 void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, |
| 2547 UIResourceId uid, | 2547 const UIResourceBitmap& bitmap) { |
| 2548 scoped_refptr<UIResourceBitmap> bitmap) { | |
| 2549 DCHECK_GT(uid, 0); | 2548 DCHECK_GT(uid, 0); |
| 2550 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); | 2549 DCHECK_EQ(bitmap.GetFormat(), UIResourceBitmap::RGBA8); |
| 2551 | 2550 |
| 2552 // Allow for multiple creation requests with the same UIResourceId. The | 2551 // Allow for multiple creation requests with the same UIResourceId. The |
| 2553 // previous resource is simply deleted. | 2552 // previous resource is simply deleted. |
| 2554 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2553 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2555 if (id) | 2554 if (id) |
| 2556 DeleteUIResource(uid); | 2555 DeleteUIResource(uid); |
| 2557 id = resource_provider_->CreateResource( | 2556 id = resource_provider_->CreateResource( |
| 2558 bitmap->GetSize(), | 2557 bitmap.GetSize(), |
| 2559 resource_provider_->best_texture_format(), | 2558 resource_provider_->best_texture_format(), |
| 2560 ResourceProvider::TextureUsageAny); | 2559 ResourceProvider::TextureUsageAny); |
| 2561 | 2560 |
| 2562 ui_resource_map_[uid] = id; | 2561 ui_resource_map_[uid] = id; |
| 2563 resource_provider_->SetPixels(id, | 2562 resource_provider_->SetPixels(id, |
| 2564 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), | 2563 bitmap.GetPixels(), |
| 2565 gfx::Rect(bitmap->GetSize()), | 2564 gfx::Rect(bitmap.GetSize()), |
| 2566 gfx::Rect(bitmap->GetSize()), | 2565 gfx::Rect(bitmap.GetSize()), |
| 2567 gfx::Vector2d(0, 0)); | 2566 gfx::Vector2d(0, 0)); |
| 2568 } | 2567 } |
| 2569 | 2568 |
| 2570 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 2569 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 2571 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 2570 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2572 if (id) { | 2571 if (id) { |
| 2573 resource_provider_->DeleteResource(id); | 2572 resource_provider_->DeleteResource(id); |
| 2574 ui_resource_map_.erase(uid); | 2573 ui_resource_map_.erase(uid); |
| 2575 } | 2574 } |
| 2576 } | 2575 } |
| 2577 | 2576 |
| 2578 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2577 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2579 UIResourceId uid) const { | 2578 UIResourceId uid) const { |
| 2580 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2579 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2581 if (iter != ui_resource_map_.end()) | 2580 if (iter != ui_resource_map_.end()) |
| 2582 return iter->second; | 2581 return iter->second; |
| 2583 return 0; | 2582 return 0; |
| 2584 } | 2583 } |
| 2585 | 2584 |
| 2586 } // namespace cc | 2585 } // namespace cc |
| OLD | NEW |